function BuyGoods(){
	this.hhtName="";				//户户通名
	this.goodsType=0;				//贷物类型，1实物，0虚拟
	this.productId="";			//产品代号
	this.productName=""; 		//产品名称
	this.productPrice=0; 		//产品价格
	this.buyCount=0;		 		//购买数量
	this.productResume="";	//产品简介
	this.payMethod=3;		 		//支付方式
	this.formDiv=null;	 		//
	this.receiverName="";	 	//收贷人姓名
	this.receiverAddr="";		//收贷人地址
	this.receiverTell="";		//收贷人电话
	this.cover=null;				//遮盖层
	this.styleClass=null;		//
	this.curTab="";					//当前选中的表头

	//初始化共享变量
	if(typeof BuyGoods._initShareVar == "undefined"){
		BuyGoods.prototype.instanceCount=0; //初始化实例数
		BuyGoods.prototype.instanceArray=new Array(); //保存实例数组
		BuyGoods._initShareVar=true;
	}
	BuyGoods.prototype.instanceCount++;
	this.hwnd=BuyGoods.prototype.instanceCount; //窗口句柄用于窗口代码回调使用
	BuyGoods.prototype.instanceArray[this.hwnd]=this; //保存实例引用
	this.payHtmlArray=new Array();
	this.payHtmlArray[0]="<div class='payMethod'>在户户通网站有注册帐户，通过在线免费赚取户户币或者使用：网上银行，支付宝，财付通，快钱，进行充值,便可使用户户币直接付款。</div>";
	this.payHtmlArray[1]="<div class='payMethod'>支付宝（中国）网络技术有限公司是国内最大的独立第三方支付平台，由阿里巴巴集团创办。<br>网址:www.alipay.com</div>"; //支付宝
	this.payHtmlArray[2]="<div class='payMethod'>财付通是腾讯公司于2005年9月正式推出专业在线支付平台，致力于为互联网用户和企业提供安全、便捷、专业的在线支付服务。<br>网址:www.tenpay.com</div>"; //财付通
	//this.payHtmlArray[3]="可支持中国银行、中国工商银行、中国农业银行、中国建设银行、招商银行等国内数十家金融机构充值。"; //网银
	this.payHtmlArray[3]="<div class='BankList'><li><input type='radio' name='bankname"+this.hwnd+"' value='ABC' checked><img src='/images/BankLogo/img_bankabc.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='BOC'><img src='/images/BankLogo/img_bankboc.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='BOCOM'><img src='/images/BankLogo/img_bankbocom.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='CCB'><img src='/images/BankLogo/img_bankccb.gif' /></li></div>";
	this.payHtmlArray[3]+="<div class='BankList'><li><input type='radio' name='bankname"+this.hwnd+"' value='CEB'><img src='/images/BankLogo/img_bankceb.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='CIB'><img src='/images/BankLogo/img_bankcib.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='CITIC'><img src='/images/BankLogo/img_bankcitic.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='CMB'><img src='/images/BankLogo/img_bankcmb.gif' /></li></div>";
	this.payHtmlArray[3]+="<div class='BankList'><li><input type='radio' name='bankname"+this.hwnd+"' value='CMBC'><img src='/images/BankLogo/img_bankcmbc.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='GDB'><img src='/images/BankLogo/img_bankgdb.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='HXBC'><img src='/images/BankLogo/img_bankhxbc.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='ICBC'><img src='/images/BankLogo/img_bankicbc.gif' /></li></div>";
	this.payHtmlArray[3]+="<div class='BankList'><li><input type='radio' name='bankname"+this.hwnd+"' value='PSBC'><img src='/images/BankLogo/img_bankpsbc.gif' /></li>";
	this.payHtmlArray[3]+="<li><input type='radio' name='bankname"+this.hwnd+"' value='SPDB'><img src='/images/BankLogo/img_bankspdb.gif' /></li></div>"; 
	this.payHtmlArray[4]="<div class='payMethod'>（快钱）是国内领先的独立第三方支付企业，旨在为各类企业及个人提供安全、便捷和保密的综合电子支付服务。</div>"; //快钱
	//变量初始化完毕
	//初始化共享方法用于减少内存使用
	if(typeof BuyGoods._initialized == "undefined"){
		
		//放入物品
		BuyGoods.prototype.putGoods=function(pName,pPrice,pCount,pResume,pType,pProductId,pShowLoginFrm){
			if(pShowLoginFrm){
				if(confirm("为了保证您的帐户安全请先登入")){
					showLoginFrm();
				}
				return;
			}
			this.setDefault();
			this.productName=pName;
			this.productPrice=pPrice;
			this.buyCount=pCount;
			this.productResume=pResume;
			this.goodsType=pType;
			this.productId=pProductId;
			this.show(true);
		}
		
		BuyGoods.prototype.setDefault=function(){ //重置
			this.productName="";
			this.productPrice=0;
			this.buyCount=0;
			this.payMethod=3;
			this.receiverName="";	 	//收贷人姓名
			this.receiverAddr="";		//收贷人地址
			this.receiverTell="";		//收贷人电话
			this.goodsType=0;				//贷物类型，1实物，0虚拟
			this.goodsClassId=0;		//物品类比如：电话卡，计费器，网关，
			this.goodsId=0;					//具体的物品ID
		}
		
		BuyGoods.prototype.show=function(showFlag){ //显示窗口
		if(this.formDiv==null){
				this.cover=new Cover();
				this.formDiv=document.createElement("div");
				this.formDiv.style.left=((top.document.body.scrollWidth)-600)/2; //window.event.clientX;
				this.formDiv.style.top=50;  //window.event.clientX;
				this.formDiv.style.position="absolute";
				this.formDiv.style.border="0px solid #A6C9E1";
				this.formDiv.style.background="#ffffff";
				this.formDiv.style.zIndex="9999";
				document.body.appendChild(this.formDiv);
				
				//开始写样式表
				var headElement = document.getElementsByTagName("head")[0]; 
				this.styleClass = document.createElement('link');
				void(this.styleClass.rel = 'stylesheet');
				void(this.styleClass.href = '/css/BuyGoodsJs.css');
				void(this.styleClass.type = 'text/css');
				headElement.appendChild(this.styleClass);
			}
			if(showFlag){
				this.formDiv.style.display="";
				this.cover.show();
			}else{
				this.formDiv.style.display="none";
				this.cover.hide();
			}
			var formHtml;
			formHtml="<div class='BuyGoods'>";
			formHtml+="<div class='Title1'>";
			formHtml+="<div style='padding-top:10px;padding-left:5px;border:0px solid black;'>";
			formHtml+="<img src='/images/shop.gif' width='25px' height='15px'> 订单 order";
			formHtml+="</div>";
			formHtml+="<div class='Close' align='center' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"hide\",0)'>关闭</div>";
			formHtml+="</div>";
			formHtml+="<div style='position:relative;'>";
			formHtml+="<div style='position:relative;margin-top:8px;margin-left:3px;margin-right:3px;border:1px solid #A6c9E1;height:160px;'>";
			formHtml+="<div style='position:absolute;left:3px;top:3px;'><u>商品信息:</u></div>";
			formHtml+="<div style='position:relative;top:18px;'>";
			formHtml+="<div style='width:275px;height:150px;border:0px solid gray;padding-left:10px;padding-top:10px' align='left'>";
			//formHtml+="<li style='list-style:none;margin-top:3px;'>请输入户户帐号:<input id='BuyGoods"+this.hwnd+"_hhtname' type='text' size='20' style='border:1px solid #A6c9E1;height:20px;font:9pt;'></li>";
			//formHtml+="<li style='list-style:none;margin-top:3px;'>请再次输入帐号:<input id='BuyGoods"+this.hwnd+"_hhtvalidate' type='text' size='20' style='border:1px solid #A6c9E1;height:20px;font:9pt;'></li>";
			formHtml+="<li style='list-style:none;margin-top:3px;'>商品ID:"+this.productId+"</li>";
			formHtml+="<li style='list-style:none;margin-top:3px;'>商品名称:"+this.productName+"</li>";
			formHtml+="<li style='list-style:none;margin-top:3px;'>商品单价:"+this.productPrice+"元</li>";
			formHtml+="<li style='list-style:none;margin-top:3px;'>购买数量:"+this.buyCount+"</li>";
			formHtml+="<li style='list-style:none;margin-top:3px;'>商品描述:"+this.productResume+"</li>";
			formHtml+="</div>";
			//formHtml+="<div style='position:absolute;top=0px;left:246px;width:245px;height:180px;border:0px solid gray;'></div>";
			formHtml+="</div>";
			formHtml+="</div>";
				
			if(this.goodsType==1){
				formHtml+="<div style='position:relative;margin-top:8px;margin-left:3px;margin-right:3px;border:1px solid #A6c9E1;height:100px;'>";
				formHtml+="<div style='position:absolute;left:3px;top:3px;'><u>收件人信息:</u></div>";
				formHtml+="<div style='position:relative;top:18px;width:490px;height:80px;border:0px solid gray;padding-left:10px;padding-top:10px' align='left''>";
				formHtml+="<li style='list-style:none;margin-top:3px;'>联系人:&nbsp;&nbsp;<input id='hhtname' type='text' size='15' style='border:1px solid #A6c9E1;height:15px;font:9pt;'></li>";
				formHtml+="<li style='list-style:none;margin-top:3px;'>联系电话:<input id='hhtname' type='text' size='15' style='border:1px solid #A6c9E1;height:15px;font:9pt;'></li>";
				formHtml+="<li style='list-style:none;margin-top:3px;'>收货地址:<input id='hhtname' type='text' size='50' style='border:1px solid #A6c9E1;height:15px;font:9pt;'></li>";
				formHtml+="</div>";
				formHtml+="</div>";
			}
			formHtml+="<div style='position:relative;margin-top:18px;margin-left:3px;margin-right:3px;border-bottom:1px solid #A6c9E1;height:25px;'>";
			formHtml+="<div style='position:absolute;bottom:-1px;border:0px solid black;height:20px;'>"
			formHtml+="<div style='margin-top:5px;'>";
			formHtml+="<li class='TabMenu' id='BuyGoods"+this.hwnd+"0' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"tabSwitch\",0)'>户户币</li>";
			formHtml+="<li class='TabMenu' id='BuyGoods"+this.hwnd+"1' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"tabSwitch\",1)'>支付宝</li>";
			formHtml+="<li class='TabMenu' id='BuyGoods"+this.hwnd+"2' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"tabSwitch\",2)'>财付通</li>";
			formHtml+="<li class='TabMenuSelected' id='BuyGoods"+this.hwnd+"3' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"tabSwitch\",3)'>网上银行</li>";
			formHtml+="<li class='TabMenu' id='BuyGoods"+this.hwnd+"4' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"tabSwitch\",4)'>快钱</li>";
			formHtml+="</div>";
			formHtml+="</div>"
			formHtml+="<span style='position:absolute;right:0px;bottom:0px'><-支付方式</span>";
			formHtml+="</div>";
			formHtml+="<div style='position:relative;height:200px;border:1px solid #A6c9E1;border-top:0px;margin-top:0px;margin-left:3px;margin-right:3px;'>";
			formHtml+="<div id='BuyGoods"+this.hwnd+"payMethod'>";
			formHtml+=this.payHtmlArray[3];
			formHtml+="</div>";
			formHtml+="<div style='position:absolute;bottom:10px;right:15px;'><input class='btn' type='button' value='确认付款' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"submit\",4)'></div>";
			formHtml+="</div>";
			formHtml+="</div>";
			formHtml+="</div>";
			this.curTab="BuyGoods"+this.hwnd+"0";
			this.formDiv.innerHTML=formHtml;
		}
		
		BuyGoods.prototype.hide=function(){ //隐藏窗口
			if(this.formDiv==null)return;
			this.formDiv.style.display="none";
			this.cover.hide();
		}
		
		BuyGoods.prototype.tabSwitch=function(pPara){ //表切换
			document.getElementById(this.curTab).className="TabMenu";
			this.curTab="BuyGoods"+this.hwnd+pPara;
			document.getElementById(this.curTab).className="TabMenuSelected";
			this.payMethod=pPara;
			document.getElementById("BuyGoods"+this.hwnd+"payMethod").innerHTML=this.payHtmlArray[pPara];
		}
		
		BuyGoods.prototype.submit=function(){ //隐藏窗口
			/*this.hhtName=document.getElementById("BuyGoods"+this.hwnd+"_hhtname").value;
			var vhhtName=document.getElementById("BuyGoods"+this.hwnd+"_hhtvalidate").value;
			if(!isAlphaOrNum(this.hhtName)){ 
				alert("户户通注册帐号输入不正确");
				return false;
			}
			if(this.hhtName!=vhhtName){
				alert("两次帐号输入不正确,请重新输入");
				return false;
			}*/
			
			var temp=document.getElementsByName("bankname"+this.hwnd);
			var bankname="";
		  for (i=0;i<temp.length;i++){ 
		    if(temp[i].checked){
		    	bankname=temp[i].value;
		    } 
		  } 

			this.vWindow=window.open("/mall/PlaceOrder.jsp?taskId=2&taskPara="+this.productId
									+"&paymethod="+this.payMethod+"&payAmount="+this.productPrice+"&bankname="+bankname);
			
			var htmlCode="<div class='BuyGoods'>";
			htmlCode+="<div class='Title1'>";
			htmlCode+="<div style='padding-top:10px;padding-left:5px;border:0px solid black;'>";
			htmlCode+="<img src='/images/shop.gif' width='25px' height='15px'> 订单 order";
			htmlCode+="</div>";
			htmlCode+="<div class='Close' align='center' onclick='javascript:BuyGoods.CallFunc("+this.hwnd+",\"hide\",0)'>关闭</div>";
			htmlCode+="</div>";
			htmlCode+="<div style=\"padding:80; padding-bottom:20;\" align='center'><image src=\"/images/loading.gif\" width=\"60\" height=\"60\"></div>";
			htmlCode+="<div style='margin-bottom:100;width:500;' align='center'><span style=\"font-size:12px;\">&nbsp;&nbsp;&nbsp;&nbsp;请在支付页面支付......</font></div>";
			htmlCode+="</div>";
			this.formDiv.innerHTML=htmlCode;
		}
		
		//静态方法调用函数
		BuyGoods.CallFunc=function(pHwnd,pFuncName,pPara){
			if(pFuncName=="hide"){
				BuyGoods.prototype.instanceArray[pHwnd].hide();
			}else if(pFuncName=="show"){
				BuyGoods.prototype.instanceArray[pHwnd].show();
			}else if(pFuncName=="setDefault"){
				BuyGoods.prototype.instanceArray[pHwnd].setDefault();
			}else if(pFuncName=="tabSwitch"){
				BuyGoods.prototype.instanceArray[pHwnd].tabSwitch(pPara);
			}else if(pFuncName=="submit"){
				BuyGoods.prototype.instanceArray[pHwnd].submit();
			}
		};
		
		BuyGoods._initialized = true; 
	}
}
