//FEATURE AREA SCRIPT

$(document).ready(function () {
							
	var openingScreenTime = 1000;
	var	menuFadeInTime = 100;
							
	//defines the easyslider
	if($("#slider").length != 0){
		$("#slider").easySlider();
	}
	
	//hides the whole nav and feature on startup
	$(".navHolder, .navFeature, .subNav").hide("");
	
	//gives all subnav classes an id
	$(".subNav").parent("li").attr("id", function (number) {
		return "mainNav" + number;		  
	});
	
	//gives all subnav classes an id
	$(".subNav").attr("id", function (number) {
		return "subNav" + number;		  
	});
	
	//gives all top level li's within subnav an id
	$(".subNav").children("li").attr("id", function (number) {
		return "subNavLi" + number;		  
	});
	
	//gives all items with navFeature class an id
	$(".navFeature").attr("id", function (number) {
		return "navFeature" + number;		  
	});
	
	//on mouseover of mainNav li hides all subNavs then shows one with same id
	$(".subNav").parent("li").mouseover(function(event){									
		var id = this.id.replace("mainNav" , 'subNav');
		$(".subNav").hide("");
		$("#" + id).show("");	
		$("#mainNav li a").removeClass("active");
		$(this).children("a").addClass("active");
		//alert(this.id);
	});
			
	//on mouseover of subNav li hides all navFeatures then shows one with same id
	$(".subNav").children("li").mouseover(function(event){									
		var id = this.id.replace("subNavLi" , 'navFeature');
		$(".navFeature").hide("");
		$("#" + id).show("");
		$("#mainNav ul.subNav li").removeClass("active");
		$(this).addClass("active");
		//alert(this.id);			
	});
	
	//hides navFeature and subNav on mouseleave
	$(".navFeature").mouseleave(function(event){
		$(".navFeature, .subNav").hide("");
		$("#mainNav li a, #mainNav ul.subNav li").removeClass("active");
	});
	
	//hides navFeature on mouseenter
	$("#mainNav").children("li").mouseenter(function(event){
		$(".navFeature").hide("");
	});
	
	//hides subNav on mouseleave
	$(".featureArea, .miscContentHolder").mouseleave(function(event){
		$(".subNav, .navFeature").hide("");
		$("#mainNav li a, #mainNav ul.subNav li").removeClass("active");
	});	
	
	//hides subNav on mouseenter
	$(".miscNav, .mainContentText").mouseenter(function(event){
		$(".subNav, .navFeature").hide("");
		$("#mainNav li a, #mainNav ul.subNav li").removeClass("active");
	});	
					
	//fade-out opening screen after set amount of time
	setTimeout(function () { $(".openScreen").fadeOut("slow"); }, openingScreenTime);
	
	//fade-in menu after set amount of time
	setTimeout(function () { $(".navHolder").fadeIn("slow"); }, menuFadeInTime);		

});

//END FEATURE AREA SCRIPT
