jQuery(function($){
	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");

	$("#nav ul.nav-list li.i").hover(function(){
		$("#nav ul.nav-list li").removeClass("current e");
		$(this).addClass("current");
		$(this).prev("#nav ul.nav-list li.j").addClass("e");
		$(this).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
		});
	}
	
	clockTime();
	
	$(".site-cates li.i").click(function(){
		$(".site-cates li").removeClass("current");
		$(this).addClass("current");
		if(this.getAttribute("rel") != "")
		{
			$("#site-list .item,#site-list .more").hide();
			$("#site-list .item[rel='"+this.getAttribute("rel")+"'],#site-list .more[rel='"+this.getAttribute("rel")+"']").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;
	});
	
	$(".e-item").each(function(i){
		$(this).hover(function(){
			$(this).addClass("cur");
		},function(){
			$(this).removeClass("cur");
		});
	});

	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 clockTime()
{
	var date = new Date();
	var D="";
	switch(parseInt(date.getDay()))
	{
		case 0:
		 D="天";
		 break;
		case 1:
		 D="一";
		 break;
		case 2:
		 D="二";
		 break;
		case 3:
		 D="三";
		 break;
		case 4:
		 D="四";
		 break;
		case 5:
		 D="五";
		 break;
		case 6:
		 D="六";
		 break;
	}
	
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	if(month < 10)
		month = "0"+ month;
		
	var date1 = date.getDate();
	if(date1 < 10)
		date1 = "0"+ date1;
		
	var hours = date.getHours();
	if(hours < 10)
		hours = "0"+ hours;
		
	var minutes = date.getMinutes();
	if(minutes < 10)
		minutes = "0"+ minutes;
		
	var seconds = date.getSeconds();
	if(seconds < 10)
		seconds = "0"+ seconds;
	
	var str=year+"年"+month+"月"+date1+"日 "+"星期"+D+" "+hours+":"+minutes+":"+seconds;
	
	$("#clock_box").html(str);
	
	setTimeout("clockTime()",1000);
}

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(5($){$.J.L=5(r){8 1={d:0,A:0,b:"h",v:"N",3:4};6(r){$.D(1,r)}8 m=9;6("h"==1.b){$(1.3).p("h",5(b){8 C=0;m.t(5(){6(!$.k(9,1)&&!$.l(9,1)){$(9).z("o")}j{6(C++>1.A){g B}}});8 w=$.M(m,5(f){g!f.e});m=$(w)})}g 9.t(5(){8 2=9;$(2).c("s",$(2).c("i"));6("h"!=1.b||$.k(2,1)||$.l(2,1)){6(1.u){$(2).c("i",1.u)}j{$(2).K("i")}2.e=B}j{2.e=x}$(2).T("o",5(){6(!9.e){$("<V />").p("X",5(){$(2).Y().c("i",$(2).c("s"))[1.v](1.Z);2.e=x}).c("i",$(2).c("s"))}});6("h"!=1.b){$(2).p(1.b,5(b){6(!2.e){$(2).z("o")}})}})};$.k=5(f,1){6(1.3===E||1.3===4){8 7=$(4).F()+$(4).O()}j{8 7=$(1.3).n().G+$(1.3).F()}g 7<=$(f).n().G-1.d};$.l=5(f,1){6(1.3===E||1.3===4){8 7=$(4).I()+$(4).U()}j{8 7=$(1.3).n().q+$(1.3).I()}g 7<=$(f).n().q-1.d};$.D($.P[\':\'],{"Q-H-7":"$.k(a, {d : 0, 3: 4})","R-H-7":"!$.k(a, {d : 0, 3: 4})","S-y-7":"$.l(a, {d : 0, 3: 4})","q-y-7":"!$.l(a, {d : 0, 3: 4})"})})(W);',62,62,'|settings|self|container|window|function|if|fold|var|this||event|attr|threshold|loaded|element|return|scroll|src|else|belowthefold|rightoffold|elements|offset|appear|bind|left|options|original|each|placeholder|effect|temp|true|of|trigger|failurelimit|false|counter|extend|undefined|height|top|the|width|fn|removeAttr|lazyload|grep|show|scrollTop|expr|below|above|right|one|scrollLeft|img|jQuery|load|hide|effectspeed'.split('|'),0,{}))

jQuery(document).ready(
function($){
$("img").lazyload({
     placeholder : "http://51tg.de/grey.gif", //加载图片前的占位图片
     effect      : "fadeIn" //加载图片使用的效果(淡入)
});
});
