// Switches the main menu image when hovered over
// Last edited: 08/14/2010
// Dev: Chris Peterson

$(document).ready(function() {
	var images = {"ulu_history.jpg": "ulu_history_over.jpg",
				  "factory_history.jpg": "factory_history_over.jpg",
				  "how_made.jpg": "how_made_over.jpg",
				  "how_use.jpg": "how_use_over.jpg",
				  "request_catalog.jpg": "request_catalog_over.jpg",
				  "catalog.jpg": "catalog_over.jpg",
				  "join_list.jpg": "join_list_over.jpg"};
	
	$("ul#main-menu a").bind({
		mouseenter: function() {
			
			var raw_paths = $(this).children("img").attr("src").split("/");
			var old_path = raw_paths.pop();
			
			if(old_path.indexOf("over") != -1)
				return false;
			
			var image_path = raw_paths.join("/");
			var hover_path = image_path + "/" + images[old_path];
			$(this).children("img").attr("src",hover_path);
		},
		mouseout: function() {
			var raw_paths = $(this).children("img").attr("src").split("/");
			var cur_path = raw_paths.pop();
			
			if(cur_path.indexOf("over") == -1)
				return false;
			
			var image_path = raw_paths.join("/");
			var old_path_working = cur_path.split("_");
			old_path_working.pop();
			var old_path = image_path + "/" + old_path_working.join("_") + ".jpg";
			$(this).children("img").attr("src",old_path);
		}					 
	});
	
});
