function calculagraph(){
	this._id=null;
	this._sT=null;
	this._cT=null;
	this._eT=null;
	//this._xT=null;//剩余天数
	this._lT=null;
	this._flag=true;
	this._gT=function(){
		if (this._lT==null){
		    if(this._flag){
		        this._sT=new Date(this._sT.replace(/-/g,"/"));
		        this._cT=new Date(this._cT.replace(/-/g,"/"));
		        this._eT=new Date(this._eT.replace(/-/g,"/"));
		    }
		    if(this._sT>this._cT)
		    {
		        this._lT=this._sT-this._cT;
		    }
		    else
		    {
		        this._lT=this._eT-this._cT;
		    }
		    this._lT=this._lT/1000;
		}
		if (this._lT>=0){
		    var _H=Math.floor(this._lT/3600);
		    if(_H<10){
		        _H="0" +_H
		    }
		    var _M=Math.floor((this._lT-_H*3600)/60);
		    if(_M<10){
		        _M="0" +_M
		    }		    
		    var _S=(this._lT-_H*3600)%60;
		    if(_S<10){
		        _S="0" +_S
		    }
		    if(this._sT>this._cT)
			{
			    document.getElementById("time" + this._id).innerHTML="<span class='sp_djs01'>"+ _H +"</span><h3>:</h3><span class='sp_djs01'>"+ _M +"</span><h3>:</h3><span class='sp_djs01'>"+ _S +"</span>";
		        $("#status"+this._id).html("未开始");
			}
			else
			{
			    $("#time"+this._id).siblings("input").removeClass("wait").addClass("start");
			    $("#time"+this._id).siblings(".seckill-djs-title").html('剩余时间：');
		        $("#status"+this._id).html("进行中");
			    document.getElementById("time" + this._id).innerHTML="<span class='sp_djs01'>"+ _H +"</span><h3>:</h3><span class='sp_djs01'>"+ _M +"</span><h3>:</h3><span class='sp_djs01'>"+ _S +"</span>";
			}
			this._lT=this._lT-1;
			if(this._lT==0 && this._sT>this._cT)
			{
			    this._cT=this._sT;
			    this._lT=null;
			    this._flag=false;
			}
		}
		else
		{
		    $("#time"+this._id).siblings("input").removeClass("start").addClass("end");
		    $("#status"+this._id).html("已结束");
//			document.getElementById(this._id).innerHTML="<strong style='font-size:14px;'>秒杀结束</strong>";
			clearInterval(this._interval);
		}
	}
	this._interval=function(){
		var o = this;
		this._interval = setInterval(function(){o._gT()},1000);
	}
}
function DoSecKill(rid,pid,gid,obj1,obj2)
{
    if($("#"+obj1).hasClass("wait")){alert('秒杀还未开始，请耐心等待');return;};
    if($("#"+obj1).hasClass("end")){alert('秒杀已结束');return;};
    $.ajax({
      type: "post",
      dataType:"json",
      url: "SecKill.aspx?NoCopyRight=1",
      data: "type=ajax&action=doseckill&rid=" + rid + "&pid="+pid+"&gid="+gid+"&fresh=" + Math.random(),
      cache:false, 
      success: function(data){
        var errorflag=data["errorflag"];
        var errormsg=data["errormsg"];
        switch(errorflag)
        {
            case "0":
                alert("恭喜您，秒杀成功，请尽快到会员中心生成订单并支付！");
                break;
            case "1":
                if(confirm('请先登录再秒杀,是否现在就登录?')){
                    window.location.href= 'login.aspx?ReturnUrl='+window.location.href;
                };
                break;
            case "2":
                alert(errormsg);//秒杀还未开始，请耐心等待
                break;
            case "3":
                alert(errormsg);//秒杀已结束，请等待下一期
                $("#"+obj2).siblings("input").removeClass("start").addClass("end");
                break;
            case "4":
                alert(errormsg);//对不起，您已超出限制数量
                break;
            case "5":
                alert(errormsg);//对不起，已秒完
                $("#"+obj2).siblings("input").removeClass("start").addClass("end");
                break;
            default:
                alert(errormsg);
                break;
        }
      }
    });
}



