$(document).ready(function() {
	// fire lightbox
	$("#gallery a").lightBox({containerResizeSpeed: 200});
	
	//clean out images for links
	function cleanImage(n){
		n = n.replace(/ /g,'');
		n = n.replace(/\|/g,'');
		
		n = n.toLowerCase();
	//	console.log(n);
		return n;
	}


	function imageReplace(n, p){ //n=image p=imageheight
		$img = cleanImage(n.text());
		$last = $img.lastIndexOf("/");		
		// setup rollover.  CSS must be set to overview hidden. 
		n.text("").html("<img src='/images/menu_"+ $img +".gif' />");		
		n.children("img").css({marginTop:"0px"});
		n.css({display: "block", overflow: "hidden", height: ""+ p + "px"});
		n.hover(function(){
				n.children("img").css({marginTop:"-"+ p + "px"});
			},function(){
				n.children("img").css({marginTop:"0px"});
		});

	}
	
	// fire image replace on the menu items
	$("#mainmenu a").each(function(){imageReplace($(this), 35);});
	
	// make header clickable.
	$("h1").click(function(){
		location = "/";
		});
	$("h1").css({cursor: "pointer"});
	
	
	//subnav subitems dropdown.
	$("#nav_sub ul").hide();
	
	
	$("#nav_sub li").hover(
		function(){
		// rollover effect
	//	alert($(this).children("ul").css("display"));
			if($(this).children("ul").css("display") == "none"){
			//	$(this).children("ul").slideDown(300, function(){
			//	});		
			}
		},
		function(){
		//rolloff effect
			//$(this).children("ul").slideUp(300, function(){
		//	});
	});

	
});