var image_names = ["about", "contact", "forum", "greaterthan", "lessthan", "media", "monster", "panda", "small-about", "small-contact", "small-forum", "small-media"];
var image_srcs = new Array();
function loadImages()
{
	for (loop = 0; loop < image_names.length; loop++)
	{
		image_srcs[image_names[loop]] = new Image();
		image_srcs[image_names[loop]].src = "over-" + image_names[loop] + ".png";
	}
}
image_srcs = new Array();
function loadImages2()
{
	for (loop = 1; loop < 6; loop++)
	{
		if (loop == 1)
			bloodID = "";
		else
			bloodID = loop;
		var image_id = 0;
		for (var innerLoop = 0; innerLoop < 6; innerLoop++)
		{
			if (innerLoop == 0)
				image_id = "blank";
			else
				image_id = innerLoop;
			image_srcs["" + loop + "." + innerLoop] = new Image();
			image_srcs["" + loop + "." + innerLoop].src = "blood" + bloodID + "-" + image_id + ".png";
		}
	}
}
loadImages();
loadImages2();

jQuery(function( $ ){
	$.localScroll.defaults.axis = 'yx';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		queue:true,
		duration:1000
	});
	$.localScroll({
		queue:true,
		duration:1000,
		hash:true
	});
	if (window.opera)
	{
		$("#top, #left, #bottom, #right").hide();
		$("#trailer").css("background", "url('bigrag.png') no-repeat");
	}
	if (!window.location.hash)
	{
		$("#body").css("left", "2000px");
		//setTimeout("$('#body').animate({ left:0 }, 'slow')", 1000);
	}
	$(window).load(function(){
		if (!window.location.hash)
			setTimeout("$('#body').animate({ left:0 }, 'slow')", 1000);
		$(".blood").each(function(){
			var src = $(this).attr("src");
			if (!src.match(/-/))
			{
				$(this).attr("src", src.replace(".png", "-blank.png"));
				temp = window.location.hash;
				if (temp == "#body" || (temp == "" && "home" == $(this).parent().parent().attr("id")))
					temp = "#home";
				if (temp.match($(this).parent().parent().attr("id")))
					animationStation(src.replace(".png", "-blank.png"), temp);
			}
		});
	});
	/*
	$(".blood").load(function(){
		var src = $(this).attr("src");
		if (!src.match(/-/))
		{
			$(this).attr("src", src.replace(".png", "-blank.png"));
			temp = window.location.hash;
			if (temp == "#body" || (temp == "" && "home" == $(this).parent().parent().attr("id")))
				temp = "#home";
			if (temp.match($(this).parent().parent().attr("id")))
				animationStation(src.replace(".png", "-blank.png"), temp);
		}
	});*/
	var animationStation = function(src, sectionID)
	{
		if (sectionID == "#body")
			sectionID = "#home";
		switch (sectionID)
		{
			case "#home":
				var delay = 2500;
			break;
			case "#about":
				var delay = 2000;
			break;
			case "#media":
				var delay = 5500;
			break;
			case "#forum":
				var delay = 3000;
			break;
			case "#contact":
				var delay = 5000;
			break;
		}
		$(sectionID + " .blood").delay(delay).queue(function(){
			$(this).attr("src", src.replace("blank", "1"));
			$(this).dequeue();
		}).delay(300).queue(function(){
			$(this).attr("src", src.replace("blank", "2"));
			$(this).dequeue();
		}).delay(100).queue(function(){
			$(this).attr("src", src.replace("blank", "3"));
			$(this).dequeue();
		}).delay(300).queue(function(){
			$(this).attr("src", src.replace("blank", "4"));
			$(this).dequeue();
		}).delay(100).queue(function(){
			$(this).attr("src", src.replace("blank", "5"));
			$(this).dequeue();
		});
	};
	
	
	var email1 = "Team" + "@" + "DiChrome2" + ".com";
	var email2 = "Dylan" + "@" + "DiChrome2" + ".com";
	$("#email1").html("<a href=\"mailto:" + email1 + "\">" + email1 + "</a>");
	$("#email2").html("<a href=\"mailto:" + email2 + "\">" + email2 + "</a>");
		
	$(".menu").mouseover(function(){
		$(this).attr("src", "over-" + $(this).attr("src"));
	}).mouseout(function(){
		$(this).attr("src", $(this).attr("src").replace("over-", ""));
	})
	
	$(".menu, .menu2").click(function(){
		var src = $($(this).parent().attr("href") + " .blood").attr("src"), sectionID = $(this).parent().attr("href");
		animationStation(src, sectionID);
	});
	
});
