﻿function calculagraph(){
	this._id=null;
	this._cT=null;
	this._eT=null;
	this._lT=null;
	this._gT=function(){
		if (this._lT==null){
			//var _xT=(parseInt(this._eT.match(/-(\d+)\s/)[1])>=parseInt(this._cT.match(/-(\d+)\s/)[1]))?(parseInt(this._eT.match(/-(\d+)\s/)[1])-parseInt(this._cT.match(/-(\d+)\s/)[1])):0;
			this._cT=parseInt(this._cT.match(/\s(\d+)\D/)[1]*3600)+parseInt(this._cT.split(":")[1]*60)+parseInt(this._cT.split(":")[2]);
			this._eT=_xT*24*3600+parseInt(this._eT.match(/\s(\d+)\D/)[1]*3600)+parseInt(this._eT.split(":")[1]*60)+parseInt(this._eT.split(":")[2]);
			this._lT=(this._eT-this._cT);
		}
		if (this._lT>=0){
			var _H=Math.floor(this._lT/3600);
			var _M=Math.floor((this._lT-_H*3600)/60);
			var _S=(this._lT-_H*3600)%60;
			document.getElementById(this._id).innerHTML="剩余<strong>"+ _H +"</strong>小时<strong>"+ _M +"</strong>分<strong>"+ _S +"</strong>秒";
			this._lT--;
		}else{
//			document.getElementById(this._id).innerHTML="<strong style='font-size:14px;'>抢购结束</strong>";
			clearInterval(this._interval);
			GetHtmlStr(this._id.replace('time',''));
		}
	}
	this._interval=function(){
		var o=this;
		this._interval = setInterval(function(){o._gT()},1000);
		
	}
}


function GetHtmlStr(id){
	$.ajax({
		type: "get",
		url: shopFolder + "BuyLimited.aspx?NoCopyRight=1",
		data: "type=ajax&Action=DeleteBuyLimitByCategoryID&CategoryID=" + id + "&fresh=" + Math.random(),
		cache:false, 
		success: function(result)
		{
			if(result == "0")
            {	        
                $("#BuyLimited" + id).show();
                $("#advertisement").hide();
            }
            else
            {
                $("#BuyLimited" + id).hide();
                $("#advertisement").show();
            }
		}
    });
}
$(document).ready(function(){
	GetHtmlStr(1);  //异步调用主方法
});

//GetHtmlStr(1002);  //异步调用主方法
//GetHtmlStr(535);  //异步调用主方法
//GetHtmlStr(537);  //异步调用主方法



