/*处理顶部菜单*/
var _cityServicePopStatus = false;
var _changeCityPopStatus = false;
var _cityMenuTimer = null;
function _hideAllMenu(){
	if(_cityMenuTimer!=null){
		window.clearTimeout(_cityMenuTimer);
	}
	_cityMenuTimer = window.setTimeout(function(){
		if((!_cityServicePopStatus) && (!_changeCityPopStatus)){
			jQuery("#changeCityPop").hide();
			jQuery("#cityServicePop").hide();
		}
	},1500);
}

jQuery(document).ready(function() {
	//首次进来，隐藏掉所有的弹窗
	jQuery("#changeCityPop").hide();
	jQuery("#cityServicePop").hide();
	var ua = navigator.userAgent.toLowerCase();

	var offset = jQuery("#changeCity").offset();
	if(ua.indexOf("msie 6") > -1 && ua.indexOf("msie 7") < 0 && ua.indexOf("msie 8") < 0 && ua.indexOf("msie 9") < 0){
		jQuery("#changeCityPop").css("top", 160);
		jQuery("#changeCityPop").css("left", offset.left - 7);
    }else{
		jQuery("#changeCityPop").css("top", 20);
		jQuery("#changeCityPop").css("left", 15);
	}
	
	offset = jQuery("#cityService").offset();
    if(ua.indexOf("msie 6") > -1 && ua.indexOf("msie 7") < 0 && ua.indexOf("msie 8") < 0 && ua.indexOf("msie 9") < 0){
		jQuery("#cityServicePop").css("top",  203);
		jQuery("#cityServicePop").css("left", offset.left);
    }else{
		jQuery("#cityServicePop").css("top", 30);
		jQuery("#cityServicePop").css("left", 3);
	}
	
	
	jQuery("#changeCity").hover(function(e){
		jQuery("#cityServicePop").hide();
		jQuery("#changeCityPop").show();
		_changeCityPopStatus = true;
	},function(){
		_changeCityPopStatus = false;_hideAllMenu();
	});

	jQuery("#cityService").hover(function(){
		jQuery("#changeCityPop").hide();
		jQuery("#cityServicePop").show();
		_cityServicePopStatus = true;
	},function(){
		_cityServicePopStatus = false;_hideAllMenu();
	});
	
	jQuery("#changeCityPop").hover(function(){
		_changeCityPopStatus = true;
	},function(){
		_changeCityPopStatus = false;_hideAllMenu();
	});
	
	jQuery("#cityServicePop").hover(function(){
		_cityServicePopStatus = true;
	},function(){
		_cityServicePopStatus = false;_hideAllMenu();
	});
	
});

jQuery(document).ready(function(){
	jQuery("#styleSelection a").click(function(){
		var skin = this.id;
		__global.setPartCookie("__fstyle",__city_name,skin,365,"/",".tianya.cn",false);
		window.location.href=window.location.href;
		return false;		
	});
});
