
// init stuff

$(document).ready(function() {

	$("#about").addClass("selected");
	$('#header').fadeIn(1000);
	
	hideAll();
	$current_content = "about";
	$('#about_content').fadeIn(2000);
	$('#map').hide();
	
});


// Top Menu Navigation

$(document).ready(function() {

	$('div.top_menu_item').click(function(event) { 
	
		if(event.target.id != $current_content){

			$current_content = event.target.id;

			hideAll();
			clearSelection();
			$(event.target).addClass("selected");

			switch(event.target.id){ 
			
				case "home": $('.wrap').fadeOut("3000"); window.location = "../index.php"; break;
				case "weekender": $(document.body).css("background","#000000 url(../img/weekender/covers.jpg) no-repeat -70px 257px"); break;
				case "web": $('#web'+$current_web_subpage).fadeIn("slow"); break;
				case "design": $('#design'+$current_web_subpage).fadeIn("slow"); break;
				case "video": getVideo($current_video_subpage); break;
				
			}
			
			$("#"+event.target.id+"_content").fadeIn('slow');
			
		}
		  
	});
			
});

function hideAll(){
/*
	$('.sub_page').hide();
	$('#about_content').hide();
	$('#weekender_content').hide();
	$('#design_content').hide();
	$('#web_content').hide();
	$('#video_content').hide();
	$('#contact_content').hide();
*/
}

function clearSelection(){

	$("#about").removeClass("selected");
	$("#weekender").removeClass("selected");
	$("#design").removeClass("selected");
	$("#web").removeClass("selected");
	$("#video").removeClass("selected");
	$("#contact").removeClass("selected");

}


//	Web Subpage Navigation

$(document).ready(function() { 

	$current_web_subpage = 1;
	$total_web_subpages =  $('#web_content').children().size() - 2;

	$('div.web_nav').click(function(event) { 
	
		if(event.target.id == 'web_left'){
		
			$('#web'+$current_web_subpage).fadeOut(1000);
			
			$current_web_subpage--;
			if($current_web_subpage == 0){ $current_web_subpage = $total_web_subpages; }
			
			$('#web'+$current_web_subpage).fadeIn(1000);
		
		} else {
		
			$('#web'+$current_web_subpage).fadeOut(1000);
			
			$current_web_subpage++;
			if($current_web_subpage > $total_web_subpages){ $current_web_subpage = 1; }
			
			$('#web'+$current_web_subpage).fadeIn(1000);
		
		}

	});

});


//	design Subpage Navigation

$(document).ready(function() { 

	$current_design_subpage = 1;
	$total_design_subpages = $('#design_content').children().size() - 3; 

	$('div.design_nav').click(function(event) { 
	
		if(event.target.id == 'design_nav_left'){
		
			$('#design'+$current_design_subpage).fadeOut(1000);
			
			$current_design_subpage--;
			if($current_design_subpage == 0){ $current_design_subpage = $total_design_subpages; }
			
			$('#design'+$current_design_subpage).fadeIn(1000);
		
		} else {
		
			$('#design'+$current_design_subpage).fadeOut(1000);
			
			$current_design_subpage++;
			if($current_design_subpage > $total_design_subpages){ $current_design_subpage = 1; }
			
			$('#design'+$current_design_subpage).fadeIn(1000);
		
		}

	});

});


//	Video Subpage Navigation

$(document).ready(function() { 

	$current_video_subpage = 1;
	$total_video_subpages = 3;

	$('div.video_nav').click(function(event) { 
	
		if(event.target.id == 'video_nav_left'){
		
			$current_video_subpage--;
			if($current_video_subpage == 0){ $current_video_subpage = $total_video_subpages; }
					
		} else {
		
			$current_video_subpage++;
			if($current_video_subpage > $total_video_subpages){ $current_video_subpage = 1; }
					
		}
		
		getVideo($current_video_subpage);


	});

});

function getVideo(page) {

	$.ajax({
		type: "GET",
		url: "vid"+page+".php", //pages/
		success: function(r){
			$("#video_sub").html(r);
			$("#video_sub").hide();
			$('#video_sub').fadeIn(1000);
		}
	});

}


// Map clicky stuff

$(document).ready(function() { 

	$('#map_link').click(function(event) { $("#map").slideToggle(); });
	$('#print_map').click(function(event) { printMap(); });

});

//Print map

function printMap(){

	var html = "<HTML><BODY>\n<img id='map' src='img/contact/map.png' weight='555px' height='660px' />\n</BODY>\n</HTML>";
	var printWP = window.open("","printMap");
	
	printWP.document.open();
	printWP.document.write(html);
	printWP.document.close();
	printWP.print();

}


//Mars Hovers
$(document).ready(function() { 

	$('div.top_menu_item').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); 
	$('.web_nav').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); 
	$('.design_nav').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); 
	$('.video_nav').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); 
	$('#map_link').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); 
	$('#print_map').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); 

});











