var closeAll, closeAllSub;
function hideSubNavHome() {
	$(".sub_links").slideUp();
	$("#sub_brands").stop().animate({width: '0'}, 500, function() {$("#Brands > a").removeClass('active');});
}
function hideAllSubNav() {
	$('ul.nav li').removeClass('hover');
	$('#nav_sub div:not(.active)').each(function(){
		if($(this).data('open')) {
			$(this).data('open',false).stop().animate({height: 0}, 500);
		}
	});
}
$(document).ready(function() { 
	//show logo fixes jumping
	if($('#asxgraph').length>0)
	{
	$('#asxgraph').load('manager/includes/bigwig/asx/asx.php');
	
	}
	
	$("#nav_sub div").not('.active').hide();
//	if(!$.fontAvailable('Frutiger LT Std')) {
	//	Cufon.replace('.fr',{fontFamily:'Frutiger LT Std', hover:true});
	//	Cufon.replace('.fr_cn',{fontFamily:'Frutiger LT Std Cn', hover:true});
	//	Cufon.now();
//	}
	$('#nav_sub div').each(function(){
		$(this).data('sub_h',$(this).height());
	});
	$("ul.nav li:not(.active) a").hover(
		function(){
			clearTimeout(closeAllSub);
			$(this).parents('li').not('.exclude').addClass('hover');
			if( ($(this).hasClass('has_sub')) ) {
				o = '#'+this.id+'_sub';
				h = $(o).data('sub_h');
				$(o).data('open',true).stop().height(0).animate({height: h}, 500);
			}
		},
		function(){
			$(this).parents('li').removeClass('hover');
			ref = $(this);
			closeAllSub = setTimeout("hideAllSubNav()", 1000);
		}
	);
	$("#nav_sub div a").hover(
		function(){
			clearTimeout(closeAllSub);
		},
		function(){
			closeAllSub = setTimeout("hideAllSubNav()", 500);
		}
	);
	$("ul.nav_home li a").hover(
		function(){
			$(this).parents('li').addClass('hover');
		},
		function(){
			$(this).parents('li').removeClass('hover');
		}
	);
	$("#Brands").hover(
		function(){
			clearTimeout(closeAllSub);
			$("#Brands > a").addClass('active');
			$("#sub_brands").stop().animate({width: '280'}, 500, function() {$(".sub_links").slideDown();});
		},
		function(){
			closeAllSub = setTimeout("hideSubNavHome()", 1000);
		}
	);
	$(".sub_links").hover(
		function(){
			clearTimeout(closeAllSub);
		},
		function(){
			closeAllSub = setTimeout("hideSubNavHome()", 500);
		}
	);
}); 

