// my library 1.0
// 1.1 add image bold title and br on hyphen
// shadow around any image of class shadow
$(document).ready(function() {
/*						   
	// gradual display of unique selling points on Home page
	$('#homeusps').children('p:nth-child(1)').delay(500).fadeIn();	
	$('#homeusps').children('p:nth-child(2)').delay(1200).fadeIn();
	$('#homeusps').children('p:nth-child(3)').delay(1900).fadeIn();	
	$('#homeusps').children('p:nth-child(4)').delay(2600).fadeIn();	
	
//	$('#homemenu ul li').children().children('li:nth-child(1)').delay(1500).fadeIn();
	// menu control
//	$('#homemenu ul li').children().children().fadeIn();
	
	$('li.submenu').hover(function(){
		$('ul', this).fadeIn();
		}, function() {	
		$('ul', this).fadeOut();
	});	
	*/
/*
	$('li.submenu').hover(function(){
		$('li.submenu ul').fadeOut(0);						
		$('ul', this).fadeIn('slow');

	}, function() {
		$('li.submenu ul').fadeOut();
	});	
	
	$('li.submenu').hover(function(){
		$('ul', this).stop().css({visibility:'visible'},{queue:false,duration:500});
	}, function() {
		$('ul', this).stop().css({visibility:'hidden'},{queue:false,duration:500});
	});	
	
	*/	
	$('#homemenu a').each(function(index) {	// select this page in menu and top level item too
		loc = window.location.toString();
		nextMenuItem = $(this).eq(0).attr('href');
		if(loc.indexOf(nextMenuItem) != -1) {
			$(this).parent().children('a').addClass('selected');	
			if ($(this).parent().parent().parent().children('a').hasClass('top')) {
				$(this).parent().parent().parent().children('a').addClass('selected');	
			}
		}
		//alert(loc+'   '+nextMenuItem);							
	});
	
	$('#mainmenu a').each(function(index) {	// select this page in menu and top level item too
		loc = window.location.toString();
		nextMenuItem = $(this).eq(0).attr('href');
		if(loc.indexOf(nextMenuItem) != -1) {
			$(this).parent().children('a').addClass('selected');	
			if ($(this).parent().parent().parent().children('a').hasClass('top2')) {
				$(this).parent().parent().parent().children('a').addClass('selected');	
			}
		}
		//alert(loc+'   '+nextMenuItem);							
	});	
	
	
	
	$('li.submenu').hover(function(){
		$('ul', this).animate({height:'200px'},{duration:700});
	}, function() {
		$('li.submenu ul').stop().animate({height:'0'},{queue:false,duration:0});
	});		
		
$('li.submenu').click(function(){
		$('li.submenu ul').css('height', '0');
	});		
	
	$('.shadow').each(function(index) {
		picwidth = parseFloat($(this).width()) + 5 + "px";	
		picheight = parseFloat($(this).height()) + 5 + "px";	
		pic = "pic" + index;
		dotpic = ".pic" + index;
		picTitle = $(this).attr('alt');
		if (picTitle.indexOf(' - ') !=-1) picTitle = "<b>" + picTitle.replace(" - ", "</b><br />");
		
		$(this).replaceWith('<div class="shadowout ' + pic + '"  ><div class="shadowin"><div class="imagecap"><img src="' + $(this).attr('src') + '" /><div class="caption"><p>' + picTitle + '</p></div></div><div class="tr"><img src="images/bg-filler.gif" /></div><div class="bl"><img src="images/bg-filler.gif" /></div><div class="br"><img src="images/bg-filler.gif" /></div></div></div>');
	
		$(dotpic).css({ // addspace for shadow
		'width': picwidth,
		'height': picheight
		});
		
		if ($(this).hasClass('rightimage')) 
			$(dotpic).addClass('rightimage');
		if ($(this).hasClass('leftimage')) 
			$(dotpic).addClass('leftimage');			
		
	});
	
	$('.justCaption').each(function(index) {
		picwidth = parseFloat($(this).width())  + "px";	
		picheight = parseFloat($(this).height())  + "px";	
		pic = "pic2" + index;
		dotpic = ".pic2" + index;
		
		$(this).replaceWith('<div class="shadowout ' + pic + '"  ><div class="shadowin"><div class="imagecap"><img src="' + $(this).attr('src') + '" /><div class="caption"><p>' + $(this).attr('alt') + '</p></div></div></div></div>');
	
		$(dotpic).css({ // addspace for shadow
		'width': picwidth,
		'height': picheight
		});
		
		if ($(this).hasClass('rightimage')) 
			$(dotpic).addClass('rightimage');
		if ($(this).hasClass('leftimage')) 
			$(dotpic).addClass('leftimage');			
		
	});

	//Full Caption Sliding (Hidden to Visible)
	$('.imagecap').hover(function(){
		$(".caption", this).stop().animate({bottom:'0px'},{queue:false,duration:500});
	}, function() {
		$(".caption", this).stop().animate({bottom:'-45px'},{queue:false,duration:500});
	});

		
		
		
});

