




// preload image function
// 
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

// preload images for each img classed "menuItem"
//
$(window).bind('load', function() 
{
	$('.menuItem').each(function(elm) {
		$.preloadImages($(this).attr("src").replace("0.png", "1.png"));
	});
});

// In each page's body element, there is a hidden <p> tag with class "keeplit",
// whose contents is the "id" of the menu element that is to STAY LIT.
// This value is read into variable "isLit" and is tested against the "id" of each menu img
// that is moused over. If they match, it skips the code that would reset the image to its
// non-moused-over (white) version.
//
$(document).ready(function(){
	$(".menuItem").hover(
		function(){
			if($(this).attr("src").indexOf("_roll") == -1) {
				var newSrc = $(this).attr("src").replace(".gif","_roll.gif");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			var isLit = $(".keeplit").html();
			if($(this).attr("id") == isLit) {
				return;
			}

			if($(this).attr("src").indexOf("_roll.gif") != -1) {
				var oldSrc = $(this).attr("src").replace("_roll.gif",".gif");
				$(this).attr("src",oldSrc);
			}
		}
	);
	
	$(".projectItem").hover(
		function(){
			if($(this).attr("src").indexOf("_f2") == -1) {
				var newSrc = $(this).attr("src").replace(".jpg","_f2.jpg");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			
			if($(this).attr("src").indexOf("_f2.jpg") != -1) {
				var oldSrc = $(this).attr("src").replace("_f2.jpg",".jpg");
				$(this).attr("src",oldSrc);
			}
		}
	);
	
	$(".projectItemGIF").hover(
		function(){
			if($(this).attr("src").indexOf("_f2") == -1) {
				var newSrc = $(this).attr("src").replace(".gif","_f2.gif");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			
			if($(this).attr("src").indexOf("_f2.gif") != -1) {
				var oldSrc = $(this).attr("src").replace("_f2.gif",".gif");
				$(this).attr("src",oldSrc);
			}
		}
	);

	// reset the "you're here now" tab to "highlighted" image
	//
	var lit = $(".keeplit").html();
	var newSrc = $("#"+lit).attr("src").replace(".jpg","_Roll.jpg");
	$("#"+lit).attr("src",newSrc);
});