<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<!--#include file="../inc/md5.asp" -->
<!-- #include file="inc/SaveRemoteFile.asp" -->
<html>
<head>
<title>会员管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
	font-size:12px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
form{margin:0;}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/js/common.js"></script>
<script src="/js/industrys.js" type="text/javascript"></script>
<script src="/js/areas.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/http.js"></script>
<script type="text/javascript">
// JavaScript Document
function check(obj){
	if(obj.mUserName.value==""){
		alert("用户名不能为空!");
		obj.mUserName.focus();
		obj.mUserName.select();
		return false;
	}
	if(obj.mUserName.value.length<2 || obj.mUserName.value.length>20){
		alert("用户名2-20个字符!");
		obj.mUserName.focus();
		obj.mUserName.select();
		return false;
	}	
	if(obj.PassWord.value==""){
		alert("密码不能为空!");
		obj.PassWord.focus();
		obj.PassWord.select();
		return false;
	}
	if(obj.PassWord.value.length<4 || obj.PassWord.value.length>20){
		alert("密码4-20个字符!");
		obj.PassWord.focus();
		obj.PassWord.select();
		return false;
	}	
	if(obj.PassWord.value!=obj.RePassWord.value){
		alert("两次输入的密码不同!");
		obj.PassWord.focus();
		obj.PassWord.select();
		return false;
	}
	if(!checkemail(obj.Email.value)){
			alert("请填写正确的邮箱地址！");
			obj.Email.focus();
			obj.Email.select();
			return false;
	}
	if(obj.CheckCode.value==""){
		alert("验证码不能为空!");
		obj.CheckCode.focus();
		obj.CheckCode.select();
		return false;
	}
	return true;
}
function checkemail(semail){
	var pattern = /^([\.a-zA-Z0-9_-]){3,}@([\.a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9]){2,4}){1,2}$/; 
	return pattern.test(semail);
}
function checkUser(obj){	
		var resultTxt="";
		var oHttp;	
		if(window.ActiveXObject){
			oHttp=new ActiveXObject("Microsoft.XMLHTTP");		
		}
		else if(window.XMLHttpRequest){
			oHttp=new XMLHttpRequest();		
		}
		if(oHttp){
			oHttp.onreadystatechange = function () {
				if (oHttp.readyState == 4){
					resultTxt = oHttp.responseText;
					document.getElementById('userMsg').innerHTML=resultTxt;
				}
			};
			oHttp.open("POST","/user.asp?uid="+obj.value, true);
			oHttp.send("");				
		}		
}
function checkEmailExits(obj){	
		var resultTxt="";
		var oHttp;	
		if(checkemail(obj.value)){
		if(window.ActiveXObject){
			oHttp=new ActiveXObject("Microsoft.XMLHTTP");		
		}
		else if(window.XMLHttpRequest){
			oHttp=new XMLHttpRequest();		
		}
		if(oHttp){
			oHttp.onreadystatechange = function () {
				if (oHttp.readyState == 4){
					resultTxt = oHttp.responseText;
					document.getElementById('emailMsg').innerHTML=resultTxt;
				}
			};
			oHttp.open("POST","/email.asp?email="+obj.value, true);
			oHttp.send("");				
		}
		}else{
			document.getElementById('emailMsg').innerHTML='您输入的邮箱地址不正确';
		}	
}
function selectcity(provinceid,cityid){	
			var citySelect=document.getElementById(cityid);
			citySelect.options.length = 0;		
			var xmlhttp;	 
			xmlhttp=getXMLRequester();	
			//alert(xmlhttp);
			if(xmlhttp){	
				xmlhttp.onreadystatechange = function doAction() {		
					if (xmlhttp.readyState == 4)
					{			
						/*alert(xmlhttp.responseText);*/				
						var response = xmlhttp.responseXML.documentElement;
						var classidList = response.getElementsByTagName('city');	
						
						for(var i=0;i<classidList.length;i++){
							xx=classidList[i].getElementsByTagName('id');
							yy=classidList[i].getElementsByTagName('title');
							classid=xx[0].firstChild.data
							classtitle=yy[0].firstChild.data				
							citySelect.options[i]=new Option(classtitle,classtitle);							
							if(cityid==classtitle){
								citySelect.options[i].selected=true;
							}
						}
					}
				};
				xmlhttp.open("POST", "/member/get_citys.asp?pid="+provinceid,true);
				xmlhttp.send("");
			}
}////////////////////////	
</script>
</head>
<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,gourl,ParentId,IndustryId,ChannelId

act=request.QueryString("act")
gourl=request.QueryString("gourl")
if(request.QueryString("gourl")<>"") then
	gourl=request.QueryString("gourl")
elseif(request.ServerVariables("HTTP_REFERER")<>"") then
	gourl=request.ServerVariables("HTTP_REFERER")
else
	gourl="/"
end if
if(act<>"" and act="reg") then
	if(isSelfRefer()) then
	else
		call alertstr("禁止外部提交",2)
	end if
	dim rs,mUserName,PassWord,RePassWord,Email,ForAsk,ForAnswer,CheckCode,UIP,IsExits,Photo
	mUserName=cstr(request.Form("mUserName"))
	PassWord=trim(request.Form("PassWord"))
	RePassWord=trim(request.Form("RePassWord"))	
	Email=cstr(request.Form("Email"))
	ForAsk=cstr(request.Form("ForAsk"))
	ForAnswer=cstr(request.Form("ForAnswer"))
	Photo=request.Form("Photo")
	PassWord=Md5(PassWord,32)
	UIP=request.ServerVariables("REMOTE_ADDR")
	dim ComType,ComName,CreateDate,ContactMan,Province,City,BusinessScope,Tel,Fax,Address,PostCode,HomePage,Demons
	ComType=cstr(request.Form("ComType"))
	ComName=cstr(request.Form("ComName"))
	ParentId=request.Form("ParentId")
	if(ParentId<>"") then
		ParentId=Cint(ParentId)
	else
		ParentId=0
	end if
	IndustryId=request.Form("IndustryId")
	if(IndustryId<>"") then
		IndustryId=Cint(IndustryId)
	else
		IndustryId=0
	end if	
	CreateDate=cstr(request.Form("CreateDate"))
	ContactMan=cstr(request.Form("ContactMan"))
	Province=request.Form("Province")
	if(Province<>"") then
		Province=Cint(Province)
	else
		Province=0
	end if	
	City=request.Form("City")
	if(City<>"") then
		City=Cint(City)
	else
		City=0
	end if	
	BusinessScope=cstr(request.Form("BusinessScope"))
	BusinessScope=left(BusinessScope,120)
	Tel=cstr(request.Form("Tel"))
	Fax=cstr(request.Form("Fax"))
	Address=cstr(request.Form("Address"))
	PostCode=cstr(request.Form("PostCode"))
	HomePage=cstr(request.Form("HomePage"))
	Demons=request.Form("content1")
	ChannelId=Cint(request.Form("ChannelId"))
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member_e where UserId='"&mUserName&"' or Email='"&Email&"'",conn,3,3
	if not rs.eof then
		IsExits=true
	else
		rs.addnew
		rs("UserId")=mUserName
		rs("Email")=Email
		rs("UserName")=ComName
		rs("ParentId")=ParentId
		rs("IndustryId")=IndustryId
		rs("ComType")=ComType
		rs("CreateDate")=CreateDate
		rs("ContactMan")=ContactMan
		rs("Province")=Province
		rs("City")=City
		rs("BusinessScope")=BusinessScope
		rs("Tel")=Tel
		rs("Fax")=Fax
		rs("Mobile")=""
		rs("QQ")=""
		rs("HomePage")=HomePage
		rs("Address")=Address
		rs("PostCode")=PostCode
		rs("Photo")=Photo
		rs("Demons")=Demons
		rs.update
		IsExits=false
	end if
	rs.close
	set rs=nothing
	if (IsExits=false) then
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from t_member where UserId='"&mUserName&"'",conn,3,3
		if(rs.eof or rs.bof) then
			rs.addnew
			rs("UserType")=1
			rs("UserId")=mUserName
			rs("UserPass")=PassWord			
			rs("PassAsk")=ForAsk
			rs("PassAnswer")=ForAnswer	
			rs("Email")=Email		
			rs("RegIp")=UIP
			rs("RegDate")=now()			
			rs("LoginNum")=0
			rs("LastLoginIp")=UIP
			rs("LastLoginDate")=now()
			rs("IsLocked")=0
			rs("GoldMoney")=0.00
			rs("Score")=100
			rs("IsCheck")=1
			rs("UserLevel")=0
			rs("ChannelId")=ChannelId
			rs.update
		end if
		rs.close
		set rs=nothing
		response.Write("<p align=""center"">成功添加新企业会员</p>!")
		call PostHttpPage(SearchPortal&"index-add-post.jsp",SearchPortal&"index-add-post.jsp","ChannelId=c0&CatalogId=0&ArticleId="&mUserName&"&Title="&server.URLEncode(ComName)&"&Content="&server.URLEncode(Demons)&"&LinkUrl="&server.URLEncode("http://reg.i536.cn/show.asp?id="&mUserName)&"&Summary=","gbk")
	else
		rs.close
		set rs=nothing
		Response.Write("<script>alert(""此用户或邮箱已存在，请换一个用户名或邮箱试试!"");history.back();</script>")		
	end if
else
	if(request.QueryString("ParentId")<>"") then
		ParentId=Cint(request.QueryString("ParentId"))
	else
		ParentId=1
	end if
	if(request.QueryString("IndustryId")<>"") then
		IndustryId=Cint(request.QueryString("IndustryId"))
	else
		IndustryId=0
	end if
%>
<form id="form1" name="form1" method="post" action="?act=reg&gourl=<%=server.URLEncode(gourl)%>" onSubmit="return check(this)">
  <table width="950" align="center" cellpadding="0" cellspacing="1" bgcolor="#fff0cf" class="tableborder">
    <tr align="middle">
      <th colspan="2" class="pad_10">添加企业会员</th>
    </tr>
    <tr>
      <td height="22" colspan="2" bgcolor="#FFFFFF" class="pformleft">★请仔细填写下面注册信息</td>
    </tr>
    <tr>
      <td width="18%" bgcolor="#FFFFFF" class="pad_5"><strong>用户名</strong>：</td>
      <td width="82%" bgcolor="#FFFFFF" class="pformleft"><input name="mUserName" id="mUserName" size="30" maxlength="20" onBlur="checkUser(this)" />
        (<span class="style3">*</span>)<span id="userMsg"></span></td>
    </tr>        
    <tr>
      <td width="18%" bgcolor="#FFFFFF" class="pad_5"><strong>帐号密码(至少4位)</strong>：</td>
      <td width="82%" bgcolor="#FFFFFF" class="pformleft"><input name="PassWord" type="password" id="PassWord" value="" size="30" maxlength="16" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td width="18%" bgcolor="#FFFFFF" class="pad_5"><strong>确认密码(至少4位)</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="RePassWord" type="password" id="RePassWord" value="" size="30" maxlength="16" />
      (<span class="style3">*</span>)</td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>密码问题</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ForAsk" id="ForAsk" size="30" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>问题答案</strong>：</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ForAnswer" id="ForAnswer" size="30" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" class="pad_5"><strong>Email地址</strong>：<br />
        请输入有效的邮件地址</td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="Email" id="Email" size="30" maxlength="50" onBlur="checkEmailExits(this)" />          
      (<span class="style3">*</span>)
	  <span id="emailMsg"></span></td>
    </tr>
    <tr>
      <td height="32" colspan="2" bgcolor="#FFFFFF" class="pad_5">以下企业资料信息选择填写，注册成功后您可以从会员控制面板修改。</td>
    </tr>
    <tr>
      <td height="32" bgcolor="#FFFFFF" class="pad_5"><strong>缩略图：</strong></td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="Photo" type="text" id="Photo" size="50">
      <input type="button" name="Button" value="上传->" onClick="javascript:document.form1.Photo.value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"></td>
    </tr>
    <tr>
      <td height="32" bgcolor="#FFFFFF" class="pad_5"><strong>所属频道：</strong></td>
      <td bgcolor="#FFFFFF" class="pformleft">
      <select name="ChannelId" id="ChannelId">
      <%
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select id,title from catalogs where id<8 or id>10",conn,3,1
			while not rs.eof
				response.Write("<option value="""&rs(0)&""">"&rs(1)&"</option>")
				rs.movenext
			wend
			rs.close
			set rs=nothing
			%>
      </select></td>
    </tr>
    <tr>
      <td height="32" bgcolor="#FFFFFF" class="pad_5"><strong>企业名称：</strong></td>
      <td bgcolor="#FFFFFF" class="pformleft"><input name="ComName" type="text" id="ComName" size="30" maxlength="50" /></td>
    </tr>
    <tr>
      <td height="32" bgcolor="#FFFFFF" class="pad_5"><strong>企业性质：</strong></td>
    <td bgcolor="#FFFFFF" class="pformleft"><select name="ComType" id="ComType">
      <option value="个体经营">个体经营</option>
      <option value="企业单位" selected="selected">企业单位</option>
      <option value="事业单位或社会团体">事业单位或社会团体</option>
          </select></td>
    </tr>   
	  <tr>
	    <td height="32" bgcolor="#FFFFFF" class="pad_5"><strong>选择行业：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft">
      <select name="ParentId" id="ParentId" onChange="GetIndustryChilds(this.options[this.selectedIndex].value,0,'IndustryId')">
        <option value="0">一级行业分类</option>
        <script>document.write(GetIndustryFirst(<%=ParentId%>,''));</script>
      </select>
      <select name="IndustryId" id="IndustryId">
        <option value="0">二级行业分类</option>
      </select>
      <script type="text/javascript">
			GetIndustryChilds(<%=ParentId%>,<%=IndustryId%>,'IndustryId');
			</script>
      </td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>成立日期：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input type="text" name="CreateDate" id="CreateDate" /></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>联系人：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input type="text" name="ContactMan" id="ContactMan" /></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>地区：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft">
      <select name="Province" id="Province" onChange="GetChilds(this.options[this.selectedIndex].value,0,'City')">
        <option value="0">选择城市</option>
        <script>document.write(GetFirst(0,''));</script>
      </select>
      <select name="City" id="City">
        <option value="0">选择地区</option>
      </select>	
      </td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>经营范围：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><textarea name="BusinessScope" id="BusinessScope" cols="45" rows="5"></textarea></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>电话：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input type="text" name="Tel" id="Tel" /></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>传真：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input type="text" name="Fax" id="Fax" /></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>地址：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input type="text" name="Address" id="Address" /></td>
    </tr>
    <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>邮编：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input type="text" name="PostCode" id="PostCode" /></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>网址：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft"><input name="HomePage" type="text" id="HomePage" size="50" /></td>
    </tr>
	  <tr>
	    <td bgcolor="#FFFFFF" class="pad_5"><strong>公司简介：</strong></td>
	    <td bgcolor="#FFFFFF" class="pformleft">
      <INPUT type="hidden" name="content1" value="">
	    <IFRAME ID="eWebEditor1" src="webedit/editor.html" frameborder="0" scrolling="no" width="98%" height="350"></IFRAME>
      </td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#FFFFFF" class="row4"><div align="center">
        <input type="submit" name="Submit" value="注 册" />
        <input type="reset" name="Submit2" value="重 写" />
      </div></td>
    </tr>
  </table>
</form>
<%
	end if
%>
</body>
</html>
<%
call connclose()
%>          