<%@page contentType="text/html;charset=GBK" %>
<%@ taglib uri="/bean" prefix="bean" %>
<%@ taglib uri="/html" prefix="html" %>
<%@ taglib uri="/logic" prefix="logic" %>
<%@ taglib uri="/keyshop" prefix="keyshop" %>
<%@include file="/jsp/pub/pub.jsp"%>
<%
	if(currentChannel.getDescription() != null) {
		PAGETITLE = currentChannel.getChannelZhName() + "-" + currentChannel.getDescription();
	} else {
		PAGETITLE = currentChannel.getChannelZhName() + PAGETITLE;
	}
	PAGEDESCRIPTION = PAGETITLE;
	PAGEKEYWORDS = PAGETITLE;
%>
<%@include file="/jsp/pub/top.jsp"%>
<jsp:useBean id="reguserForm" class="com.keyshop.shop.user.controller.UserForm" scope="request"/>
<%
User bean = (User)reguserForm.getBean();
%>
<html:javascript formName="userRegForm"/>   
<SCRIPT language=JavaScript src=="<%=CONTEXT%>/fg/js/pub.js"></SCRIPT>
<SCRIPT language=JavaScript src=="<%=CONTEXT%>/fg/js/check.js"></SCRIPT>
<SCRIPT language=JavaScript src=="<%=CONTEXT%>/fg/js/state.js"></SCRIPT>
<script>
<% if(("true").equals((String)request.getAttribute("name_existed"))){%>
alert("用户名已经存在，请修改后在添加");
<%
} else  if(("true").equals((String)request.getAttribute("email_existed"))){
%>
alert("用户Email已经存在，请修改后在添加");	
<%
}
%>
function test_name(str) {
var pattern = /^[_\-a-zA-Z0-9]{3,20}$/;
if(pattern.test(str)) return true;
return false;
} 
	function trim(Str , Flag)
	{
	
		Str	= ""+Str;
		if( Flag == "l" || Flag == "L" )/*trim left side only*/
		{
			RegularExp	= /^\s+/gi;
			return Str.replace( RegularExp,"" );
		}
		else if( Flag == "r" || Flag == "R" )/*trim right side only*/
		{
			RegularExp	= /\s+$/gi;
			return Str.replace( RegularExp,"" );
		}
		else/*defautly, trim both left and right side*/
		{
			RegularExp	= /^\s+|\s+$/gi;
			return Str.replace( RegularExp,"" );
		}
	}
	 function submitForm() {
	 	 userRegForm.actionType.value = "regsetp3";
			
		 if(validateUserRegForm(userRegForm)) {
			if(!test_name(trim(document.all['bean.id'].value))) {
				alert("用户名必须输入3-20位英文字母或者数字。")
				return;
			}
			if(!test_name(trim(document.all['bean.password'].value))) {
				alert("密码必须输入3-20位英文字母或者数字。")
				return;
			}
			
		//	if(document.all['bean.password'].value != userRegForm.testrepassword.value) {
			//		alert("重复密码不一致。")
				//	return;
			//}
			
	    document.userRegForm.submit();
	  }
	}
	
	function formReset(){
	  document.userRegForm.reset();
	}
</script>

<table width="96%" height="96%" border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="f2f2f2"> 
    <td colspan="3" height=1></td>
  </tr>
  <tr> 
    <td bgcolor="f2f2f2" width=1></td>
    <td align="center" valign="top" bgcolor="ffffff">
			<table bgcolor="ffffff"  width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
			    <td>&nbsp;</td>
			    <td bgcolor="ffffff"></td>
			    <td width=40></td>
			  </tr>
			</table>
			<table border="0" width="680" align=center cellpadding="0" cellspacing="0">
			  <tr>
			    <td width="10" height="10">
			    	<img src="<%=CONTEXT%>/img/QQ/i01.gif" width="10" height="10"></td>
			    <td background="<%=CONTEXT%>/img/QQ/i03.gif"></td>
			    <td width="10" height="10">
			    	<img src="<%=CONTEXT%>/img/QQ/i02.gif" width="10" height="10"></td>
			  </tr>
			  <tr>
			    <td  background="<%=CONTEXT%>/img/QQ/i04.gif">&nbsp;</td>
			    <td>
						<table width="100%"  border="0" cellpadding="0" cellspacing="0">
						  <tr bgcolor="f2f2f2"> 
						    <td colspan="3" height=25></td>
						  </tr>
						  <tr>
						    <td  colspan="3" valign="top" bgcolor="">
									<table width="100%"  bgcolor="" border="0" cellspacing="0" cellpadding="0">
						        <tr> 
						          <td align="center" height=25 bgcolor="2B579E">
						          	<font color="#FFFFFF">
						          		<strong> 
									    	     用户注册信息			
									   	    </strong>
									   	  </font>
									   	</td>
						        </tr>
						      </table>
						    </td>
						  </tr>
						  <tr> 
						    <td bgcolor="f2f2f2" width=1></td>
						    <td align="center" valign="top" bgcolor="f2f2f2"><br>
						      <table width="95%"  border="1" align="center" cellpadding="0" cellspacing="0" 
										bordercolorlight="#D4D4D4" bordercolordark="white">
						        <tr>
						          <td align="center" bgcolor="#FFFFFF">
												<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="f2f2f2">
											    <tr>
											    	<td>
																		<html:form  method="post" action="/fg/user/userreg">
																		<html:hidden property="channelId" value="<%=currentChannel.getId()%>"/>
																		<input type="hidden" name="actionType" value="fgsave"/> 
																		<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="f2f2f2">
											               <tr>
													             <td align="right">用户名：</td>
													             <td align="left">
													             	<html:text property="bean.id" size="16" styleClass="i03" maxlength="20"/>	
													                 <font color="red">*</font></td>
													           </tr>
													           <tr>
													             <td align="right">密码：</td>
													             <td align="left">
												             	<html:password property="bean.password" size="16" styleClass="i03" maxlength="20"/>
												                   <font color="red">*</font></td>
												             </tr>
												             <tr>
												               <td align="right">确认密码：</td>
												               <td align="left">
												               	<input class="i03" name="repassword" type="password"  size="16">
												                   <font color="red">*</font></td>
												             </tr>
												             <tr>
												               <td colspan="2"></td>
												             </tr>
															       <tr align="center">
												               <td colspan="2"><span class="Login_Title">--保护您的个人信息 --</span></td>
												             </tr>
												             <tr>
												               <td class="zc_tdline"  colspan="2"></td>
												             </tr>
												             <tr>
												               <td align="right">密码查询问题：</td>
												               <td align="left">
												               	<html:text property="bean.question" size="16" styleClass="i03" maxlength="20"/>
												                  	<font color="red">*</font></td>
													           </tr>
													           <tr>
													             <td align="right">密码查询答案：</td>
													             <td align="left">
													             	<html:text property="bean.answer" size="16" styleClass="i03" maxlength="20"/>
													                  	<font color="red">*</font></td>
													           </tr>
													             <tr align="center">
													               <td colspan="2"><span class="Login_Title">-- 以下是您的个人信息 --</span></td>
													             </tr>
													             <tr>
													               <td class="zc_tdline"  colspan="2"></td>
													             </tr>
													             <tr>
													               <td align="right">姓名：</td>
													               <td align="left">
													               	<html:text property="bean.userName" size="16" styleClass="i03" maxlength="20"/>
													                 <font color="red">*</font></td>
													           </tr>
													           <tr>
													             <td align="right">性别：</td>
													             <td align="left"><html:radio property="bean.sex" value="true"  styleClass="check"/>
													             男 
													            <html:radio property="bean.sex" value="false"  styleClass="i03"/>
													          	女  <font color="red">*</font></td>
													           </tr>
													           <tr>
													             <td align="right">身份证号：</td>
													             <td align="left">
													             	<html:text property="bean.idcard" size="24" styleClass="i03" maxlength="20"/></td>
													               </tr>
													               <tr>
													                 <td align="right">Email：</td>
													                 <td align="left">
													                 	<html:text property="bean.email" size="24" styleClass="i03" maxlength="127"/>
													                 <font color="red">*</font></td>
													           </tr>
													           <tr>
													             <td align="right">联系电话：</td>
													             <td align="left">
													             	<html:text property="bean.phone" size="24" styleClass="i03" maxlength="20"/> 
													                 <font color="red">*</font>
													             </td>
													           </tr>
													           <tr>
													             <td align="right">手机：</td>
													             <td align="left">
													             	<html:text property="bean.mobile" size="24" styleClass="i03" maxlength="20"/></td>
													           </tr>
													           <tr>
													             <td align="right">直辖市、省：</td>
													             <td align="left"> 
																			   <html:select property="bean.province"  onchange="State_updateck(document.all['bean.province'], document.all['bean.city'], '')" styleClass="i03" >
																						<option value="0" selected>请选择...</option>
																					</html:select> 
																				  <html:select property="bean.city"  styleClass="i03" >
																					<option value="0" selected>请选择...</option>
																				  </html:select> 
																			   <font color="red">*</font></td>
																			     </tr>
																			     <tr>
																			       <td align="right">详细地址：</td>
																			       <td align="left">
																			       	<html:text property="bean.contact_address" styleClass="i03" size="40" maxlength="127"/>
																			           <font color="red">*</font>
																			       </td>
																			     </tr>
																			     <tr>
																			       <td align="right">邮编：</td>
																			       <td align="left">
																			       	<html:text property="bean.zipcode" size="24" styleClass="i03" maxlength="24"/>
													                           <font color="red">*</font>
													                   </td>
												                   </tr>
												            </table>
												                 
											 						 <table width="100%" border="0" cellspacing="0" cellpadding="0">
							                       <tr>   
																	     <td>
																			
																					<input type="button" onclick="javascript:submitForm()" name="Submit" value="提交"  class="i04">
																			    &nbsp;&nbsp; 
																			    <input type="reset"  value="清空" class="i04">
																			 </td>
																	<!--
																	<div align="center">
																	　　<a href="#">
																	 　<img onclick="javascript:submitForm()" src="<%=CONTEXT%>/img/pic0530.gif"width="61"height="26" border="0">
																	 　</a>
																	　 <a href="#">
																	　　<img onclick="javascript:formReset()"  src="<%=CONTEXT%>/img/pic0531.gif"width="61" height="26" border="0">
																	　　 </a>
																	</div>
																	-->
                                　
			                               </tr>
			                               <tr>
																       <td hight=25 align="right"></td>
																       <td align="left"></td>
									                   </tr>
				     											</table>
				     											</html:form >
											      </td>
					                </tr>
						            </table>
						          </td>
						        </tr>
						        <tr>
						        	<td  colspan="4" bgcolor="f2f2f2"></td>
						        </tr>
						      </table>
						    </td>
						    <td bgcolor="f2f2f2" width=1></td>
						  </tr>
						</table>
			    </td>
			    <td background="<%=CONTEXT%>/img/QQ/i05.gif"></td>
			  </tr>
			  <tr>
			    <td width="10" height="10">
			    	<img src="<%=CONTEXT%>/img/QQ/i06.gif" width="10" height="10"></td>
			    <td background="<%=CONTEXT%>/img/QQ/i08.gif"></td>
			    <td width="10" height="10">
			    	<img src="<%=CONTEXT%>/img/QQ/i07.gif" width="10" height="10"></td>
			  </tr>
			</table>
    </td>
  </tr>
</table>

<!--底部文件-->
<%@include file="/jsp/pub/bottom.jsp"%>
<script>
	initprovince(document.all['bean.province']);
	<%
		if(!StringUtil.isEmpty(bean.getProvince())) {	
	%>
	document.all['bean.province'].value='<%=bean.getProvince()%>';
	<%
		if(!StringUtil.isEmpty(bean.getCity())) {	
	%>
	State_updateck(document.all['bean.province'], document.all['bean.city'], '<%=bean.getCity()%>');
	<%
			}
		}
	%>
	/**
	 * 选择省份后，变换市为选择省的所有市
	 * form 表单名
	 * city 输入城市名，如果是添加操作city为空，是显示修改信息则输入city值
	 */
  function State_updateck(provincectrl, cityctrl,  city)
	{
  	var a="安徽:合肥,182*蚌埠,184*淮北,186*安庆,188*铜陵,190*滁州,183*淮南,185*阜阳,187*马鞍山,189*黄山,191*宿州,257*其他,245*;澳门:澳门,255*;北京:北京,001*其他,250*;福建:福州,034*泉州,036*三明,038*漳州,040*莆田,035*南平,037*龙岩,039*厦门,041*其他,226*;甘肃:兰州,134*白银,136*嘉峪关,138*天水,135*金昌,137*其他,235*;广东:东莞,006*惠州,008*揭阳,010*梅州,012*韶关,014*佛山,016*中山,018*云浮,020*茂名,022*广州,005*深圳,007*汕尾,009*潮州,011*河源,013*清远,015*江门,017*肇庆,019*阳江,021*湛江,023*其他,223*;广西:南宁,024*防城港,026*贵港,028*梧州,030*钦州,025*北海,027*玉林,029*桂林,031*其他,224*;贵州:贵阳,192*遵义,194*六盘水,193*其他,246*;海南:海口,032*三亚,033*其他,225*;河北:张家口,076*邢台,078*衡水,080*保定,082*承德,084*秦皇岛,086*石家庄,077*邯郸,079*沧州,081*廊坊,083*唐山,085*其他,230*;河南:郑州,062*鹤壁,064*濮阳,066*商丘,068*三门峡,070*南阳,072*漯河,074*新乡,063*安阳,065*开封,067*洛阳,069*平顶山,071*许昌,073*信阳,075*其他,229*;黑龙江:大庆,110*黑河,112*牡丹江,114*鹤岗,116*双鸭山,118*哈尔滨,109*齐齐哈尔,111*伊春,113*鸡西,115*佳木斯,117*七台河,119*其他,233*;湖北:黄冈,054*黄石,056*襄樊,058*荆州,060*武汉,053*鄂州,055*孝感,057*十堰,059*宜昌,061*其他,228*;湖南:长沙,042*株洲,044*郴州,046*湘潭,048*益阳,050*张家界,052*岳阳,043*衡阳,045*永州,047*怀化,049*常德,051*其他,227*;吉林:四平,164*松原,166*辽源,168*白山,170*长春,163*白城,165*吉林,167*通化,169*其他,242*延吉,258*;江苏:镇江,196*无锡,198*扬州,200*盐城,202*淮阴,204*连云港,206*南京,195*常州,197*苏州,199*泰州,201*南通,203*宿迁,205*徐州,207*其他,247*;江西:鹰潭,218*九江,220*萍乡,222*南昌,217*景德镇,219*新余,221*其他,249*;辽宁:沈阳,120*锦州,122*朝阳,124*铁岭,126*本溪,128*辽阳,130*营口,132*盘锦,121*葫芦岛,123*阜新,125*抚顺,127*丹东,129*鞍山,131*大连,133*其他,234*;内蒙古:包头,172*赤峰,174*呼和浩特,171*乌海,173*其他,243*;宁夏:银川,144*吴忠,146*石嘴川,145*其他,239*;青海:西宁,139*其他,236*;山东:德州,088*东营,090*潍坊,092*威海,094*济宁,096*莱芜,098*临沂,100*济南,087*聊城,089*淄博,091*青岛,093*烟台,095*泰安,097*日照,099*枣庄,101*其他,231*荷泽,260*;山西:阳泉,104*大同,106*晋城,108*太原,103*朔州,105*长治,107*其他,232*;陕西:渭南,176*延安,178*宝鸡,180*西安,175*铜川,177*咸阳,179*汉中,181*其他,244*;上海:上海,003*其他,252*;四川:德阳,148*广元,150*南充,152*自贡,154*宜宾,156*攀枝花,158*成都,147*绵阳,149*遂宁,151*广安,153*泸州,155*乐山,157*其他,240*;台湾:台湾,256*;天津:天津,002*其他,251*;西藏:拉萨,142*日喀则,143*其他,238*;香港:香港,254*;新疆:乌鲁木齐,140*克拉玛依,141*哈密,261*其他,237*;云南:东川,160*玉溪,162*昆明,159*曲靖,161*其他,241*;浙江:杭州,208*湖州,210*宁波,212*金华,214*温州,216*嘉兴,209*绍兴,211*舟山,213*台州,215*萧山,259*其他,248*;重庆:重庆,004*其他,253*;"

		var data1=""
		var data2=""
		var data3=""
		var data4=""
		var i,j
		data1=a.split(";");
		if (provincectrl.value=="0")
		{
			cityctrl.length=1;
			cityctrl.options[0].value="-1";
			cityctrl.options[0].text="请选择...";
	
		}
		else
		{
			for (i=0;i<data1.length-1;++i)
			{
				data2=data1[i].split(":");
				if (data2[0]==provincectrl.value)
				{
					cityctrl.length=0;
					data3=data2[1].split("*");
					if (data3.length>2)
					{
						cityctrl.length=data3.length;	
						
						for(j=0;j<data3.length;++j)				
						{
							if (j==0)
							{
								cityctrl.options[j].value="0";
								cityctrl.options[j].text="请选择...";
							}
							else
							{
								data4=data3[j-1].split(",");
  										if(city.length > 0){
      										if(data4[0] == city) {
      											cityctrl.options[j].selected = true;
      										}
  										}									
								cityctrl.options[j].value=data4[0];
								cityctrl.options[j].text=data4[0];
							}				
						} 					
					}	
					else
					{
  					cityctrl.length=1;
  					data4=data3[0].split(",");
  					cityctrl.options[0].value=data4[0];
  					cityctrl.options[0].text=data4[0];
				  }	
				}		
		 	}
		}	
	}
		function initprovince(provincectrol)
		{
			provincectrol.length=35;
			provincectrol.options[0].value="0";
			provincectrol.options[0].text="请选择…";
			provincectrol.options[1].value="北京";
			provincectrol.options[1].text="北京";
			provincectrol.options[2].value="广东";
			provincectrol.options[2].text="广东";
			provincectrol.options[3].value="广西";
			provincectrol.options[3].text="广西";
			provincectrol.options[4].value="海南";
			provincectrol.options[4].text="海南";
			provincectrol.options[5].value="福建";
			provincectrol.options[5].text="福建";
			provincectrol.options[6].value="天津";
			provincectrol.options[6].text="天津";
			provincectrol.options[7].value="湖南";
			provincectrol.options[7].text="湖南";
			provincectrol.options[8].value="湖北";
			provincectrol.options[8].text="湖北";
			provincectrol.options[9].value="河南";
			provincectrol.options[9].text="河南";
			provincectrol.options[10].value="河北";
			provincectrol.options[10].text="河北";
			provincectrol.options[11].value="山东";
			provincectrol.options[11].text="山东";
			provincectrol.options[12].value="山西";
			provincectrol.options[12].text="山西";
			provincectrol.options[13].value="黑龙江";
			provincectrol.options[13].text="黑龙江";
			provincectrol.options[14].value="辽宁";
			provincectrol.options[14].text="辽宁";
			provincectrol.options[15].value="上海";
			provincectrol.options[15].text="上海";
			provincectrol.options[16].value="甘肃";
			provincectrol.options[16].text="甘肃";
			provincectrol.options[17].value="青海";
			provincectrol.options[17].text="青海";
			provincectrol.options[18].value="新疆";
			provincectrol.options[18].text="新疆";
			provincectrol.options[19].value="西藏";
			provincectrol.options[19].text="西藏";
			provincectrol.options[20].value="宁夏";
			provincectrol.options[20].text="宁夏";
			provincectrol.options[21].value="四川";
			provincectrol.options[21].text="四川";
			provincectrol.options[22].value="云南";
			provincectrol.options[22].text="云南";
			provincectrol.options[23].value="吉林";
			provincectrol.options[23].text="吉林";
			provincectrol.options[24].value="内蒙古";
			provincectrol.options[24].text="内蒙古";
			provincectrol.options[25].value="陕西";
			provincectrol.options[25].text="陕西";
			provincectrol.options[26].value="安徽";
			provincectrol.options[26].text="安徽";
			provincectrol.options[27].value="贵州";
			provincectrol.options[27].text="贵州";
			provincectrol.options[28].value="江苏";
			provincectrol.options[28].text="江苏";
			provincectrol.options[29].value="重庆";
			provincectrol.options[29].text="重庆";
			provincectrol.options[30].value="浙江";
			provincectrol.options[30].text="浙江";
			provincectrol.options[31].value="江西";
			provincectrol.options[31].text="江西";
			provincectrol.options[32].value="香港";
			provincectrol.options[32].text="香港";
			provincectrol.options[33].value="澳门";
			provincectrol.options[33].text="澳门";
			provincectrol.options[34].value="台湾";
			provincectrol.options[34].text="台湾";
	}
</script>
