/***************************/
//@Author: Adrian "yEnS" Mato Gondelle & Ivan Guardado Castro
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
/***************************/

$(document).ready(function(){
	
	var sections = [
			"mainabout",
			"mainhouserules",
			"mainicinfo",
			"maindirections",
			"maincontact",
			"mainlinks"
		];
	
	function showSection(section)
	{
		jQuery.each(sections, function(){
			if ("div."+this != section){
				$("div."+this).hide();				
			}
		});
		$("div." + section).fadeIn();
	}	
	
	function display(section)
	{
		if ($("div#shell").height() < 444) {
			// Expand the shell and display the target section when that's done.
			
			// now then.. to figure out the IE crap.. you only have to do it here:
			
			$("div#quoteie8").animate( {opacity:.00}, 500, function() { $("div#quoteie8").hide(); /* I dunno */ });
			$("div#quote").animate( {opacity:.00}, 500, function () { 
				$("div#shell").animate( {height:"444px"}, 1500); 
				$("div#bgcover").css({ opacity: 0.0 }).animate( {opacity:.70}, 2500, function(){ showSection(section) });
			});
		} else {
			// Nothing to be done but display the target section.
			showSection(section);
		}		
	}
		
	$(".nav-menu > div").click(function(e){
		switch(e.target.id){
			case ".menuabout":
				display("mainabout");
				break;
				
			case ".menuhouserules":
				display("mainhouserules");
				break;
				
			case ".menuicinfo":
				display("mainicinfo");
				break;
				
			case ".menudirections":
				display("maindirections");
				break;
				
			case ".menucontact":
				display("maincontact");
				break;
				
			case ".menulinks":
				display("mainlinks");
				break;
				
			default:
				// I always include a default in my switch statements. Even if there's nothing there.
				break;
		}
		return false;
	});
});