$(document).ready(function(){
	
	//Load Image
	$(window).load(function() {
		    $('.splash').fadeIn("slow");
			$.windowvariable = {
				myCounter : "0"
			};
		    $("#slide_counter").val($.windowvariable.myCounter.valueOf());  
			$(".slide_nav_left a").each(function() {
				this.href = this.href.split("#")[0] + "#window" + 0;
			});
			$(".slide_nav_right a").each(function() {
				this.href = this.href.split("#")[0] + "#window" + 1;
			});
		    
		   // var url = window.location.search
		   // var string = url.split("=");
		    //alert(string[1])
		   // if(url[1]){
			   // 
			   //	$("#first_page").fadeIn("slow"); //Turn on first page text
				//$(".slide_nav_right").fadeIn("slow"); // Turn on the left nav
			//	$(".shdw_edge_left").fadeIn("slow");
				//$(".shdw_edge_right").fadeIn("slow");
				
				//Set the navigation background for the windows link. 
				//$("#left_3").fadeIn("slow");
				//$("#right_3").fadeIn("slow");
				//$("#navItem_3").css("background","url(/images/bck_nav.jpg) top left repeat-x");
				
				//$(".splash").css("left", "-1050px"); //push splash off to the left and start window slide show. 
				//$(".slideWindows").css("left", "-50px");
				//$("#window_1").fadeOut("slow");
				//$("#slide_counter").attr('value', '1');
				//$('#navItem_3').unbind('click');
		    //}
		    
	});

/*---
Hashtags
----------*/

if(window.location.hash.toLowerCase() == "#window0") {
	
			
			 var newCount = 2
			 $("input#slide_counter").val(newCount); 
			$(".slide_nav_left a").each(function() {
				this.href = this.href.split("#")[0] + "#window" + 1;
			});
			$(".slide_nav_right a").each(function() {
				this.href = this.href.split("#")[0] + "#window" + 3;
			});
			
	$("#first_page").fadeIn("slow"); //Turn on first page text
			$(".slide_nav_right").fadeIn("slow"); // Turn on the left nav
			$(".shdw_edge_left").fadeIn("slow");
			$(".shdw_edge_right").fadeIn("slow");
			
			//Set the navigation background for the windows link. 
			$("#left_3").fadeIn("slow");
			$("#right_3").fadeIn("slow");
			
			
			$(".splash").animate({"left": "-=1050px"}, "slow"); //push splash off to the left and start window slide show. 
			$(".slideWindows").animate({"left": "-=1050px"}, "slow", function(){
				$("#window_1").fadeOut("slow");
			});
			
			//$('#navItem_3').unbind('click').clearQueue().unbind('hover');
			$("#navItem_3").css("background","url(/images/bck_nav.jpg) top left repeat-x").unbind('click').unbind('hover');
}

	
/*-----------
NAVIGATION
----------------*/

	//Hover event for main navigation
	$('div[class^=navItem]').hover(
		function() {
			var $this = $(this);
			var x = $this.attr("id");
			var tempid = x.split("_");
			if(tempid[1] <= 3){
				$("#navItem_"+tempid[1]).css("background","url(/images/bck_nav.jpg) top left repeat-x");
				$("#left_"+tempid[1]).fadeIn("slow");
				$("#right_"+tempid[1]).fadeIn("slow");
			}else{
				$("#navItem_"+tempid[1]+" a").css("color","#d44a14");	
			}
		}, 
		function() {
			var $this = $(this);
			var x = $this.attr("id");
			var tempid = x.split("_");
			if(tempid[1] <= 3){
				$("#navItem_"+tempid[1]).css("background","none");
				$("#left_"+tempid[1]).fadeOut("slow");
				$("#right_"+tempid[1]).fadeOut("slow");
			}else{
				$("#navItem_"+tempid[1]+" a").css("color","#5a471b");	
			}

	});
/*-----------
OPEN SLIDE SHOW
----------------*/
	$("#toWindows").one('click', 
		function() {
			
			$("#first_page").fadeIn("slow"); //Turn on first page text
			$(".slide_nav_right").fadeIn("slow"); // Turn on the left nav
			$(".shdw_edge_left").fadeIn("slow");
			$(".shdw_edge_right").fadeIn("slow");
			
			//Set the navigation background for the windows link. 
			$("#left_3").fadeIn("slow");
			$("#right_3").fadeIn("slow");
			
			
			$(".splash").animate({"left": "-=1050px"}, "slow"); //push splash off to the left and start window slide show. 
			$(".slideWindows").animate({"left": "-=1050px"}, "slow", function(){
				$("#window_1").fadeOut("slow");
			});
			$("#slide_counter").attr('value', '1');
			//$('#navItem_3').unbind('click').clearQueue().unbind('hover');
			$("#navItem_3").css("background","url(/images/bck_nav.jpg) top left repeat-x").unbind('click').unbind('hover');
		});
		
	$("#navItem_3").one('click', 
		function() {
			
			$("#first_page").fadeIn("slow"); //Turn on first page text
			$(".slide_nav_right").fadeIn("slow"); // Turn on the left nav
			
			//Set the navigation background for the windows link. 
			$("#left_3").fadeIn("slow");
			$("#right_3").fadeIn("slow");
			$("#navItem_3").css("background","url(/images/bck_nav.jpg) top left repeat-x");
			
			$(".splash").animate({"left": "-=1050px"}, "slow"); //push splash off to the left and start window slide show. 
			$(".slideWindows").animate({"left": "-=1050px"}, "slow", function(){
				$("#window_1").fadeOut("slow");
			});
			$("#slide_counter").attr('value', '1');
			
			//$(this).unbind('click');
			
		});
		
		
		
/*-----------
SLIDE OUT MOVIE SLEEVE
----------------*/

/*-----------
ARROW NAV RIGHT
----------------*/
	$("#moveRight").click(
		
		function() {
			var x = $("#slide_counter").attr('value');
			this.href = this.href.split("#")[0] + "#window" + x;
			$("img[id^=window]").fadeIn("slow");
			$("#detail_results").fadeOut("slow");
			$("#movie_slider").fadeOut("slow");
			
			switch(x){
				case '1':
					$(".slideWindows").animate({"left": "-=100px"}, "slow", function(){
						//Turn on directions
						$("#first_page").fadeOut("slow");
						//Turn on the left slider
						$(".slide_nav_left").fadeIn("slow");
						$("#window_2").fadeOut("slow");
						
						//Populate the details
						$(".artist_results").html("<h2>Tanenbaum</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/b_trees.pdf' target='_blank'><img src='/images/detail_2.gif' id='detail_2'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '2':
					$(".slideWindows").animate({"left": "-=210px"}, "slow", function(){
						$("#window_3").fadeOut("slow");
						
						//Populate the details
						$(".artist_results").html("<h2>All Spruced Up</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/c_tree.pdf' target='_blank'><img src='/images/detail_3.gif' id='detail_3'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '3':
					$(".slideWindows").animate({"left": "-=210px"}, "slow", function(){
						$("#window_4").fadeOut("slow");
						
						$(".artist_results").html("<h2>Packer Love</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/d_lovepackers.pdf' target='_blank'><img src='/images/detail_4.gif' id='detail_4'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '4':
					$(".slideWindows").animate({"left": "-=580px"}, "slow", function(){
						$("#window_5").fadeOut("slow");
						
						$(".artist_results").html("<h2>Ever Present</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/e_present.pdf' target='_blank'><img src='/images/detail_5.gif' id='detail_5'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '5':
					$(".slideWindows").animate({"left": "-=480px"}, "slow", function(){
						$("#window_6").fadeOut("slow");
						
						$(".artist_results").html("<h2>Fred & Ginger</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/h_gingerbread.pdf' target='_blank'><img src='/images/detail_6.gif' id='detail_6'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '6':
					$(".slideWindows").animate({"left": "-=1750px"}, "slow", function(){
						$("#window_7").fadeOut("slow");
						
						$(".artist_results").html("<h2>Star Bright</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/l_starflake.pdf' target='_blank'><img src='/images/detail_7.gif' id='detail_7'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '7':
					$(".slideWindows").animate({"left": "-=390px"}, "slow", function(){
						$("#window_8").fadeOut("slow");
						
						$(".artist_results").html("<h2>Snow Time Like the Present</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/o_snowfall.pdf' target='_blank'><img src='/images/detail_8.gif' id='detail_8'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '8':
					$(".slideWindows").animate({"left": "-=380px"}, "slow", function(){
						$("#window_9").fadeOut("slow");
						
						$(".artist_results").html("<h2>Ornamental Couple</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/p_ornaments.pdf' target='_blank'><img src='/images/detail_9.gif' id='detail_9'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '9':
					$(".slideWindows").animate({"left": "-=110px"}, "slow", function(){
						$("#window_10").fadeOut("slow");
						
						$(".artist_results").html("<h2>Hats Off</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/q_hat.pdf' target='_blank'><img src='/images/detail_10.gif' id='detail_10'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '10':
					$(".slideWindows").animate({"left": "-=340px"}, "slow", function(){
						$("#window_11").fadeOut("slow");
						
						$(".artist_results").html("<h2>Poinsetti-Ahhh</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/r_poinsettia.pdf' target='_blank'><img src='/images/detail_11.gif' id='detail_11'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '11':
					$(".slideWindows").animate({"left": "-=325px"}, "slow", function(){
						$("#window_12").fadeOut("slow");
						
						$(".artist_results").html("<h2>Hanging Around</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/s_ornaments.pdf' target='_blank'><img src='/images/detail_12.gif' id='detail_12'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '12':
					$(".slideWindows").animate({"left": "-=170px"}, "slow", function(){
						$("#window_13").fadeOut("slow");
						
						$(".artist_results").html("<h2>Flakefall</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/t_snowflake.pdf' target='_blank'><img src='/images/detail_13.gif' id='detail_13'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '13':
					$(".slideWindows").animate({"left": "-=250px"}, "slow", function(){
						$("#window_14").fadeOut("slow");
						
						$(".artist_results").html("<h2>OrnaMint</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/u_candycane.pdf' target='_blank'><img src='/images/detail_15.gif' id='detail_14'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '14':
					$(".slideWindows").animate({"left": "-=170px"}, "slow", function(){
						$("#window_15").fadeOut("slow");
						
						$(".artist_results").html("<h2>Dreidle Me This</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/v_dreidle.pdf' target='_blank'><img src='/images/detail_14.gif' id='detail_15'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '15':
					$(".slideWindows").animate({"left": "-=530px"}, "slow", function(){
						$("#window_16").fadeOut("slow");
						
						$(".artist_results").html("<h2>Stocking Stuffer</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/w_stocking.pdf' target='_blank'><img src='/images/detail_16.gif' id='detail_16'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '16':
					$(".slideWindows").animate({"left": "-=530px"}, "slow", function(){
						$(".slide_nav_right").fadeOut("slow");
						$("#window_17").fadeOut("slow");
						
						$(".artist_results").html("<h2>Take a Bough</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/z_tree.pdf' target='_blank'><img src='/images/detail_17.gif' id='detail_17'></a>'>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
			}
			//$(".slideWindows").animate({"left": "-=1000px"}, "slow");
			var new_slide = ++x;
			$("#slide_counter").attr('value', new_slide);
			//$("#debug").html(new_slide);
		});

/*-----------
ARROW NAV LEFT
----------------*/		
	$("#moveLeft").click(
		function() {
			var x = $("#slide_counter").attr('value');
			$("img[id^=window]").fadeIn("slow");
			$("#detail_results").fadeOut("slow");
			$("#movie_slider").fadeOut("slow");
			
			switch(x){
				case '2':
					$(".slideWindows").animate({"left": "+=100px"}, "slow", function(){
						$("#first_page").fadeIn("slow");
						$(".slide_nav_left").fadeOut("slow");
						$("#window_1").fadeOut("slow");
						
						
					});
					break;
				case '3':
					$(".slideWindows").animate({"left": "+=210px"}, "slow", function(){
						$("#window_2").fadeOut("slow");
						
						//Populate the details
						$(".artist_results").html("<h2>Tanenbaum</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/a_tree.pdf' target='_blank'><img src='/images/detail_2.gif' id='detail_2'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
							
					});
				
					break;
				case '4':
					$(".slideWindows").animate({"left": "+=210px"}, "slow", function(){
						$("#window_3").fadeOut("slow");
						
						//Populate the details
						$(".artist_results").html("<h2>All Spruced Up</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/c_tree.pdf' target='_blank'><img src='/images/detail_3.gif' id='detail_3'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					
					break;
				case '5':
					$(".slideWindows").animate({"left": "+=580px"}, "slow", function(){
						$("#window_4").fadeOut("slow");
						
						$(".artist_results").html("<h2>Packer Love</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/d_lovepackers.pdf' target='_blank'><img src='/images/detail_4.gif' id='detail_4'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					
					break;
				case '6':
					$(".slideWindows").animate({"left": "+=480px"}, "slow", function(){
						$("#window_5").fadeOut("slow");
						
						$(".artist_results").html("<h2>Ever Present</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/e_present.pdf' target='_blank'><img src='/images/detail_5.gif' id='detail_5'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '7':
					$(".slideWindows").animate({"left": "+=1750px"}, "slow", function(){
						$("#window_6").fadeOut("slow");
						
						$(".artist_results").html("<h2>Fred & Ginger</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/h_gingerbread.pdf' target='_blank'><img src='/images/detail_6.gif' id='detail_6'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '8':
					$(".slideWindows").animate({"left": "+=390px"}, "slow", function(){
						$("#window_7").fadeOut("slow");
						
						$(".artist_results").html("<h2>Star Bright</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/l_starflake.pdf' target='_blank'><img src='/images/detail_7.gif' id='detail_7'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '9':
					$(".slideWindows").animate({"left": "+=380px"}, "slow", function(){
						$("#window_8").fadeOut("slow");
						
						$(".artist_results").html("<h2>Snow Time Like the Present</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/o_snowfall.pdf' target='_blank'><img src='/images/detail_8.gif' id='detail_8'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '10':
					$(".slideWindows").animate({"left": "+=110px"}, "slow", function(){
						$("#window_9").fadeOut("slow");
						
						$(".artist_results").html("<h2>Ornamental Couple</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/p_ornaments.pdf' target='_blank'><img src='/images/detail_9.gif' id='detail_9'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '11':
					$(".slideWindows").animate({"left": "+=340px"}, "slow", function(){
						$("#window_10").fadeOut("slow");
						
						$(".artist_results").html("<h2>Hats Off</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/q_hat.pdf' target='_blank'><img src='/images/detail_10.gif' id='detail_10'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '12':
					$(".slideWindows").animate({"left": "+=325px"}, "slow", function(){
						$("#window_11").fadeOut("slow");
						
						$(".artist_results").html("<h2>Poinsetti-Ahhh</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/r_poinsettia.pdf' target='_blank'><img src='/images/detail_11.gif' id='detail_11'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '13':
					$(".slideWindows").animate({"left": "+=170px"}, "slow", function(){
						$("#window_12").fadeOut("slow");
						
						$(".artist_results").html("<h2>Hanging Around</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/s_ornaments.pdf' target='_blank'><img src='/images/detail_12.gif' id='detail_12'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '14':
					$(".slideWindows").animate({"left": "+=250px"}, "slow", function(){
						$("#window_13").fadeOut("slow");
						
						$(".artist_results").html("<h2>Flakefall</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/t_snowflake.pdf' target='_blank'><img src='/images/detail_13.gif' id='detail_13'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '15':
					$(".slideWindows").animate({"left": "+=170px"}, "slow", function(){
						$(".slide_nav_right").fadeIn("slow");
						$("#window_14").fadeOut("slow");
						
						$(".artist_results").html("<h2>OrnaMint</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/u_candycane.pdf' target='_blank'><img src='/images/detail_15.gif' id='detail_14'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '16':
					$(".slideWindows").animate({"left": "+=530px"}, "slow", function(){
						$(".slide_nav_right").fadeIn("slow");
						$("#window_15").fadeOut("slow");
						
						$(".artist_results").html("<h2>Dreidle Me This</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/v_dreidle.pdf' target='_blank'><img src='/images/detail_14.gif' id='detail_15'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '17':
					$(".slideWindows").animate({"left": "+=530px"}, "slow", function(){
						$(".slide_nav_right").fadeIn("slow");
						$("#window_16").fadeOut("slow");
						
						$(".artist_results").html("<h2>Stocking Stuffer</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/w_stocking.pdf' target='_blank'><img src='/images/detail_16.gif' id='detail_16'></a>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
				case '18':
					$(".slideWindows").animate({"left": "+=530px"}, "slow", function(){
						$(".slide_nav_right").fadeIn("slow");
						$("#window_17").fadeOut("slow");
						
						$(".artist_results").html("<h2>Take a Bough</h2>");
						$(".nam_results").html("");
						$("#img").html("<a href='/PDF/z_tree.pdf' target='_blank'><img src='/images/detail_17.gif' id='detail_17'></a>'>");
						$('#img img').bind("load", function() {
		     					$("#detail_results").fadeIn("slow");
	     					});
					});
					break;
			}
			
			var new_slide = --x;
			$("#slide_counter").attr('value', new_slide);
			
			
			//$("#debug").html(new_slide);
		});
		
$("#moveLeft").click(function() {
	var y = $("#slide_counter").attr('value');
			$(".slide_nav_left a").each(function() {
				this.href = this.href.split("#")[0] + "#window" + (y-1);
			});
			$(".slide_nav_right a").each(function() {
				this.href = this.href.split("#")[0] + "#window" + (y+1);
			});
});



 });
