jQuery(function($){
	window.onerror=function(){
		return true
	};
	$("#tgkefu").floatdiv({
		right:"0px",top:"410px"
	});	
	var navcurrent=$("#nav li.current");
	navcurrent.prev("#nav ul.nav-list li.j").addClass("e");
	navcurrent.next("#nav ul.nav-list li.j").addClass("e");
	if($(".scroll-news li").length>1){
		$(".scroll-news div").jCarouselLite({
			auto:2000,speed:500,vertical:true,visible:1,over:true
		})
	};

	$("#leftkefu").hide();
	$("#tgkefu").hover(function(){
		$("#leftkefu").show();
		$(this).children('.Obtn').hide()
	}
	,function(){
		$("#leftkefu").hide();
		$(this).children('.Obtn').show()
	});
	$("#searchinfo").click(function(){$(this).val();});
	$(".site-cates li.i").click(function(){
		$(".site-cates li").removeClass("current");
		$(this).addClass("current");
		if(this.getAttribute("rel")!=""){
			$(".site-list").hide();
			if(this.getAttribute("rel")=="index")$(".site-list[isIndex='true']").show();
			else $(".site-list[rel='"+this.getAttribute("rel")+"']").show()
		}
	});
	$("#CompanyList a").click(function(){
		var ListName=$(this).attr("lang");
		$("#CompanyList a").removeClass("oncurr");
		$(this).addClass("oncurr");
		$(".tjlist").hide();
		$("#"+ListName).show()
	});
	$("#head.toggle").click(function(){
		if($("#city-list").css("display")=="none"){
			$("#city-list").bgiframe();
			$("#city-list").show();
			$("body").one("click",function(){
				$("#city-list").hide()
			})
		}
		else $("#city-list").hide();
		return false
	});
	if($(".settime").length>0)updateEndTime()
});
function updateEndTime(){
	var date=new Date();
	var time=date.getTime();
	$(".settime").each(function(i){
		var endDate=new Date(this.getAttribute("endTime"));
		var endTime=endDate.getTime();
		var lag=(endTime-time)/1000;
		if(lag>0){
			var second=Math.floor(lag%60);
			var minite=Math.floor((lag/60)%60);
			var hour=Math.floor((lag/3600)%24);
			var day=Math.floor((lag/3600)/24);
			$(this).html(day+"天"+hour+"小时"+minite+"分"+second+"秒")
		}
		else $(this).html("团购已经结束啦！")
	});
	setTimeout("updateEndTime()",1000)
};
function goToUrl(){
	indexUrl=clearParm(indexUrl,'#ty#',ty,'ty');
	if(prices=="")indexUrl=clearParm(indexUrl,'#prices#','','prices');
	else indexUrl=clearParm(indexUrl,'#prices#',prices,'prices');
	indexUrl=clearParm(indexUrl,'#k#',k,'k');
	indexUrl=clearParm(indexUrl,'#city#',city,'city');
	indexUrl=clearParm(indexUrl,'#o#',o,'o');
	if(gc=="")indexUrl=clearParm(indexUrl,'#gc#','','gc');
	else indexUrl=clearParm(indexUrl,'#gc#',gc,'gc');
	location.href=indexUrl
};

function clearParm(url,search,replace,parm){
	if(replace==""){
		if(route>0)return url.replace(depr+parm+depr+search,"");
		else return url.replace("&"+parm+"="+search,"")
	}
	else return url.replace(search,replace)
};
jQuery.fn.floatdiv=function(location){
	var isIE6=false;
	var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 0;
	if(Sys.ie && Sys.ie=="6.0"){
		isIE6=true;
	}
	var windowWidth,windowHeight;//窗口的高和宽
	//取得窗口的高和宽
	if (self.innerHeight) {
		windowWidth=self.innerWidth;
		windowHeight=self.innerHeight;
	}else if (document.documentElement&&document.documentElement.clientHeight) {
		windowWidth=document.documentElement.clientWidth;
		windowHeight=document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth=document.body.clientWidth;
		windowHeight=document.body.clientHeight;
	}
	return this.each(function(){
		var loc;//层的绝对定位位置
		var wrap=$("<div></div>");
		var top=-1;
		if(location==undefined || location.constructor == String){
			switch(location){
				case("rightbottom")://右下角
					loc={right:"0px",bottom:"0px"};
					break;
				case("leftbottom")://左下角
					loc={left:"0px",bottom:"0px"};
					break;	
				case("lefttop")://左上角
					loc={left:"0px",top:"0px"};
					top=0;
					break;
				case("righttop")://右上角
					loc={right:"0px",top:"0px"};
					top=0;
					break;
				case("middletop")://居中置顶
					loc={left:windowWidth/2-$(this).width()/2+"px",top:"0px"};
					top=0;
					break;
				case("middlebottom")://居中置低
					loc={left:windowWidth/2-$(this).width()/2+"px",bottom:"0px"};
					break;
				case("leftmiddle")://左边居中
					loc={left:"0px",top:windowHeight/2-$(this).height()/2+"px"};
					top=windowHeight/2-$(this).height()/2;
					break;
				case("rightmiddle")://右边居中
					loc={right:"0px",top:windowHeight/2-$(this).height()/2+"px"};
					top=windowHeight/2-$(this).height()/2;
					break;
				case("middle")://居中
					var l=0;//居左
					var t=0;//居上
					l=windowWidth/2-$(this).width()/2;
					t=windowHeight/2-$(this).height()/2;
					top=t;
					loc={left:l+"px",top:t+"px"};
					break;
				default://默认为右下角
					location="rightbottom";
					loc={right:"0px",bottom:"0px"};
					break;
			}
		}else{
			loc=location;
			var str=loc.top;
			//09-11-5修改：加上top为空值时的判断
			if (typeof(str)!= 'undefined'){
				str=str.replace("px","");
				top=str;
			}
		}
		/*fied ie6 css hack*/
		if(isIE6){
			if (top>=0)
			{
				wrap=$("<div style=\"top:expression(documentElement.scrollTop+"+top+");\"></div>");
			}else{
				wrap=$("<div style=\"top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight);\"></div>");
			}
		}
		$("body").append(wrap);
		
		wrap.css(loc).css({position:"fixed",
			z_index:"999"});
		if (isIE6)
		{
			
			wrap.css("position","absolute");
			//没有加这个的话，ie6使用表达式时就会发现跳动现象
			//至于为什么要加这个，还有为什么要加nothing.txt这个，偶也不知道，希望知道的同学可以告诉我
			//$("body").css("background-attachment","fixed").css("background-image","url("+Domain_URL+"/tpl/images/bg.gif)");
		}
		//将要固定的层添加到固定层里
		$(this).appendTo(wrap);
	});
};
