$(document).ready(function(){

function closeothers(current) {

	if (current != 'about') {
		$("#menu").hide();
	}
	if (current != 'products') {
		$("#menu_products").hide();
	}
	if (current != 'upgrades') {
		$("#menu_upgrades").hide();
	}
	if (current != 'fituse') {
		$("#menu_fituse").hide();
	}
	
}

var config = {    
     sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
     interval: 100, // number = milliseconds for onMouseOver polling interval    
     over: makeTall, // function = onMouseOver callback (REQUIRED)    
     timeout: 100, // number = milliseconds delay before onMouseOut    
     out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	
	var about_menu_flag = false;
	
	function makeTall(){  
		var pos = $("#link_about").offset();  
		  var width = $("#link_about").width();
		  //show the menu directly over the placeholder
		  $("#menu").css( { "left": (pos.left + width - 57) + "px", "top":(pos.top + 15) + "px" } );
		  
		  $("#menu").slideDown(50).show();
		  closeothers('about');
	  	  $('#menu').hover(function() {
	  	  		about_menu_flag = true;
		      }, function() {
		        // $(this).slideUp('fast');
		        $(this).hide();
		       	 about_menu_flag = false; 
		      });
	  }
	  
	function makeShort(){ 
			if (!about_menu_flag){
				// $("#menu").slideUp('fast');
				 $("#menu").hide();
			}
	}
	
	if ($("#link_about").length > 0){
		$("#link_about").hoverIntent(config);	
	}
	


var config_products = {    
     sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
     interval: 100, // number = milliseconds for onMouseOver polling interval    
     over: makeTallproducts, // function = onMouseOver callback (REQUIRED)    
     timeout: 100, // number = milliseconds delay before onMouseOut    
     out: makeShortproducts // function = onMouseOut callback (REQUIRED)    
	};
	
	var products_menu_flag = false;
	
	function makeTallproducts(){  
		var pos = $("#link_products").offset();  
		  var width = $("#link_products").width();
		  //show the menu directly over the placeholder
		  $("#menu_products").css( { "left": (pos.left + width - 72) + "px", "top":(pos.top + 15) + "px" } );
		    closeothers('products');
		  $("#menu_products").slideDown(50).show();
	  	  $('#menu_products').hover(function() {
	  	  		products_menu_flag = true;
		      }, function() {
		        //$(this).slideUp('fast');
		        $(this).hide();
		       	 products_menu_flag = false; 
		      });
	  }
	  
	function makeShortproducts(){ 
			if (!products_menu_flag){
				// $("#menu_products").slideUp('fast');
				$("#menu_products").hide();
			}
	}
	
	if ($("#link_products").length > 0){
		$("#link_products").hoverIntent(config_products);	
	}
	
	
var config_upgrades = {    
     sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
     interval: 100, // number = milliseconds for onMouseOver polling interval    
     over: makeTallupgrades, // function = onMouseOver callback (REQUIRED)    
     timeout: 100, // number = milliseconds delay before onMouseOut    
     out: makeShortupgrades // function = onMouseOut callback (REQUIRED)    
	};
	
	var upgrades_menu_flag = false;
	
	function makeTallupgrades(){  
		var pos = $("#link_upgrades").offset();  
		  var width = $("#link_upgrades").width();
		  //show the menu directly over the placeholder
		  $("#menu_upgrades").css( { "left": (pos.left + width - 78) + "px", "top":(pos.top + 15) + "px" } );
		    closeothers('upgrades');
		  $("#menu_upgrades").slideDown(50).show();
	  	  $('#menu_upgrades').hover(function() {
	  	  		upgrades_menu_flag = true;
		      }, function() {
		        //$(this).slideUp('fast');
		        $(this).hide();
		       
		       	 upgrades_menu_flag = false; 
		      });
	  }
	  
	function makeShortupgrades(){ 
			if (!upgrades_menu_flag){
				// $("#menu_upgrades").slideUp('fast');
				$("#menu_upgrades").hide();
			}
	}
	
	if ($("#link_upgrades").length > 0){
		$("#link_upgrades").hoverIntent(config_upgrades);	
	}
	
	
	
var config_fituse = {    
     sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
     interval: 100, // number = milliseconds for onMouseOver polling interval    
     over: makeTallfituse, // function = onMouseOver callback (REQUIRED)    
     timeout: 100, // number = milliseconds delay before onMouseOut    
     out: makeShortfituse // function = onMouseOut callback (REQUIRED)    
	};
	
	var fituse_menu_flag = false;
	
	function makeTallfituse(){  
		var pos = $("#link_fituse").offset();  
		  var width = $("#link_fituse").width();
		  //show the menu directly over the placeholder
		  $("#menu_fituse").css( { "left": (pos.left + width - 160) + "px", "top":(pos.top + 15) + "px" } );
		    closeothers('fituse');
		  $("#menu_fituse").slideDown(50).show();
	  	  $('#menu_fituse').hover(function() {
	  	  		fituse_menu_flag = true;
		      }, function() {
		          //$(this).slideUp('fast');
		          $(this).hide();
		        
		       	 fituse_menu_flag = false; 
		      });
	  }
	  
	function makeShortfituse(){ 
			if (!fituse_menu_flag){
				//$("#menu_fituse").slideUp('fast');
				$("#menu_fituse").hide();
			}
	}
	
	if ($("#link_fituse").length > 0){
		$("#link_fituse").hoverIntent(config_fituse);	
	}
	
});
