$(document).ready(function(){
	jQuery.preloadimages = function() {
		for(var i = 0; i<arguments.length; i++) {
			jQuery("<img>").attr("src", arguments[i]);
		}
	}
	
	$.preloadimages("images/nav_pj_over.png","images/nav_books_over.png","images/nav_appearances_over.png",
	"images/nav_writetous_over.png","images/nav_inspiration_over.png","images/nav_photogallery_over.png","images/triangle_over.gif",
	"images/triangle_over.gif", "images/nav_faq_over.png", "images/nav_links_over.png", "images/nav_media_over.png",
	"images/subnav_the-little-death_over.png","images/subnav_south-of-hell_over.png","images/subnav_a-thousand-bones_over.png","images/subnav_an-unquiet-grave_over.png",
	"images/subnav_a-killing-rain_over.png","images/subnav_island-of-bones_over.png","images/subnav_thicker-than-water_over.png","images/subnav_paint-it-black_over.png",
	"images/subnav_dead-of-winter_over.png","images/subnav_dark-of-the-moon_over.png");

	$('#pj').hover(function() {
		$(this).attr("src","images/nav_pj_over.png");
			}, function() {
		$(this).attr("src","images/nav_pj.png");
	});
	
	$('#sidebar-container').hover(function() {
		$('#sidebar').fadeIn(1200);
			}, function() {
		$('#sidebar').fadeOut(1200);
	});
	
	$('#books').hover(function() {
		$(this).attr("src","images/nav_books_over.png");
			}, function() {
		$(this).attr("src","images/nav_books.png");
	});
	
	$('#links').hover(function() {
		$(this).attr("src","images/nav_links_over.png");
			}, function() {
		$(this).attr("src","images/nav_links.png");
	});
	
	$('#media').hover(function() {
		$(this).attr("src","images/nav_media_over.png");
			}, function() {
		$(this).attr("src","images/nav_media.png");
	});
	
	$('#faq').hover(function() {
		$(this).attr("src","images/nav_faq_over.png");
			}, function() {
		$(this).attr("src","images/nav_faq.png");
	});
	
	$('#appearances').hover(function() {
		$(this).attr("src","images/nav_appearances_over.png");
			}, function() {
		$(this).attr("src","images/nav_appearances.png");
	});
	
	$('#writetous').hover(function() {
		$(this).attr("src","images/nav_writetous_over.png");
			}, function() {
		$(this).attr("src","images/nav_writetous.png");
	});
	
	$('#inspiration').hover(function() {
		$(this).attr("src","images/nav_inspiration_over.png");
			}, function() {
		$(this).attr("src","images/nav_inspiration.png");
	});
	
	$('#photogallery').hover(function() {
		$(this).attr("src","images/nav_photogallery_over.png");
			}, function() {
		$(this).attr("src","images/nav_photogallery.png");
	});
	
	$('#the-little-death').hover(function() {
		$(this).attr("src","images/subnav_the-little-death_over.png");
			}, function() {
		$(this).attr("src","images/subnav_the-little-death.png");
	});
	
	$('#south-of-hell').hover(function() {
		$(this).attr("src","images/subnav_south-of-hell_over.png");
			}, function() {
		$(this).attr("src","images/subnav_south-of-hell.png");
	});
	
	$('#a-thousand-bones').hover(function() {
		$(this).attr("src","images/subnav_a-thousand-bones_over.png");
			}, function() {
		$(this).attr("src","images/subnav_a-thousand-bones.png");
	});
	
	$('#an-unquiet-grave').hover(function() {
		$(this).attr("src","images/subnav_an-unquiet-grave_over.png");
			}, function() {
		$(this).attr("src","images/subnav_an-unquiet-grave.png");
	});
	
	$('#a-killing-rain').hover(function() {
		$(this).attr("src","images/subnav_a-killing-rain_over.png");
			}, function() {
		$(this).attr("src","images/subnav_a-killing-rain.png");
	});
	
	$('#island-of-bones').hover(function() {
		$(this).attr("src","images/subnav_island-of-bones_over.png");
			}, function() {
		$(this).attr("src","images/subnav_island-of-bones.png");
	});
	
	$('#thicker-than-water').hover(function() {
		$(this).attr("src","images/subnav_thicker-than-water_over.png");
			}, function() {
		$(this).attr("src","images/subnav_thicker-than-water.png");
	});
	
	$('#paint-it-black').hover(function() {
		$(this).attr("src","images/subnav_paint-it-black_over.png");
			}, function() {
		$(this).attr("src","images/subnav_paint-it-black.png");
	});
	
	$('#dead-of-winter').hover(function() {
		$(this).attr("src","images/subnav_dead-of-winter_over.png");
			}, function() {
		$(this).attr("src","images/subnav_dead-of-winter.png");
	});
	
	$('#dark-of-the-moon').hover(function() {
		$(this).attr("src","images/subnav_dark-of-the-moon_over.png");
			}, function() {
		$(this).attr("src","images/subnav_dark-of-the-moon.png");
	});
	
	$('#short-stories').hover(function() {
		$(this).attr("src","images/subnav_short-stories_over.png");
			}, function() {
		$(this).attr("src","images/subnav_short-stories.png");
	});
	
	$('#backtotop').hover(function() {
		$(this).attr("src","images/triangle_over.gif");
			}, function() {
		$(this).attr("src","images/triangle.gif");
	});
		
	function fadeImage() {
		if ($("#keys:visible").size() > 0) {
			$("#keys").fadeOut(2000);
		} else if ($("#keys:hidden").size() > 0) {
			$("#keys").fadeIn(2000);
		}
	}
	
	setInterval(fadeImage,5000)

});