﻿
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="剩余<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);
			switch (this._id){
			    case "time535":
			        GetHtmlStr(535);
			        break;
			    case "time536":
			        GetHtmlStr(536);
			        break;
			    case "time537":
			        GetHtmlStr(537);
			        break;
			    case "time538":
			        GetHtmlStr(538);
			        break;
			}

		}
	}
	this._interval=function(){
		var o=this;
		this._interval=setInterval(function(){o._gT()},1000)
	}
}


function GetHtmlStr(id){
    $.ajax({
      type: "get",
      url: "limitBuy.aspx",
      data: "id="+id+"&fresh=" + Math.random(),
      cache:false, 
      success: function(result){
            $("#loading"+id).hide();
            if(result=="")
            {	        
                $("#hasQiangGou"+id).fadeOut("slow",function(){
                    $("#paihang"+id).fadeIn();
                });
            }
            else
            {
                $("#hasQiangGou"+id).show();
                //$("#paihang"+id).hide();
                eval(result.split('|')[0]);
                $("#qianggou"+id).html(result.split('|')[1]);
            }
      }
    });
}

GetHtmlStr(536);  //异步调用主方法
GetHtmlStr(538);  //异步调用主方法
GetHtmlStr(535);  //异步调用主方法
GetHtmlStr(537);  //异步调用主方法



