var mainNavTimer;
var mainNavTimerInterval = 2000;
var tempNavOver;
var tempNavOff;
var tempNavOn;
$(document).ready(function() {
	/* image flicker fix: mister-pixel */ 
	if($.browser.msie && $.browser.version == '6.0'){
		try { 
			document.execCommand("BackgroundImageCache", false, true); 
		} catch(err) {} 
	}	
	$("#menuCountries").hide(); 		
	$("#countryNav>div.country>a").click(function() {
		$(this).addClass("menuOn");						  	
		$("#menuCountries").css("top",($("#countryNav").height() * 2) - 3); 
		$("#menuCountries").css("left",($("#countryNav>div.flag").width() + $("#countryNav>div.country").width() - 30)); 
		$("#menuCountries").show(); 	
	});		
	$("#menuCountries>div.menuClose>a").click(function() {			
		$("#menuCountries").hide(); 
		$("#countryNav>div.country>a").removeClass("menuOn");		
	});					   
	$("#mainNavBox>ul>li>ul").css("top",$("#mainNavBox").height()); 
	tempNavOn = $("#mainNavBox>ul>li").filter(".navOn").html();		
	$("#mainNavBox>ul>li:not(:first)").mouseover(function() { 														  
		$("#mainNavBox>ul>li").removeClass("navOn");
		$("#mainNavBox>ul>li>ul").css("top",$("#mainNavBox").height()); 			
		clearTimeout(mainNavTimer);
		if ($(this).html() != tempNavOver){	
			$("#mainNavBox>ul>li").removeClass("navOver");		
			tempNavOver = $(this).html();					
			$(this).addClass("navOver");				
		}			
	});
	$("#mainNavBox>ul>li:not(:first)").mouseout(function() {			
		tempNavOff = $(this);						
		mainNavTimer = setTimeout("$(tempNavOff).removeClass(\"navOver\");tempNavOver=\"\"; setNavOn();",mainNavTimerInterval);	            
	});		
	$('#footer>#siteLink').wrapInner("<a href=\"javascript:;\"></a>");
	$("#footer>#footerSiteLinks").hide().end();
	$("#footer>#siteLink>a").click(function() {				
		if (this.className == "open"){
			this.className = '';
		}else{
			this.className = 'open';
		}			
		$("#footer>#footerSiteLinks").slideToggle("fast");
	});		
});  
function setNavOn(){
	for(var listloop=0; listloop < ($("#mainNavBox>ul").find('li').length);listloop++){			
		if ($("#mainNavBox>ul").find('li').eq(listloop).html() === tempNavOn){				
			$("#mainNavBox>ul").find('li').eq(listloop).addClass("navOn");	
			break;
		}			
	}		
}
