﻿function calculagraph(){
	this._id=null;
	//this._sT=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._sT=parseInt(this._sT.match(/\s(\d+)\D/)[1]*3600)+parseInt(this._sT.split(":")[1]*60)+parseInt(this._sT.split(":")[2]);
			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= _H +"小时"+ _M +"分"+ _S +"秒";
			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=DeleteBuyLimitByProductID&ProductID=" + id + "&fresh=" + Math.random(),
      cache:false, 
      success: function(result){}
    });
}


