function ProSetTypes(strValue)
{
	var objTemp
	objTemp=document.getElementById("mainPro_2");
	objTemp.readOnly=false;
	objTemp.style.background="#ffffff";
	objTemp=document.getElementById("mainBuy_2");
	objTemp.readOnly=false;
	objTemp.style.background="#ffffff";

	if(strValue=="seller")
	{
		objTemp=document.getElementById("mainBuy_2"); //mainBuy_2
		objTemp.readOnly=true;
		objTemp.style.background="#EEEEEE";
	}
	if(strValue=="buyer")
	{
		objTemp=document.getElementById("mainPro_2");
		objTemp.readOnly=true;
		objTemp.style.background="#EEEEEE";
	}
 


}
function ProInitCity(strId)
{

	var provinceName = ['重庆','广州','上海','东莞'];
	var provinceInt = ['17','4','3','16'];	
	var e = document.getElementById(strId);
	for (var i=0; i<provinceName.length; i++)
	{
		var newOption = document.createElement("OPTION"); 
		newOption.text=provinceName[i];
		newOption.value=provinceInt[i];
  　　 e.options.add(newOption); 

	}
}
function ProInitSf()
{

    var nows=new Date(); 
    var strUrl="NewRegCheckEnterprise.asp?strShowType=SF&tmp="+nows;

    var mAjaxer = new Ajaxer(strUrl,ProShowSf2,errorFunction2) ;
    mAjaxer.send();  

}

function ProShowSf2(strText)
{


	var strTemp;
	if(strText=="NONEDATA")
	{
		alert("读取省份资料出错或没有资料");
		return;
	}
	strText=strText.split("<ROW>");
	var e = document.getElementById("province_2");
	for(var i=0;i<strText.length;i++)
	{
		strTemp=strText[i];
		strTemp=strTemp.split("<COL>");
		var newOption = document.createElement("OPTION"); 
		newOption.text=strTemp[1];
		newOption.value=strTemp[0];
  　　 e.options.add(newOption); 

	}
}
function ProSelectSf(strId)
{
	var objType2=document.getElementById("city_2");	
	objType2.length=0;
	if(strId=="0")
	{
		var newOption = document.createElement("OPTION"); 
		newOption.text="请选择地区";
		newOption.value="0";
  　　 objType2.options.add(newOption); 		
  		return;
	}
	var nows=new Date(); 
    var strUrl="NewRegCheckEnterprise.asp?strShowType=DQ&tmp="+nows+"&sfid="+strId;
    var mAjaxer = new Ajaxer(strUrl,ProShowDq,errorFunction2) ;
    mAjaxer.send();  

}

function ProShowDq(strText)
{
	var e = document.getElementById("city_2");
	var strTemp;
	if(strText=="NONEDATA")
	{
		var newOption = document.createElement("OPTION"); 
		newOption.text="请选择地区";
		newOption.value="0";
  　　 e.options.add(newOption); 		
  		return;
		 
	}
	strText=strText.split("<ROW>");

	for(var i=0;i<strText.length;i++)
	{
		strTemp=strText[i];
		strTemp=strTemp.split("<COL>");
		var newOption = document.createElement("OPTION"); 
		newOption.text=strTemp[1];
		newOption.value=strTemp[0];
  　　 e.options.add(newOption); 

	}
}

 

function ProRegisterPersonal()
{
//	alert("注册个人会员");
	document.getElementById("div_showmsg").style.display="none";
	document.getElementById("div_EnterPriseRegister").style.display="none";
	document.getElementById("div_RegisterComplete").style.display="none";
document.getElementById("div_userRegister").style.display="";
}

function ProReturnMain()
{
		document.getElementById("div_showmsg").style.display="";
		document.getElementById("div_EnterPriseRegister").style.display="none";
		document.getElementById("div_userRegister").style.display="none";
		document.getElementById("div_RegisterComplete").style.display="none";
}


function ProRegisterEnterprise()
{
	document.getElementById("div_showmsg").style.display="none";
	document.getElementById("div_EnterPriseRegister").style.display="";
	document.getElementById("div_userRegister").style.display="none";
	document.getElementById("div_RegisterComplete").style.display="none";

}

function regcheck()
{
	var tempObj,tempObj2,tempObj3,strUrl;
	strUrl="";
	tempObj=document.getElementById("UserName");	
	if (tempObj.value=="")
	{
		alert("请输入用户名！");
		tempObj.focus();
		return false;
	}
	if((tempObj.value.length<3) || (tempObj.value.length>12))
	{
		alert("用户名长度在3 到 12之间！");
		tempObj.focus();
		return false;
		
	}
	strUrl=strUrl+"strUserName="+tempObj.value;
	
	tempObj=document.getElementById("Email");	
	if (tempObj.value=="")
	{
		alert("请输入Email地址！");
		tempObj.focus();
		return false;
	}
//check the email
 	if( ProCheckEmail(tempObj.value)==false)
	{
		alert("Email地址无效");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strEmail="+tempObj.value;
//
	
 
	
	tempObj=document.getElementById("Password");	
	if (tempObj.value=="")
	{
		alert("请输入用户密码！");
		tempObj.focus();
		return false;
	}
	tempObj=document.getElementById("Password");
	tempObj2=document.getElementById("PwdConfirm");
	if (tempObj.value!=tempObj2.value)
	{
		alert("两次输入的密码不一致，重新输入！");
		tempObj.focus();
		return false;
	}
	if(tempObj.value.length<6)
	{
		alert("密码长度不能少于 6");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strPassword="+tempObj.value;
	
	tempObj=document.getElementById("Question");
	if (tempObj.value=="")
	{
		alert("提示问题不能为空！");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strQuestion="+tempObj.value;

	tempObj=document.getElementById("Answer");
	if (tempObj.value=="")
	{
		alert("提示问题答案不能为空！");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strAnswer="+tempObj.value;
		
	tempObj=document.getElementById("UserReName");
	if (tempObj.value=="")
	{
		alert("联系人不能为空！");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strUserReName="+tempObj.value;
	
	tempObj=document.getElementById("UserAddRess");
	if (tempObj.value=="")
	{
		alert("联系地址不能为空！");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strUserAddRess="+tempObj.value;
	tempObj=document.getElementById("UserTelePhone");
	tempObj2=document.getElementById("UserMobile");
	tempObj3=document.getElementById("QQ");		
	if (tempObj.value=="" && tempObj2.value=="" && tempObj3.value=="")
	{
		alert("办公电话,手机号码,联系QQ请任选一项！");
		tempObj.focus();
		return false;
	}
	
	if(tempObj.value!="")
	{
		if(checkTel(tempObj.value)==false)
		{
			if(check_validate1(tempObj.value)==false)
			{
					if(checkTel2(tempObj.value)==false)
					{
						alert("办公电话无效,可以输入如:0755-1234567 或 13512345432 或 07551234567");
						tempObj.focus();
						return false;
					}
			}
		}
	}
	
	strUrl=strUrl+"&strUserTelePhone="+tempObj.value;
			
	if(tempObj2.value!="")
	{
		if(check_validate1(tempObj2.value)==false)
		{
			alert("手机号码只能输入数字");
			tempObj2.focus();
			return false;
		}
	
	}
	strUrl=strUrl+"&strUserMobile="+tempObj2.value;
		
	if(tempObj3.value!="")
	{
		if(check_validate1(tempObj3.value)==false)
		{
			alert("QQ号码只能输入数字");
			tempObj3.focus();
		return false;
		}
	}	
	strUrl=strUrl+"&strQQ="+tempObj3.value;
		
	tempObj=document.getElementById("div_ur_status");

	tempObj=document.getElementsByName("sex");

	for(var i=0;i<tempObj.length;i++)
	{
		if(tempObj[i].checked)
		{
				strUrl=strUrl+"&strSex="+tempObj[i].value;
		}
	}
	tempObj=document.getElementById("siteid");
	strUrl=strUrl+"&strSiteId="+tempObj.value;
	tempObj=document.getElementById("code");
	if(tempObj.value=="")
	{
		alert("请输入验证码");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strCode="+tempObj.value;
	
	tempObj=document.getElementById("MSN");
	strUrl=strUrl+"&strMsn="+tempObj.value;
	

	
//   tempObj.innerHTML="正在处理中..";
    var nows=new Date(); 
	

    strUrl="NewRegCheck.asp?types=PostUser&tmp="+nows+"&"+strUrl;
    var mAjaxer = new Ajaxer(strUrl,ProShowResult,errorFunction2) ;
    mAjaxer.send();  
}
function ProShowResult(strText)
{
	var tempObj;
	if(strText=="ERROR_WITH_CHECKERROR")
	{
		alert("验证码错误,请重新输入");
        tempObj=document.getElementById("code");
		tempObj.focus();
		return false;
	}
	if(strText=="ERROR_WITH_USEREXITS")
	{
		tempObj=document.getElementById("UserName");
		alert("用户"+tempObj.value+"已存在,请重新输入");
		tempObj.focus();
		return false;
	}
	if(strText=="ERROR_WITH_EMAILEXITS")
	{
		tempObj=document.getElementById("Email");
		alert("电子邮件"+tempObj.value+"已存在,请重新输入");
		tempObj.focus();
		return false;
	}
	if(strText=="ERROR_WIDTH_FAILSUBMIT")
	{
		alert("请注意，你是从外部非法注册，系统拒绝你的注册申请");
		return false;
	}
	
	if(strText=="ok")
	{
		tempObj=document.getElementById("UserName");
		alert("注册成功");
		var obj=document.getElementById("div_username");
		obj.innerHTML=tempObj.value;
		document.getElementById("div_showmsg").style.display="none";
		document.getElementById("div_EnterPriseRegister").style.display="none";
		document.getElementById("div_userRegister").style.display="none";
		document.getElementById("div_RegisterComplete").style.display="";

	}

	
}

function ProCheckEmail(strValue)
{
	var   regu   =   "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"  
        var   re   =   new   RegExp(regu);  
        if   (strValue.search(re)   !=   -1)    
        {  
              return   true;  
        }  
        else    
        {  
                return   false;  
        } 
}
function check_validate1(strValue)
{
 	strValue=strValue.replace(/[\d+]/ig,"")
	if(strValue.length>0)
		return false;
	return true;
} 

function   checkTel(strTemp)
{  
  var   re   =   /^(((\()?\d{2,4}(\))?[-(\s)*]){0,2})?(\d{7,8})$/;  
  if(re.test(strTemp))
  {  
	return true;
  }
  else
  {  
	return false;
  }  
 }   
function   checkTel2(strTemp)
{  
  var   re   =   /^(((\()?\d{2,4}(\))?[(\s)*]){0,2})?(\d{7,8})$/;  
  if(re.test(strTemp))
  {  
	return true;
  }
  else
  {  
	return false;
  }  
 }   


function errorFunction2(strError)
{
    alert(strError.code+strError.message);
}

 //////////////////////////
 var Ajaxer = function(URL,callBackFunction,errorFunction2,ProMethod,strPara)
{
    if(ProMethod==null)
    {
        this.AjaxMethod = "GET";                            //默认传输方式 POST;
    }
    else
    {
        this.AjaxMethod=ProMethod;
    }
    
    this.SendObject = null;                                //传输的内容，默认null    
    if(strPara!=null)
    {
        this.SendObject=strPara;
    }
    this.ResponseType = "Text";                        //返回值类型 
    this.Async = true;                                        //是否异步方式
    
    function createXMLHttp()
    {
        var xmlhttp;
        try
        {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (ex)
        {
            try
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (ex)
            {
                xmlhttp = new XMLHttpRequest();
            }
        }
        return xmlhttp;
    }
    var xmlHttp;    
     this.send =    function ()
    {
        xmlHttp = null;
        xmlHttp = createXMLHttp();
        if(xmlHttp == null)
        {
            alert("创建xmlHTTP失败！");
        }else
        {
            xmlHttp.onreadystatechange = this.SendBack;
            xmlHttp.open(this.AjaxMethod,URL,this.Async);
            if(this.SendObject!=null)
            {
                xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            }
            xmlHttp.send(this.SendObject);
        }
    }
    
    this.SendBack = function (){

        if(xmlHttp.readyState == 4){
            if(xmlHttp.status == 200){
                var res;
                res = xmlHttp.responseText;
                callBackFunction(res);                
            }else{
                var error = eval(error + "=" + "{\"code\":\"" + xmlHttp.status + "\",\"message\":\"" + xmlHttp.statusText + "\"}" );
                errorFunction2(error);
            }
        }
    }
}



function ProRegEnter()
{
	var tempObj,tempObj2,tempObj3,strUrl;
	strUrl="";
	tempObj=document.getElementById("loginid_2");	
	if (tempObj.value=="")
	{
		alert("请输入会员登陆名！");
		tempObj.focus();
		return false;
	}
	if((tempObj.value.length<4) || (tempObj.value.length>13))
	{
		alert("会员登陆名长度在4到12之间,请重新输入！");
		tempObj.focus();
		return false;
	}
	strUrl="&strUserName="+tempObj.value
	tempObj2=document.getElementById("password_2");	
	if((tempObj2.value.length<6) || (tempObj2.value.length>16))
	{
		alert("密码长度在6到16之间,请重新输入！");
		tempObj2.focus();
		return false;
	}
	if(tempObj2.value==tempObj.value)
	{
		alert("登陆名和密码不能相同,请重新输入");
		tempObj.focus();
		return false;
	}
	tempObj=document.getElementById("confirm_password_2");	
	if(tempObj2.value!=tempObj.value)
	{
		alert("密码和确认密码不一致,请重新输入");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strPassword="+tempObj2.value
	tempObj2=document.getElementById("confirm_question_2");	
	if(tempObj2.value=="")
	{
		alert("请选择密码提示问题");
		tempObj2.focus();
		return false;
	}
	strUrl=strUrl+"&strUserQuesion="+tempObj2.value
		
	tempObj=document.getElementById("confirm_answer_2");	
	if(tempObj.value=="")
	{
		alert("密码提示答案不能空");
		tempObj.focus();
		return false;
	}
	strUrl=strUrl+"&strUserAnswer="+tempObj.value
	
	if(tempObj.value==tempObj2.value)
	{
		alert("密码提示答案不能与密码提示问题和登录名相同");
		tempObj.focus();
		return false;
	}
	tempObj3=document.getElementById("loginid_2");	
	if(tempObj.value==tempObj3.value)
	{
		alert("密码提示答案不能与密码提示问题和登录名相同");
		tempObj.focus();
		return false;
	}

	tempObj3=document.getElementById("first_name_2");	
	if(tempObj3.value=="")
	{
		alert("请输入真实姓名");
		tempObj3.focus();
		return false;
	}
	strUrl=strUrl+"&strUserReName="+tempObj3.value;
	tempObj3=document.getElementById("job_title_2");	
	if(tempObj3.value=="")
	{
		alert("填写所在部门和职务");
		tempObj3.focus();
		return false;
	}
	tempObj3=document.getElementById("email_2");	
	if(tempObj3.value=="")
	{
		alert("请填写电子邮件地址");
		tempObj3.focus();
		return false;
	}
	
	if( ProCheckEmail(tempObj3.value)==false)
	{
		alert("Email地址无效");
		tempObj3.focus();
		return false;
	}
	strUrl=strUrl+"&strEmail="+tempObj3.value
	tempObj3=document.getElementById("phone_number_2");	
	if(tempObj3.value=="")
	{
		alert("请填写有效的固定电话");
		tempObj3.focus();
		return false;
	}
	if(checkTel(tempObj3.value)==false)
	{
			if(check_validate1(tempObj3.value)==false)
			{
					if(checkTel2(tempObj3.value)==false)
					{
						alert("固定电话无效,可以输入如:0755-1234567 或 13512345432 或 07551234567");
						tempObj3.focus();
						return false;
					}
			}
	}
		
	strUrl=strUrl+"&strUserTelephone="+tempObj3.value;
		
	tempObj3=document.getElementById("mobile_2");	
 	if(tempObj3.value.length>0)
	{
		if(check_validate1(tempObj3.value)==false)
		{
			alert("手机号码只能输入数字");
			tempObj3.focus();
			return false;
		}
	}
	strUrl=strUrl+"&strUserMobile="+tempObj3.value;
	
	tempObj3=document.getElementById("company_2");	
	if(tempObj3.value=="")
	{
		alert("请填写贵公司的名称");
		tempObj3.focus();
		return false;
	}
	tempObj3=document.getElementById("province_2");	
	if(tempObj3.value=="0")
	{
		alert("请选择有效的省份");
		tempObj3.focus();
		return false;
	}
	strUrl=strUrl+"&strCityInfo="+tempObj3.value+",";
	tempObj3=document.getElementById("city_2");	
	strUrl=strUrl+tempObj3.value;
		
	tempObj3=document.getElementById("address_2");	
	if(tempObj3.value=="")
	{
		alert("请填写有效的经营地址");
		tempObj3.focus();
		return false;
	}
	tempObj3=document.getElementById("code_2");	
	if(tempObj3.value=="")
	{
		alert("请填写有效的验证码");
		tempObj3.focus();
		return false;
	}
	strUrl=strUrl+"&strCode="+tempObj3.value;

	tempObj3=document.getElementById("QQ_2");	
	strUrl=strUrl+"&strQQ="+tempObj3.value;
	
	tempObj3=document.getElementById("MSN_2");	
	strUrl=strUrl+"&strMsn="+tempObj3.value;
	
	tempObj3=document.getElementById("address_2");	
	strUrl=strUrl+"&strUserAddRess="+tempObj3.value;

	tempObj3=document.getElementById("company_2");	
	strUrl=strUrl+"&strCMName="+tempObj3.value;
	
	tempObj3=document.getElementById("model_2");	
	strUrl=strUrl+"&strCmbus="+tempObj3.value;

	tempObj3=document.getElementById("siteid_2");	
	strUrl=strUrl+"&strSiteid="+tempObj3.value;


	tempObj3=document.getElementById("mainPro_2");	
	strUrl=strUrl+"&strCmMain="+tempObj3.value;
	tempObj3=document.getElementById("mainBuy_2");	
	strUrl=strUrl+","+tempObj3.value;
	
	tempObj=document.getElementsByName("male_2");
	for(var i=0;i<tempObj.length;i++)
	{
		if(tempObj[i].checked)
		{
				strUrl=strUrl+"&strSex="+tempObj[i].value;
		}
	}
	

    var nows=new Date(); 
    strUrl="NewRegCheckEnterprise.asp?strShowType=Registers&tmp="+nows+strUrl;
    var mAjaxer = new Ajaxer(strUrl,ProShowResult_enterprise,errorFunction2) ;
    mAjaxer.send(); 
}
function ProShowResult_enterprise(strText)
{
	var tempObj;
	if(strText=="ERROR_WIDTH_FAILSUBMIT")
	{
		alert("请注意，你是从外部非法注册，系统拒绝你的注册申请");
		return false;
	}

	if(strText=="ERROR_WITH_CHECKERROR")
	{
		alert("验证码错误,请重新输入");
        tempObj=document.getElementById("code_2");
		tempObj.focus();
		return false;
	}
	if(strText=="ERROR_WITH_USEREXITS")
	{
		tempObj=document.getElementById("loginid_2");
		alert("会员登陆名"+tempObj.value+"已存在,请重新输入");
		tempObj.focus();
		return false;
	}
	if(strText=="ERROR_WITH_EMAILEXITS")
	{
		tempObj=document.getElementById("email_2");
		alert("电子邮件"+tempObj.value+"已存在,请重新输入");
		tempObj.focus();
		return false;
	}
	tempObj=document.getElementById("loginid_2");
	if(strText=="ok")
	{
		alert("注册成功"); //div_username
		var obj=document.getElementById("div_username");
		obj.innerHTML=tempObj.value;
		document.getElementById("div_showmsg").style.display="none";
		document.getElementById("div_EnterPriseRegister").style.display="none";
		document.getElementById("div_userRegister").style.display="none";
		document.getElementById("div_RegisterComplete").style.display="";

	}
}
 