$(function (){

//	NAVIGATION SECTION
//	------------------
		
	//Hover Intent config's
 	var configSubMenu = {    
     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
     interval: 0, // number = milliseconds for onMouseOver polling interval    
     over: over, // function = onMouseOver callback (REQUIRED)    
     timeout: 400, // number = milliseconds delay before onMouseOut    
     out: out // function = onMouseOut callback (REQUIRED)    
	};
	$("#nav .subMenu").hide();	
 	
 	//Submenu display
 	$("#nav > ul > li").each(function () {
	 	if($("#" + $(this).attr("id")+"> div.subMenu").length > 0){
	 		$("#" + $(this).attr("id")).hoverIntent(configSubMenu);
	 	}
 	});
	
	function over(evt) {
		//Align
		var thisOne = "#"+$(this).attr("id");
		var leftPos = $(thisOne).position().left;
		$(thisOne + " .subMenu").css("left", leftPos+25);

		
       var zIndexNumber = 4000;
       // Put your target element(s) in the selector below!
       $(thisOne + " .subMenu").each(function() {
               $(this).css('zIndex', zIndexNumber);
               zIndexNumber -= 10;
       });

		$("#nav > ul > li > a").removeClass("thisLink");
		$(thisOne + " > a").addClass("thisLink");
		//Display
		thisMenu = "#"+$(this).attr("id")+" .subMenu";
		
		$(thisMenu).slideDown(200, function() { 
			$(thisOne + " > a").addClass("thisLink"); 
		});
		
		
	}
	function out(evt) { 
		//Hide
		thisMenu = "#"+$(this).attr("id")+" .subMenu";
		$(thisMenu).slideUp(200);
		
		var thisOne = "#"+$(this).attr("id");
		$(thisOne + " > a").removeClass("thisLink");
	}

});

//ANALYTICS
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-24247823-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
