/*+++++++++++++++++++++++++++++++++++++
+ 功能:竞拍倒计时的单体对象
+ 研发:宗帝
+ 时间:2010-12-20
+++++++++++++++++++++++++++++++++++++*/
function PaiPaiBidItem(_GameType,_Vid,_PaiPai)
{
	this.IsUseMicroSecond = 0,//0表示不启用小秒
	this.GameType = (_GameType?_GameType:0),//游戏类型
	this.PaiPaiBid = _PaiPai;//竞拍核心对象
	this.id=_Vid,
	this.RobotUser = _PaiPai.GetRobotUser(this.id),	//机器人对象
	this.VendueState = 0,
	this.Price=0,
	this.UserId= this.PaiPaiBid.UserId,
	this.VendueUserId =0,//当前竞拍信息对应的会员编号
	this.UserNickName = '',
	this.UserHeadImage ='',
	this.EndStopTimeSecond=0,
	this.EndStopTimeSecondOld = 0,
	this.EndStopTimeString ='',
	this.Mill = 0,//毫秒值
	this.MillStrFormat=[
		'<font style="color:#888;font-size:12px;valign:bottom;display:inline-block;width:10px;line-height:16px;"></font>'
		,'<font style="color:#888;font-size:12px;valign:bottom;display:inline-block;width:10px;line-height:16px;">','</font>'],
	this.InputPrice = 0,	
	this.IsHot = 1;//模式值。 
		
	//赋值.
	//jQuery对象
	this.oPrice=null,
	this.oUserInfo= null,
	this.oTimer=null,
	this.oBtn = null,
	this.oSpanTip = null,
	this.oInputPrice_ = null,
	this.oInputIsHot = null;//模式值。 
	this.CheckObject = function(){
		var _this = this;
		if(this.oPrice==null){this.oPrice = jQuery("#Price_"+this.id);}
		if(this.oUserInfo==null){this.oUserInfo = jQuery("#UserInfo_"+this.id);}
		if(this.oTimer==null){this.oTimer = jQuery("#timer_"+this.id);}
		if(this.oBtn==null){this.oBtn = jQuery("#btn_"+this.id);}	
		if(this.oInputPrice_==null){this.oInputPrice_ = jQuery("#InputPrice_"+this.id);}	//手工输入价格
		if(this.oSpanTip==null){this.oBtn = jQuery("#spanTip_"+this.id);}	
		if(this.oInputIsHot==null){this.oInputIsHot = jQuery("#InputIsHot_"+this.id);}	
		
		
		
		var _v = parseInt( this.oInputIsHot.val());
		if(isNaN(_v))	this.IsHot =1;
		else this.IsHot = _v;

		
	},
	this.Fill = function(){
		var _this = this;
		//this.CheckObject();	
		//赋值
		this.oPrice.html("￥"+this.Price);
		this.oUserInfo.html(this.UserNickName);
		if(this.GameType==1)
		{
			if(this.VendueState<3){
				this.EndStopTimeString = _this.PaiPaiBid.FormatTime_3(_this);
				if(this.EndStopTimeSecond>30){
					this.oTimer.html('<font color="green">'+ this.EndStopTimeString +  this.MillStrFormat[0] + '</font>');////this.EndStopTimeSecondOld
				}
				else if(this.EndStopTimeSecond>0){
					this.oTimer.html('<font color="red">'+ this.EndStopTimeString +  this.MillStrFormat[1]+this.MillStrFormat[2] +'</font>');////this.EndStopTimeSecondOld
				}
				else{
					this.oTimer.html('<font color="red">'+ this.EndStopTimeString +  this.MillStrFormat[0] +'</font>');////this.EndStopTimeSecondOld
				}			
				
				//分身
				//window.status = "Vid=" + this.VendueUserId + "/Uid="+this.UserId + "/状态:" + this.RobotUser.GetState();  
				//出价条件.
				
				if( this.UserId>0 && this.VendueUserId!=this.UserId )//&& this.EndStopTimeSecond<=1)
				{
					//this.PaiPaiBid.RobotUserBid(_this.id,_this.Price,_this.EndStopTimeSecond);
					_this.RobotUser.Running(_this.Price,_this.EndStopTimeSecond);
				}
			}
			else {
				this.oTimer.html("已成交");this.oBtn.html("");
				_this.PaiPaiBid.Remove(this.id);
				_this=null;
			}
		}
		else if(this.GameType==2)
		{
			if(this.VendueState<3){
				this.EndStopTimeString = _this.PaiPaiBid.FormatTime_3(_this,this.id);
				if(this.EndStopTimeSecond>30){
					this.oTimer.html('<font color="green">'+ this.EndStopTimeString +  this.MillStrFormat[0] + '</font>');////this.EndStopTimeSecondOld
				}
				else if(this.EndStopTimeSecond>0){
					this.oTimer.html('<font color="red">'+ this.EndStopTimeString +  this.MillStrFormat[1]+this.MillStrFormat[2] +'</font>');////this.EndStopTimeSecondOld
				}
				else{
					this.oTimer.html('<font color="red">'+ this.EndStopTimeString +  this.MillStrFormat[0] +'</font>');////this.EndStopTimeSecondOld
				}	

				if( this.UserId>0 && this.VendueUserId!=this.UserId ){_this.RobotUser.Running(_this.Price,_this.EndStopTimeSecond);}				
						
			}
			else {
				this.oTimer.html("秒杀已成交");
				_this.PaiPaiBid.Remove(this.id);
				_this=null;
			}		
		}

	},
	this.FillEndStopTime = function(){
		var _this = this;
		if(_this.EndStopTimeSecond<10 && _this.EndStopTimeSecond>0)
		{
			var s = '<font color="red">'+ this.EndStopTimeString 
				+ this.MillStrFormat[1] + this.Mill 
				+ this.MillStrFormat[2] +'</font>';
			this.oTimer.html(s); 
			this.Mill--;
			if(this.Mill<0) this.Mill=0;
		}
	},		
	this.Input=function(d){
		//id,timelength,price,state,saveprice,stoptime,nick,uiddec,headimage,servertime
		var _this = this;
		try
		{
			this.CheckObject();	
			this.Price = d[2];
			this.VendueState = d[3];
			this.VendueUserId = d[7];//竞拍信息对应的会员编号
			this.UserNickName=d[6];
			this.UserHeadImage=d[8];
			this.EndStopTimeSecond = d[1];
			if(!this.RobotUser)
			this.RobotUser = this.PaiPaiBid.GetRobotUser(this.id);	
			if(this.oInputPrice)
				this.InputPrice = this.oInputPrice.val();
		}
		catch(e)
		{
		//	alert(e.meseage);
		}
		
	}
}

/*+++++++++++++++++++++++++++++++++++++
+ 功能:核心托管类
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function PaiPaiBid (){
	this.GameType = 1,//游戏类型
	this.PointType = 2,//使用点的类型(1,2,3)
	this.SeMilli = 10,
	this.MinMilli = this.SeMilli * 60 ; //每分钟多少毫秒
	this.HrMilli = this.MinMilli * 60;//每小时多少毫秒
	this.DayMilli = this.HrMilli * 24 ;//	
	
	//内部变量(public)
	
	this.UserId =0,//当前会员编号
	this.Url = ["/thread.aspx","/thread.aspx","/thread_Second.aspx"],//tid=1251,1,7,6,9,1253,19,15,14,13,12,11
	this.VendueList="", //所有时间项
	this.VendueList2="",//最后30秒项
	this.VendueList3="",//最后10秒项(1/10显示项)
	this.DivList = [],//0:时间,1:会员链接,2:会员ID,3,竞拍价,4:按钮
	this.RobotUserList = [],//分身对象列表
	this.timer = null ,
	this.timerTmp = null,
	this.ArrTimer=[],
	this.AjaxDataAll = null,//总数据
	this.AjaxData_1 = [],	//各自的本秒次数据
	this.AjaxData_2 = [],	//各自的本秒次增量数据
	//this.CurrentDate = new Date().getHour(),
	this._Hour = new Date().getHours(),
	this.index =0,
	this.IsShowHistory=0,//0不显示,1显示[详细页]	
	this.IsShowUserInfo=0,//0不显示,1显示[详细页]
	this.timer_Detail=new Array(2);//0:历史,1当前会员
	this.RedirectUrl = "/index.aspx?s=/Auction/detail/tid/";
	this.IsRedirect = false;
	//获取数据,并调用填充
	this.GetData = function(){
		this.timerTmp = new Array(this.VendueList.length);
		var _this = this;_Hour = new Date().getHours();
		//检查时间,60s,30s
		//alert(this.DivList["Bid_1"]);
		//if( _Hour>=0 && _Hour<9){this.timer = setTimeout(function(){_this.GetData()},60000);}
		//else if(this.VendueList.length<1){this.timer = setTimeout(function(){_this.GetData()},30000);}
		//else
		{

		_this.Ajax("GET",this.Url[this.GameType],{"tid":_this.VendueList,"PointType":_this.PointType,"tt":new Date().getTime()}
			,function(dt){
				
						
				if(dt!=null && dt.length>0){
					try
					{
						
						_this.AjaxData_1[0] = dt = eval(dt);
						//alert(dt);
						//if(1==0)
						for(var i =0;i<dt.length;i++)
						{
							var d=(dt[i]);
							var id=d[0].toString();//id值
							var o = _this.DivList["Bid_"+id];
							o.Input(d);
							o.Fill();
							o.Mill=9;
						}
					}
					catch(e)
					{
						//alert(e.message);
					}
					
				}
				//	alert(_this.VendueList.length + "/GameType="+_this.GameType) ;
				
				
				if( _this.VendueList.length>0 )	_this.timer = setTimeout(function(){_this.GetData()},800);
				
			},function(){/*error*/},"json");
		}	
	},//格式化填充
	this.Fill = function(){
		var _this = this;
		var _t ;
		//倒计时,
			var dt = _this.AjaxData_1[0];
			if(dt)
			{
				try{
					//alert(dt);
					//if(1==0)
					for(var i =0;i<dt.length;i++)
					{
						var d=(dt[i]);
						var id=d[0].toString();//id值
						var o = _this.DivList["Bid_"+id];
						if(o)
						o.FillEndStopTime();
						//o.Mill --;
					}
				}catch(se){
				}
			}
			//if(_this.IsUseMicroSecond==1){
			_this.ArrTimer[0] = setTimeout(function(){_this.Fill();},100);//启动1/10计时器
			//}
			
	}
	//添加倒计时项
	,this.Add = function(id)//,arr)
	{
		
		var _this = this;
		//0:时间,1:会员链接,2:会员头像和链接,3,竞拍价,4:按钮,5:tip显示框,
		var arr=["timer_"+id,"UserInfo_"+id,"UserHeadImage_"+id,"Price_"+id,"btn_"+id,"spanTip_"+id];
		//this.DivList["Bid_"+id]= arr;//9:44 2010-12-20加入bid
		//说明有值
		
		if(this.VendueList.length>0)this.VendueList +=","+ id;
		else this.VendueList = id.toString();
		this.DivList["Bid_"+id]= new PaiPaiBidItem(_this.GameType,id,_this);
		this.RobotUserList["Bid_"+id] = new RobotUser(_this.GameType,id,_this)
			
		//alert(this.DivList["Bid_"+id].id);
		//alert(this.RobotUserList["Bid_"+id].VendueId);
	}
	//移除:成交项将移出.
	,this.Remove = function(id){

		var _this = this;var arr = _this.VendueList.toString().split(",");var list = "";
		for(var n=0;n<arr.length;n++){
			if(arr[n]==id){	_this.DivList["Bid_"+id] = null; _this.ArrTimer[id] = null;}
			else{list +=arr[n]+",";}
		}
		if(list.length>0 && list.substr(list.length-1,1)==",") _this.VendueList = list.substr(0,list.length-1);
		else _this.VendueList = list;
	}
	//设置闪动
	,this.SetActiveBackGroundColor = function(o,ActiveColor,DefaultColor){
		var x = o.css("background-color");
		o.css("background-color",ActiveColor);
		o.fadeTo("1",0.4,function(){o.css("background-color",x);//.css("color","red");
		if(jQuery.browser.msie) o.css("filter","");else o.fadeTo("100",1);});
	}
	//设置时间双位
	,this.Ft = function (d) {
		d = parseInt(d,10);
		if(d<10){d="0"+d} return d;
	}
	//开始托管程序
	,this.Start = function () {
		var _this = this; 
		this.GetData();
		_this.ArrTimer[0] = setTimeout(function(){_this.Fill();},1000);//启动1/10计时器
		//window.status =_this.ArrTimer[0];
	}
	//停止托管程序
	,this.Stop = function () {  clearInterval(this.timer);clearInterval(this.ArrTimer[0]);}	
	,this.GetRobotUser = function(Vid){
		return this.RobotUserList["Bid_"+Vid];
	}
	//,this.StartRobotUser = function(Vid,_Type,_Count,_Price){
	//_StartType,_StartPrice,_StartTime,_StartCount
	//	,_TacticType ,_StopType,_StopPrice,_StopPriceStep,_StopTime
		//this.RobotUserList["Bid_"+Vid].Start(_Type,_Count,_Price);
	,this.StartRobotUser = function(Vid,_StartType,_StartPrice,_StartTime,_StartCount
		,_TacticType ,_StopType,_StopPrice,_StopPriceStep,_StopTime)
	{
		this.RobotUserList["Bid_"+Vid].Start(_StartType,_StartPrice,_StartTime,_StartCount
			,_TacticType ,_StopType,_StopPrice,_StopPriceStep,_StopTime);
	
		
		//alert(this.RobotUserList["Bid_"+Vid].State);
	}
	,this.StopRobotUser = function(Vid){
		this.RobotUserList["Bid_"+Vid].Stop();
	}	
	,this.RobotUserBid = function(Vid,_Price,_EndStopTimeSecond){
		this.RobotUserList["Bid_"+Vid].Bid(_Price);
	}	
	,this.IsIp = function(ip){var re = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/;  return re.test(ip);}
	,this.IsPhone = function(phone){var re = /^1[0-9]\d{9}$/; return re.test(phone);}
	,//测试调用
	this.test = function(){
		var _this = this;var v = "2010-12-01 12:50:50";
		if(this.DivList.length>0){var o = jQuery("#" + this.DivList["Bid_"+"16"]);this.SetActiveBackGroundColor(o,"#dd0000","#ffffff");o.html(this.FormatTime(v))}
		this.timer = setTimeout(function(){_this.test()},1000);
	}
};


//绑定数据内容:
//倒计时,竞拍人(ID,头像,昵称),竞拍价,竞拍状态
//s	/INDEX/index
//t	1291130482845
//tid	1251,1,7,6,9,1253,19,15,14,13,12,11
//http://127.0.0.1:8002/thread.aspx?s=/INDEX/index&tid=1251%2C1%2C7%2C6%2C9%2C1253%2C19%2C15%2C14%2C13%2C12%2C11&t=1291130465977

/*+++++++++++++++++++++++++++++++++++++
+ 功能:通用 Ajax 提交
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
PaiPaiBid.prototype.Ajax=function(_Type,_Url,_data,_success,_error)
{
	jQuery.ajax({"type": (_Type?_Type:"POST"),"url": (_Url?_Url:""),"data": (_data?_data:"")
		,success: (_success?_success:null),error: (_error?_error:null)});
}
/*+++++++++++++++++++++++++++++++++++++
+ 功能:时间格式化,并调用闪动
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
PaiPaiBid.prototype.FormatTime=function(v,servertime,VendueId,oThis)
{	
	
		var _this = this;
		return _this.FormatTime_2(v,servertime,VendueId,oThis);
		
		//var v = "2010-11-29 13:24:00";
		var arr = v.split(/[-|\x20|:]/);
		var d = new Date(parseInt(arr[0],10),parseInt(arr[1],10)-1,parseInt(arr[2],10),	parseInt(arr[3],10),parseInt(arr[4],10),parseInt(arr[5],10));

		arr = servertime.split(/[-|\x20|:]/);
		var t = new Date();//parseInt(arr[0],10),parseInt(arr[1],10)-1,parseInt(arr[2],10),	parseInt(arr[3],10),parseInt(arr[4],10),parseInt(arr[5],10));
		var dt = d.getTime();
		var tt = t.getTime();//毫秒数//1秒=1000毫秒
		var x = dt-tt;
		if(x<0) x=0; x = parseInt(x/100,10);
		var SeMilli = 10;
		var MinMilli = SeMilli * 60 ; //每分钟多少毫秒
		var HrMilli = MinMilli * 60;//每小时多少毫秒
		var DayMilli = HrMilli * 24 ;//
		//x = x % DayMilli;
		var h = parseInt( x / HrMilli,10);
		var m = parseInt((x % HrMilli)/MinMilli,10);
		var s =  parseInt((x % MinMilli)/SeMilli,10);
		var ms =x % SeMilli;
		var str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s);//+" "+ Ft(ms);
		if(x<1) x=0;
		//处理
		
		if(VendueId && _this.DivList["Bid_"+VendueId]!=null && _this.DivList["Bid_"+VendueId].length>0){
			var o = jQuery("#" + _this.DivList["Bid_"+VendueId][0]);
			var LastTimeLong = o.attr("LastTimeLong");
			if(LastTimeLong<x){
				_this.SetActiveBackGroundColor(jQuery("#" + _this.DivList["Bid_"+VendueId][3]),"#ff0000","");
				}
			o.attr("LastTimeLong",x);
		}

		if(x>300){//30s
			str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s);
			return ('<font color="green">'+ str +'</font>');
		}else if(x>100){//100
			str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s) ;
			return ('<font color="red">'+ str +'</font>');
		}
		else if(x>0){
			str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s) //+ " " + ms;
				+ ' <font style="background-color:#666;color:yellow;font-size:14px;valign:bottom;padding:3px 3px 2px 3px">'+ ms+'</font>';
			return ('<font color="red">'+ str +'</font>');
			//return str;
		}
		else{
			return ('<font color="red">即将成交!</font>');
		}

}
PaiPaiBid.prototype.FormatTime_2=function(v,servertime,VendueId,oThis)
{
		var _this = this;
		//秒数
		var x = parseInt(v,10)*1;
		//x = parseInt(x/100,10);
		//alert(x);
		var SeMilli = 1;//每秒多少毫秒
		var MinMilli = SeMilli * 60 ; //每分钟多少毫秒
		var HrMilli = MinMilli * 60;//每小时多少毫秒
		var DayMilli = HrMilli * 24 ;//
		//x = x % DayMilli;
		var h = parseInt( x / HrMilli,10);
		var m = parseInt((x % HrMilli)/MinMilli,10);
		var s =  parseInt((x % MinMilli)/SeMilli,10);
		var ms =x % SeMilli;
		var str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s);//+" "+ Ft(ms);
		if(x<1) x=0;
		//处理
		
		if(VendueId && _this.DivList["Bid_"+VendueId]!=null && _this.DivList["Bid_"+VendueId].length>0){
			var o = jQuery("#" + _this.DivList["Bid_"+VendueId][0]);
			var LastTimeLong = o.attr("LastTimeLong");
			if(LastTimeLong<x){
				_this.SetActiveBackGroundColor(jQuery("#" + _this.DivList["Bid_"+VendueId][3]),"#ff0000","");
				}
			o.attr("LastTimeLong",x);
		}
		
		if(x>300){//30s
			str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s);
			return ('<font color="green">'+ str +'</font>');
		}else if(x>100){//100
			str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s) ;
			return ('<font color="red">'+ str +'</font>');
		}
		else if(x>0){
			str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s) //+ " " + ms;
				+ ' <font style="background-color:#666;color:yellow;font-size:14px;valign:bottom;padding:3px 3px 2px 3px">'+ ms+'</font>';
			return ('<font color="red">'+ str +'</font>');
			//return str;
		}
		else{
			return ('<font color="red">即将成交...</font>');
		}		
}


PaiPaiBid.prototype.FormatTime_3=function(oItemThis,id)
{
	if(!id)id=0;
		var _this = this;
		//秒数
		var x = parseInt(oItemThis.EndStopTimeSecond,10) * 1 ;
		
		//if(oItemThis.id==9876)	window.status = oItemThis.EndStopTimeSecond;
		
		var SeMilli = 1;//每秒多少毫秒
		var MinMilli = SeMilli * 60 ; //每分钟多少毫秒
		var HrMilli = MinMilli * 60;//每小时多少毫秒
		var DayMilli = HrMilli * 24 ;//
		//x = x % DayMilli;
		var h = parseInt( x / HrMilli,10);
		var m = parseInt((x % HrMilli)/MinMilli,10);
		var s = parseInt((x % MinMilli)/SeMilli,10);		
		
		
		var str = _this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s) 
		var _x = 0;	
		_x = x;	
			
		if(x<1) x=0;
		//处理
		if(oItemThis.EndStopTimeSecondOld < x){_this.SetActiveBackGroundColor(oItemThis.oPrice,"#ff0000","");}
		oItemThis.EndStopTimeSecondOld = x;
		
		//window.status = x;
		if(x>0) 
		{
			
			return (_this.Ft(h)+":"+_this.Ft(m)+":"+_this.Ft(s));// + "|"+x;
		}
		else
		{	
			if(oItemThis.GameType==1)
			{
				if(_x>-30) return "即将成交";
				else{
				//	if(id>0)
					//oItemThis.PaiPaiBid.Remove(oItemThis.id);
					 return '<span style="font-size:12px;font-weight:bold;width:100px;">竞拍结束。</span>';//超过30秒者，将按结束处理
				}
			}
		 	
		 	else if(oItemThis.GameType==2)
		 		return "开始秒杀";
		 	else if(oItemThis.GameType==3)
		 		return "开始彩票";
		 	else if(oItemThis.GameType==4)
		 		return "开始投注";
		}
	
}

/*+++++++++++++++++++++++++++++++++++++
+ 功能:IP显示格式化
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
PaiPaiBid.prototype.FormatIp=function(strIP)
{
	if(this.IsIp(strIP)){
		var len = strIP.lastIndexOf(".");
		return strIP.substr(0,len+1) +"*";
	}
	else return strIP;
}

/*+++++++++++++++++++++++++++++++++++++
+ 功能:手机号显示格式化
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
PaiPaiBid.prototype.FormatPhone=function(strPhone)
{
	if(this.IsPhone(strPhone)){
		
		return strPhone.substr(0,3) +"****" + strPhone.substr(7,4);
	}
	else return strPhone;
}


/*+++++++++++++++++++++++++++++++++++++
+ 功能:点击触发时的处理时,显示提示信息,并在5秒后消失.
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
PaiPaiBid.prototype.ShowBidTip = function(id,content,FontColor,Second){
	var _this = this;
	if(!Second)Second=1500;
	var o ;
	//o = jQuery("#spanTip_"+id);
	PaiPaiCMS.DialogBox.ShowSimpleTip(content+"","bold",FontColor,15,"center",200,o);
	//_this.timerTmp[id] = setTimeout(function(){PaiPaiCMS.DialogBox.CloseSimpleTip(o);clearInterval(_this.timerTmp[id]);},Second);
}

/*+++++++++++++++++++++++++++++++++++++
+ 功能:点击触发时的处理
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/

PaiPaiBid.prototype.Bid = function(id,IsRobotUserRunning)
{
	var _ajaxtimeout = 1000;
	var _this = this;
	
	var _CurrentItem = _this.DivList["Bid_"+id];
	if(_CurrentItem==null)
	{
		return ;
	}
	
	if(GetIsLogin()!=1)
	{
		AjaxLoginBox();return ;
	}	
	
//	alert(_CurrentItem.IsHot);
//	return;
	if(_CurrentItem.IsHot==2)//|| _CurrentItem.IsHot==4)
	{
		if(location.href.toLowerCase().indexOf("detail/tid")<0)
		{
			document.location.href=_this.RedirectUrl + id + "&GameType="+ this.GameType;
			return false;
		}
	}
	//if(_this.IsRedirect==true){	document.location.href=_this.RedirectUrl + id;return false;}
	
	if(!IsRobotUserRunning) IsRobotUserRunning = 0;
	//alert("Bid="+IsRobotUsrRunning);
	if(IsRobotUserRunning==0)
	{
		_this.StopRobotUser(id);
	}

	//alert("bid"+this);
	////加入判断如果完成了则不提示信息
	if(_this.GameType==1)
	{
		if(jQuery("#time_"+id).text()=='--:--:--'){
			showBidTip(id,'出价信息到达服务器时竞拍已经结束，下次请提早出价！');
			return false;
		}
	}	
	
	
	var _InputPriceValue = 0;
	
	
	if(_CurrentItem.IsHot==2|| _CurrentItem.IsHot==4)
	{
		if(location.href.toLowerCase().indexOf("detail/tid")<0)
		{
	

		}
		else
		{
			if(jQuery("#InputPrice_"+id)!=null){	_InputPriceValue = Common.ParseFloat ( jQuery("#InputPrice_"+id).val());}

			if(_InputPriceValue<0.01)
			{
				alert("请填写您的出价。")
				return 0;
			}		
		}
	}
	else
	{
	_InputPriceValue=0;
	}	




	var _url = "/ThreadBid.aspx?t="+new Date().getTime();//17:46 2011-05-19 更改。
	if(_this.GameType==2)
		_url = "/ThreadBid_2.aspx?t="+new Date().getTime();
	
	jQuery.ajax({
		type: "GET",//"POST",
		timeout: _ajaxtimeout,
		//url: "/index.aspx?s=/Bid/dobid&t="+new Date().getTime(),
		url:_url,
		data: {"tid":id,"GameType":_this.GameType,"RobotUser":IsRobotUserRunning,"PointType":_this.PointType,"InputPrice":_InputPriceValue},
		success: function(msg){
			if(_this.GameType==1)
				_this.BidSuccess(id,msg);
			else if(_this.GameType==2)
				_this.BidSuccessForSecondGame(id,msg);
		},
		error:function(msg){
		//	ShowErrorMsg(msg);
		}
		

	});
}

PaiPaiBid.prototype.BidSuccess = function(id,msg){
			var _this = this;
			//window.status = msg;
			////1正常,0操作失败,2没登陆,3值不够,4已出过价,5游戏已结束,6封盘 #ff0000  #339900
			if(msg==1){//ShowBidTip(id,'<span style="color:#ff0000">您出价成功</span>',"#339900");
				_this.ShowBidTip(id,'您出价成功',"#339900");
				Fast_GetUserInfo();
			}else if(msg==0){
				//_this.ShowBidTip(id,'您出价失败，请重试');
			}else if(msg==2){
				AjaxLoginBox();
				//_this.ShowBidTip(id,'请先登录',"#339900");
			}else if(msg==3){
				_this.ShowBidTip(id,'您的余额不足，请充值!');
			}else if(msg==4){
				_this.ShowBidTip(id,'您已出价，无需重复',"#FF0000");
				//var msg = '<div class="tc"><span class="button"><span class="first-child"><button onclick="removeDialogbox(\'#userAway\');" type="button">您已出价，无需重复!</button></span></span></div>';
				//addDialogbox("#userAway","拍拍网提示",10010,300);
				//jQuery("#userAway .dialogboxContent").html(msg);
			}else if(msg==5){
				_this.ShowBidTip(id,'商品已成交',"#339900");
			}else if(msg==6){
				_this.ShowBidTip(id,'现已经到达封盘时段（00:00 - 09:00），请于开盘时再竞拍');
			}else if(msg==7){
				ShowBidTip(id,'您的资金账号已被冻结，请与我们的客服联系！',"#FF0000");
			}else if(msg==8){
				_this.ShowBidTip(id,'您的用户账号已被冻结，请与我们的客服联系！',"#FF0000");
				Fast_Logout(true);//用户冻结之后马上退出
			}else if(msg==9){
				_this.ShowBidTip(id,'已达到4周获得游戏封顶',"#FF0000");
				//delCookie('topboxopen');
				//opentopbox();//控制打开个人获得的浮动层
			}else if(msg==10){
				_this.ShowBidTip(id,'您已获得过商品，此为新人竞拍商品',"#FF0000");
			}else if(msg==11){
				_this.ShowBidTip(id,'您出价太快，请放松',"#FF0000");
			}else if(msg==12){
				_this.ShowBidTip(id,'此为新人竞拍商品，请先进行账户安全认证',"#FF0000");
			}else if(msg==13){
				_this.ShowBidTip(id,'检测点击频率太快，暂停出价30秒',"#FF0000");
			}else if(msg==14){
				_this.ShowBidTip(id,'您已设置分身进行竞拍，请取消或者等待分身出价结束后再操作！',"#FF0000");
			}else if(msg==15){
				_this.showBidTip(id,'您已达到出价次数的上限！',"#FF0000");
			}else if(msg==100){
				_this.ShowBidTip(id,'游戏类型不一致');
			}else if(msg==101){
			//	alert(msg);
				_this.ShowBidTip(id,'本拍品扣点信息未设置，欢迎您向客服反馈本情况。');	
			}else if(msg==102){
			//	alert(msg);
				var s = "0";
				if(jQuery("#PayEntrancefees_"+id)!=null){	s = Common.ParseFloat ( jQuery("#PayEntrancefees_"+id).val());}
				
				if(confirm("您还未交给入场费，不能参与拍卖。\r\n\r\n是否现在交纳入场费(入场费:"+ s +"拍点)?"))
				{
						var _ajaxtimeout = 1000;
					
						jQuery.ajax({
							type: "GET",//"POST",
							timeout: _ajaxtimeout,
							//url: "/index.aspx?s=/Auction/detail/tid/100010&IsAdd=" + msg +"&" +new Date().getTime(),
							url: "/Auction/detail.aspx?IsAdd=" + msg +"&" + new Date().getTime(),
							data: {"tid":id,"GameType":_this.GameType},
							success: function(msg){
								alert(msg);
								if(msg==1){document.location.replace(document.URL);}
								else{alert(msg);}
							}
						});
							
				}
				//_this.ShowBidTip(id,'您未交入场费，不能参与拍卖。');
			}else if(msg==103){
				_this.ShowBidTip(id,'您的出价过低了，本次出价无效。');					
			}else if(msg==201){
				_this.ShowBidTip(id,'您的出价不在出价范围，本次出价无效。');					
			}else if(msg==999){
				_this.ShowBidTip(id,'您的出价异常0，本次出价无效。');					
			}else{
				
				_this.ShowBidTip(id,'出价信息到达服务器时竞拍已经结束，下次请提早出价！',"#FF0000");
			}

}


PaiPaiBid.prototype.BidSuccessForSecondGame = function(id,msg){
	var _this = this;
	//alert(msg);
			////1正常,0操作失败,2没登陆,3值不够,4已出过价,5游戏已结束,6封盘 #ff0000  #339900
			if(msg==1){//ShowBidTip(id,'<span style="color:#ff0000">您出价成功</span>',"#339900");
				_this.ShowBidTip(id,'您秒杀成功',"#339900");
			}else if(msg==0){
				//_this.ShowBidTip(id,'您出价失败，请重试');
			}else if(msg==2){
			//	alert("请先登陆（2）");
				AjaxLoginBox();
				//_this.ShowBidTip(id,'请先登录',"#339900");
			}else if(msg==3){
				_this.ShowBidTip(id,'您的余额不足，请充值!');
			}else if(msg==4){
				_this.ShowBidTip(id,'您已秒杀，无需重复',"#FF0000");
				//var msg = '<div class="tc"><span class="button"><span class="first-child"><button onclick="removeDialogbox(\'#userAway\');" type="button">您已出价，无需重复!</button></span></span></div>';
				//addDialogbox("#userAway","拍拍网提示",10010,300);
				//jQuery("#userAway .dialogboxContent").html(msg);
			}else if(msg==5){
				_this.ShowBidTip(id,'商品已成交',"#339900");
			}else if(msg==6){
				_this.ShowBidTip(id,'现已经到达封盘时段（00:00 - 09:00），请于开盘时再竞拍');
			}else if(msg==7){
				ShowBidTip(id,'您的资金账号已被冻结，请与我们的客服联系！',"#FF0000");
			}else if(msg==8){
				_this.ShowBidTip(id,'您的用户账号已被冻结，请与我们的客服联系！',"#FF0000");
				Fast_Logout(true);//用户冻结之后马上退出
			}else if(msg==9){
				_this.ShowBidTip(id,'已达到4周获得游戏封顶',"#FF0000");
				//delCookie('topboxopen');
				//opentopbox();//控制打开个人获得的浮动层
			}else if(msg==10){
				_this.ShowBidTip(id,'您已获得过商品，此为新人竞拍商品',"#FF0000");
			}else if(msg==11){
				_this.ShowBidTip(id,'您出价太快，请放松',"#FF0000");
			}else if(msg==12){
				_this.ShowBidTip(id,'此为新人秒杀商品，请先进行账户安全认证',"#FF0000");
			}else if(msg==13){
				_this.ShowBidTip(id,'检测点击频率太快，暂停出价30秒',"#FF0000");
			}else if(msg==14){
				_this.ShowBidTip(id,'您已设置分身进行秒杀，请取消或者等待分身出价结束后再操作！',"#FF0000");
			}else if(msg==15){
				_this.showBidTip(id,'您已达到出价次数的上限！',"#FF0000");
			}else if(msg==20){
				//_this.ShowBidTip(id,'秒杀已结束,下次请提早出价！',"#FF0000");
				_this.ShowBidTip(id,'秒杀还未启动！',"#FF0000");
			}else if(msg==21){
				//_this.ShowBidTip(id,'秒杀已结束,下次请提早出价！',"#FF0000");
				_this.ShowBidTip(id,'未到秒杀时间！',"#FF0000");
			}else if(msg==100){
			//	alert(msg);
				_this.ShowBidTip(id,'游戏类型不一致');
			}else if(msg==101){
			//	alert(msg);
				_this.ShowBidTip(id,'本拍品扣点信息未设置，欢迎您向客服反馈本情况。');	
			}else if(msg==100){
			//	alert(msg);
				_this.ShowBidTip(id,'您未交入场费，不能参与拍卖。');
			}else if(msg==103){
				_this.ShowBidTip(id,'(升价秒杀)您的出价过低了，本次出价无效。');
			}else if(msg==104){
				_this.ShowBidTip(id,'(降价秒杀)您的出价过高了，本次出价无效。');
			}else if(msg==201){
				_this.ShowBidTip(id,'您的出价不在出价范围，本次出价无效。');					
			}else if(msg==999){
				_this.ShowBidTip(id,'您的出价异常0，本次出价无效。');					
			}else {
				_this.ShowBidTip(id,msg);
			}			

}

PaiPaiBid.prototype.BidHistory = function(id,VendueState,oDiv){
	var _this = this;
	if(oDiv.length<1 || oDiv.css("display")=="none"){window.setTimeout(function(){_this.BidHistory(id,VendueState,oDiv)},3000);return ;}
	if(!VendueState) VendueState = 0;
	//VendeuState = parseInt(VendeuState,10);
	if(isNaN(VendueState)) VendueState = 0;
	if(VendueState>=3){ clearInterval(this.timer_Detail[0]);return false;}
	else{		
		var _this = this;
		var _url = "/index.aspx?s=/Auction/ajaxbidhistory_json/tid/"+id;
		//alert(_url);
		_url  = "/Auction/AjaxHistoryJson.aspx";
	
	AjaxSubmit("GET",_url,{"GameType":_this.GameType,"Vid":id,"TopNum":6},function(data){
			var htmlvar;var html_body="";	
			var html_header = '<table class="AjaxContBox MGT3 WP98" >'
				+ '<tr><th >价格</th><th >IP</th><th class="l2">手机</th><th >参于价</th></tr>';	
			html_header = '<table cellspacing="0" cellpadding="0" border="0" class="AjaxContBox MGT3 WP98">'
				+ '<tr><th >排名</th><th >会员</th><th >会员手机</th></tr>';
			var html_footer='</table>';//

			data = eval("(" + data + ")");
			if(data["all"]){
				jQuery.each(data["all"], function(i,n){
				var item  = n;
				html_body+='<tr><td ><a >'+ item.nickname +'</a></td>'
		     			+ '<td >' + item.ip  + '</td>'
		     			+ '<td >' +  item.UserMobile  + '</td>'
		     			+ '</tr>';	
		     	});	
	     	}
			//oDiv.html(data); 
			oDiv.html(html_header+html_body+html_footer);//覆盖	

			 window.setTimeout(function(){_this.BidHistory(id,VendueState,oDiv)},3000);//开始
		});				
	}
}



//针对性处理
//我的出价10:23 2011/9/20改JSON为HTML
PaiPaiBid.prototype.UserInfoSelf = function(id,SafetyPrice,oDiv){
	var _this = this;
	if(oDiv.length<1 || oDiv.css("display")=="none"|| Common.getCookie('islogin')!=1 ){	window.setTimeout(function(){_this.UserInfoSelf(id,SafetyPrice,oDiv)},3000);return ;}
	var tid=id;
	var _url = "/Auction/AjaxMyCountJson.aspx?LogType=4";
	AjaxSubmit("GET",_url,{"GameType":_this.GameType,"Vid":id,"SafePrice":SafetyPrice},function(data){
			oDiv.html(data);window.setTimeout(function(){_this.UserInfoSelf(id,SafetyPrice,oDiv)},3000);//开始
		});		
}



/*
var PaiPai_Manage = new PaiPaiBid();
//m.DivList = ["txTimeDiv"];//txTime
PaiPai_Manage.Add ("16","txTimeDiv");
PaiPai_Manage.test();
*/


//
PaiPaiBid.prototype.UserBidSumLogSort = function(id,oDiv){
	

	if(oDiv.length<1 || oDiv.css("display")=="none"){window.setTimeout(function(){_this.UserBidSumLogSort(id,oDiv,TopNum)},3000);return ;}

	//var n=1;//先采用全部刷新的方式
	var _this = this;
	var tid=id;
	//var data_all=data;
	var htmlvar;
	
	var html_header = '<table cellspacing="0" cellpadding="0" border="0"  class="AjaxContBox MGT3 WP98">'
		+ '<tr><th class="l2">价格</th><th class="l2">IP</th><th class="l2">手机</th><th class="l1">参于价</th></tr>';
	
	
	var html_header = '<table cellspacing="0" cellpadding="0" border="0" class="AjaxContBox MGT3 WP98">'
		+ '<tr><th class="l2">排名</th><th class="l2">会员</th><th class="l2">出价次数</th></tr>';
	var html_footer='</table>';//

	var html_body='';
	var item_num = 0;
	var item_type = '';
	//alert(data_all["all"]);
	//更新所有记录
	//http://192.168.5.2/Auction/AjaxVendueLogCountByUser.aspx?GameType=1&VendueID=1&TopNum=11
	var _url = "/Auction/AjaxVendueLogCountByUser.aspx";
	//alert(_url);
		oDiv.html(html_header + html_footer);//先填充
		AjaxSubmit("GET",_url,{"GameType":_this.GameType,"VendueID":id,"TopNum":11},function(data){
		//	alert(data);
			jQuery.each(data, function(i,n){
				var item  = n;//if(i>11) return false; 
				html_body+='<tr>'
					+ '<td>'+ (i+1) +'</td>'
					+ '<td >'+ item.UserNickName +'</td>'
		     		+ '<td >' + item.Counts  + '</td>'
		     		+ '</tr>';
				});
			oDiv.html(html_header+html_body+html_footer);//覆盖	
			window.setTimeout(function(){_this.UserBidSumLogSort(id,oDiv)},3000);//开始
		},null,"json");
}



/*+++++++++++++++++++++++++++++++++++++
+ 功能:竞价排名（竞拍结束后）
+ 研发:宗帝
+ 时间:2010-12-23
+++++++++++++++++++++++++++++++++++++*/
PaiPaiBid.prototype.VendueLogCountByUser = function(id,TopNum,oDiv){
	//alert(SafetyPrice);
	var _this = this;
	var tid=id;
	var html_header = '<table cellspacing="0" cellpadding="0" border="0" >';
	var html_footer='</table>';//
	var html_body='';	
	//var i = 1;
	//var _url = "/index.aspx?s=/Auction/AjaxVendueLogCountByUser/";
	var _url = "/Auction/AjaxVendueLogCountByUser.ASPX";

	html_body +=''
		+ '<tr><td >排名</td>'
		+ '<td >会员</td>'
		+ '<td >参与次数</td>'
		+ '</tr>';	

		AjaxSubmit("GET",_url,{"GameType":_this.GameType,"VendueID":id,"TopNum":TopNum}
			,function(data){
			if(data!=null)
			{
				jQuery.each(data, function(i,n){
				var item  = n;
					html_body +=''
						+ '<tr><td ><a class="noreturn n_u1">No.'+ (++i) +'</a></td>'
		     			+ '<td >' + item.UserNickName + '</td>'
		     			+ '<td >' + item.Counts + '</td>'
		     			+ '</tr>';			
     			});
     		}
			oDiv.html(html_header+html_body+html_footer);		
			}
			,null,"json");
		
}

PaiPaiBid.prototype.SafeBuy = function(vid)
{
	var _this = this;
	if(vid>0)
	{
		var _url = "/Auction/detail.aspx?IsAdd=1001&tid="+vid+"&t="+ new Date().getTime();
		AjaxSubmit("GET",_url,{"GameType":_this.GameType}
			,function(data){
				//Alert(data,100);
				switch(data)
				{
					case "-5":Alert('<div class="W300">您已经有本期商品的订单了,为了节省您的资金,本次操作俺就替您取消了.如果您想查看订单的话,您到"会员中心"的"订单管理"中看看吧.</DIV>');break;
					case "-4":Alert('<div class="W300">本期商品不允许保价哟,我们没有提供该商品的保价操作的呀,您是怎么做到这一步的呀,您真是个高手.</DIV>');break;
					case "-3":Alert('<div class="W300">好象本期商品的游戏类型不符,请您检查一下吧.</DIV>');break;
					case "-2":Alert('<div class="W300">该商品好像不存在哟,请您检查一下吧</DIV>');break;
					case "-1":Alert('<div class="W300">您还未登陆吧,请先登陆再操作.</DIV>');break;
					case "0":Alert('<div class="W300">您好,本次操作已被取消,可能是您已保价购买成功了或是您赢取了本商品,如果是这样的话,您到会员中心的"订单管理中"看看吧.</DIV>');break;
					case "1":Alert('<div class="W300">恭喜哟，您已保价购买了本期商品。您可以在用户中心的订单管理中查看您订单。</DIV>');break;
					default:Alert('<div class="W300">不好意思哟，您的未能成功保价该拍品。\r\n如果您还未登陆，请先登陆吧。</DIV>');break;
				}
				

								
		
			}
			,null,"html");	
	}
}

/*+++++++++++++++++++++++++++++++++++++
+ 功能:分身(又名,机器人会员,自动出价器)
+ 研发:宗帝
+ 时间:2010-12-23
+++++++++++++++++++++++++++++++++++++*/
function RobotUser(_GameType,_Vid,_PaiPai)
{
	this.GameType	= _GameType,
	this.PaiPaiBid	= _PaiPai;
	this.UserId 	= (this.PaiPaiBid?this.PaiPaiBid.UserId:0),
	this.VendueId 	= _Vid,
	
	this.StartType = 0,
	this.StartPrice =0,//分，不是元
	this.StartTimeStr = "",
	this.StartTime = new Date();
	this.StartCount =0,
	
	this.TacticType 	= 0,	//0最后10秒价,1随机出价(1~30秒)
	
	this.StopType 		= 0,	//0:手工停止,1依次数,2依价格,3依时间
	this.StopPrice 	= 0,
	this.StopPriceStep	= 1,	//分.不是元
	this.StopCount =0,//StopCount >=StartCount 时停止
	this.StopTime = new Date(),
	
	
	this.State 	= -1,	//0:未启动状态,1执行中状态,2停止状态
	//出价策略 strategy / tactic
	
	
	
	//	this.StartTime = new Date(),//本次启动时的当前时间(客户端电脑时间,可能与服务器不一致),暂无功能
	//
	this.Start = function (_StartType,_StartPrice,_StartTime,_StartCount
		,_TacticType ,_StopType,_StopPrice,_StopPriceStep,_StopTime)
	{
		this.SetConfig (_StartType,_StartPrice,_StartTime,_StartCount
		,_TacticType ,_StopType,_StopPrice,_StopPriceStep,_StopTime); 
	},
	this.SetConfig = function(_StartType,_StartPrice,_StartTime,_StartCount
		,_TacticType ,_StopType,_StopPrice,_StopPriceStep,_StopTime)
	{//钱以元为单位.
		var _this = this;
		//if()
		this.UserId 	= (this.PaiPaiBid?this.PaiPaiBid.UserId:0);
	//	alert(this.PaiPaiBid.UserId)
	//	alert(this.UserId);
		if(_this.UserId>0)
		{
			_this.State = -1;
			
			_this.StartType = parseInt(_StartType,10);//出价类型
			_this.StartPrice = _StartPrice;
			_this.StartTimeStr = _StartTime;
			var t = _this.GetDateParse(_StartTime);
			_this.StartTime = t ;
			_this.StartCount = _StartCount;
			
			_this.TacticType = parseInt(_TacticType,10);
			_this.StopType = _StopType;
			_this.StopPrice = _StopPrice;
			_this.StopPriceStep = _StopPriceStep;
			_this.StopTime = _StopTime;

			_this.StopCount = 0;//初始
			//alert(_this.StartTime);
			//this.Running();
			_this.State = 0;//启动;
			if(_this.StopType==1 && ( _this.StartCount - _this.StopCount )<1) _this.State = -1;
			if(_this.State ==-1) { alert("自动出价器功能已停止."+_this.StartCount);	}
			else if(_this.State == 0){ alert("自动出价器功能已启动.");}//但还未到自动出价状态.
			else if(_this.State == 1){ alert("自动出价器功能运行中,正在参于出价.");}		

			//显示配置信息
			_this.ShowSetConfigToPage();
		}
		else{ AjaxLoginBox();//alert("您还没有登陆,健身功能暂不能使用.");
		}
	},
	this.Running = function(_Price,_EndStopTimeSecond)
	{
		
		var _this = this;
		//alert(_this.State);
		if(_this.State <=-1) { 
			//已停止,不处理
			
		}
		else if(_this.State == 0){ 
			_this.StartRunning(_Price);
		}
		else if(_this.State == 1){
			//策略,核心组
			_this.TacticRunning(_Price,_EndStopTimeSecond);
		}
		//window.status = "运行中...("+ _this.StopCount +").." + new Date().getTime();
		//jQuery("#input_StartCount").val(_this.StartCount - _this.StopCount);
		this.ShowSetConfigToPage2();
	},

	this.StartRunning =  function(_Price){//判断是否需要启动
		var _this = this;
		//0:price,1:time
		if(_this.StartType==0) {if(_Price>=_this.StartPrice){_this.State=1;}}
		if(_this.StartType==1) {
			var t = new Date();
			if(t>= _this.StartTime)
			{
				_this.State=1;
			}
		}
	},
	this.TacticRunning = function(_Price,_EndStopTimeSecond){ //_this.StartType==1
		//window.status +="|" + _EndStopTimeSecond + "秒";
		var _this = this;
		if(_this.State<0)return ;
		//判断策略,判断停止
		if(_this.TacticType==0)//最后10秒
		{
			if(_EndStopTimeSecond<=10)_this.Bid(_Price);
		}
		else if(_this.TacticType==1)//1~30秒
		{
			var x = _this.GetRandom(1,30);
			if(_EndStopTimeSecond<=x) _this.Bid(_Price);
		}
		
	},
	this.Stop = function(){
		var _this = this;
		_this.State = -1;//停止
		_this.StartPrice = 0;
		_this.StartType = 0;
		_this.StartCount = 0;
		
		_this.TacticType = 0;
		_this.StopType = 0;
		_this.StopPrice = 0;
		_this.StopPriceStep = 0;
		_this.StopCount = 0;
		//alert("stop");
		//alert("分身功能已取消.");
	},
	this.Bid = function(_Price){
		//alert("Robot="+_Price);
		var _this = this;
		
		if(_this.State==1)// return true;
		{
		
			//添加分身标识
			switch(_this.StopType)
			{
				case 0:_this.VenudeBid();break;
				case 1://次数到了,停
					//window.status ="="+(_this.StartCount-_this.StopCount);
					if((_this.StartCount-_this.StopCount)>0){ 
						_this.VenudeBid();
						_this.StopCount ++;
						
					}
					else{
						_this.State = -1;
					}
					break;
				case 2: //价格到了,停
				
					if(_this.StopPrice>_Price){
						_this.VenudeBid();
						_this.StopCount ++;
					}
					else {
						_this.State = -1;
					}
					break;
				default : //手工停
					{
						_this.VenudeBid();
						_this.StopCount ++;
					}
					break;
			}
		//	window.status = "robot=" + _Price;	
		}
		//window.status = "robotOther=" + _Price + "State=" + _this.State;
	},
	this.IsState = function(){
		return (this.State==1);//是否处于分身状态
	},
	this.VenudeBid = function()
	{
		this.PaiPaiBid.Bid(this.VendueId,1);
	},
	this.GetState = function()
	{
		var _this = this;
		var _return = "类型:"+ _this.State + ";";
		
		if(_this.State==1)
		{
			switch(_this.Type)
			{
				case 0:_return += "分身功能启动中";break;
				case 1://次
					_return += "分身功能启动中...剩余次数:" + (_this.StartCount-_this.StopCount);
					break;
				case 2:
					_return += "分身功能启动中...目标价位:" + _this.StopPrice;
					break;
				default :_return += "分身功能启动中(default)"+ _this.StopType;break;
			}	
		}
		else{
			_return += "分身功能已取消";
		}
		return _return ;
	}
	,
	this.GetRandom = function (min,max)
	{
		var x = Math.round(Math.random()*max);
		if(x>min)
			x = min + Math.round(Math.random()*(max-min));
		return x;
	}
	,this.GetDateParse = function(_time)
	{
		var y = 2011;
		var M = 1;
		var d = 1;
		var h = 0; 
		var m = 0;
		var s = 0;
		//2011-02-03 10:10:10
		if(_time.length>4)	y = parseInt(_time.substr(0,4));
		if(_time.length>7)	M = parseInt(_time.substr(5,2));
		if(_time.length>10)	d = parseInt(_time.substr(8,2));
		
		if(_time.length>13)	h = parseInt(_time.substr(11,2));
		if(_time.length>16)	m = parseInt(_time.substr(14,2));
		if(_time.length>=19)	s = parseInt(_time.substr(17,2));
		
		return new Date(y,M-1,d,h,m,s);
	}
	,this.ShowSetConfigToPage = function(){
		var _this = this;
		switch(parseInt(_this.StartType,10))
		{
			case 0:jQuery("#span_Span_StartInfo").html("将于当前价为"+ _this.StartPrice +"元时启动.");break;
			case 1:
			jQuery("#span_Span_StartInfo").html("将于"+ _this.StartTimeStr +"时启动.");break;
		}
		
		switch(parseInt(_this.TacticType,10))
		{
			case 0:jQuery("#span_Span_StartTactic").html("最后10秒出价.");break;
			case 1:jQuery("#span_Span_StartTactic").html("最后1~30秒随机出价.");break;
		}
		switch(parseInt(_this.StopType,10))
		{
			case 0:jQuery("#span_Span_StopInfo").html("手工停止自动出价.");break;
			case 1:jQuery("#span_Span_StopInfo").html("剩余次数为0时停止出价,还剩"+ ( _this.StartCount - _this.StopCount ) +"次.");break;
			case 2:jQuery("#span_Span_StopInfo").html("到当前价位为"+ _this.StopPrice +"元时停止出价.");break;
		}		
	}
	,this.ShowSetConfigToPage2 = function(){
		var _this = this;
		switch(parseInt(_this.StopType,10))
		{
			case 0:jQuery("#span_Span_StopInfo").html("手工停止自动出价.");break;
			case 1:jQuery("#span_Span_StopInfo").html("剩余次数为0时停止出价,还剩"+ ( _this.StartCount - _this.StopCount ) +"次.");break;
			case 2:jQuery("#span_Span_StopInfo").html("到当前价位为"+ _this.StopPrice +"元时停止出价.");break;
		}		
	}
		
}