
function yonghuming(){
	var chk=true;
var user=document.getElementById("uesr").value
    document.getElementById("yonghu").src="yonghuming.asp?user="+user
	
	if (user.length<4||user.length>12)
	
	{chk=false;
	   document.getElementById("yangzheng").className="d_err";

	}
	
	
	return chk;
} 


var xmlHttp = false;
try {
 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
 try {
 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (e2) {
 xmlHttp = false;
 }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
 xmlHttp = new XMLHttpRequest();
}
function passcheck() {
	var chk=true;
 var u_pass = document.getElementById("u_pass").value;
 var u_pass1 = document.getElementById("u_pass1").value;
 if(u_pass.length<4||u_pass.length>12){
 chk=false;
 document.getElementById("u_pass1").disabled=true;
 PwdMsg.innerHTML="<font color=#ff0000>密码要求4-12个字符</font>";
    document.getElementById("PwdMsg").className="d_err";
 if (u_pass1.length<1)
 {
	  chk=false;
	  RePwdMsg.innerHTML="<font color=#ff0000>请再次输入密码</font>";
   document.getElementById("RePwdMsg").className="d_err";
 }
 }else{
 document.getElementById("u_pass1").disabled=false; 
 PwdMsg.innerHTML="密码正确";
  document.getElementById("PwdMsg").className="d_ok";
 if(u_pass!=u_pass1){
 chk=false;
   document.getElementById("RePwdMsg").className="d_err";
 RePwdMsg.innerHTML="<font color=#ff0000>再次输入密码与原密码不同</font>";
 }
  else{
 document.getElementById("u_sub").disabled=false;
 RePwdMsg.innerHTML="密码重复正确";
  document.getElementById("RePwdMsg").className="d_ok";
 } }
 return chk;
}

function exist_Chr(theValue)
	{
		var compChr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
		var strLen=theValue.length;
		for (var i=0;i<strLen;i++){
			var temp1=compChr.indexOf(theValue.charAt(i));
			if(temp1==-1) 
			{
				return 1;
			}
		}
		return 0;
	}


//密码强度;
function PasswordStrength(showed){  
  this.showed = (typeof(showed) == "boolean")?showed:true;
  this.styles = new Array();  
  this.styles[0] = {backgroundColor:"#EBEBEB",borderLeft:"solid 1px #FFFFFF",borderRight:"solid 1px #BEBEBE",borderBottom:"solid 1px #BEBEBE"};  
  this.styles[1] = {backgroundColor:"#F00",borderLeft:"solid 1px #FFFFFF",borderRight:"solid 1px #BB2B2B",borderBottom:"solid 1px #BB2B2B"};
  this.styles[2] = {backgroundColor:"#FD1",borderLeft:"solid 1px #FFFFFF",borderRight:"solid 1px #E9AE10",borderBottom:"solid 1px #E9AE10"};
  this.styles[3] = {backgroundColor:"#0F0",borderLeft:"solid 1px #FFFFFF",borderRight:"solid 1px #3BBC1B",borderBottom:"solid 1px #3BBC1B"};
  
  this.labels= ["密码强度弱","密码强度中","密码强度高"];

  this.divName = "pwd_div_"+Math.ceil(Math.random()*100000);
  this.minLen = 4;
  
  this.width = "300px";
  this.height = "18px";
  
  this.content = "";
  
  this.selectedIndex = 0;
  
  this.init();  
}
PasswordStrength.prototype.init = function(){
  var s = '<table cellpadding="0" id="'+this.divName+'_table" cellspacing="0" style="width:'+this.width+';height:'+this.height+';">';
  s += '<tr>';
  for(var i=0;i<3;i++){


    s += '<td id="'+this.divName+'_td_'+i+'" width="33%" align="center"><span style="font-size:1px">&nbsp;</span><span id="'+this.divName+'_label_'+i+'" style="display:none;font-family: Courier New, Courier, mono;font-size: 12px;color: #000000;">'+this.labels[i]+'</span></td>';
  }  
  s += '</tr>';
  s += '</table>';
  this.content = s;
  if(this.showed){
    document.write(s);
    this.copyToStyle(this.selectedIndex);
  }  
}
PasswordStrength.prototype.copyToObject = function(o1,o2){
  for(var i in o1){
    o2[i] = o1[i];
  }
}
PasswordStrength.prototype.copyToStyle = function(id){
  this.selectedIndex = id;
  for(var i=0;i<3;i++){
    if(i == id-1){
      this.$(this.divName+"_label_"+i).style.display = "inline";
    }else{
      this.$(this.divName+"_label_"+i).style.display = "none";
    }
  }
  for(var i=0;i<id;i++){
    this.copyToObject(this.styles[id],this.$(this.divName+"_td_"+i).style);      
  }
  for(;i<3;i++){
    this.copyToObject(this.styles[0],this.$(this.divName+"_td_"+i).style);
  }
}
PasswordStrength.prototype.$ = function(s){
  return document.getElementById(s);
}
PasswordStrength.prototype.setSize = function(w,h){
  this.width = w;
  this.height = h;
}
PasswordStrength.prototype.setMinLength = function(n){
  if(isNaN(n)){
    return ;
  }
  n = Number(n);
  if(n>1){
    this.minLength = n;
  }
}
PasswordStrength.prototype.setStyles = function(){
  if(arguments.length == 0){
    return ;
  }
  for(var i=0;i<arguments.length && i < 4;i++){
    this.styles[i] = arguments[i];
  }
  this.copyToStyle(this.selectedIndex);
}
PasswordStrength.prototype.write = function(s){
  if(this.showed){
    return ;
  }
  var n = (s == 'string') ? this.$(s) : s;
  if(typeof(n) != "object"){
    return ;
  }
  n.innerHTML = this.content;
  this.copyToStyle(this.selectedIndex);
}
PasswordStrength.prototype.update = function(s){
  if(s.length < this.minLen){
    this.copyToStyle(0);
    return;
  }
  var ls = -1;
  if (s.match(/[a-z]/ig)){
    ls++;
  }
  if (s.match(/[0-9]/ig)){
    ls++;
  }
   if (s.match(/(.[^a-z0-9])/ig)){
    ls++;
  }
  if (s.length < 6 && ls > 0){
    ls--;
  }
   switch(ls) { 
     case 0:
       this.copyToStyle(1);
       break;
     case 1:
       this.copyToStyle(2);
       break;
     case 2:
       this.copyToStyle(3);
       break;
     default:
       this.copyToStyle(0);
   }
}
function turenamecheck()
{ 
var a = document.getElementById("turename").value;
var chk=true;
if(a.length<2){
chk=false;
 document.getElementById("trnameMsg").className="d_err";
trnameMsg.innerHTML="<font color=#ff0000>请输入个人真实姓名</font>";
 }else{
 fibdn = new Array ("@","$","%","&","!","*","#");
 i=fibdn.length;
 j=a.length;
 for (ii=0;ii<i;ii++)
 { for (jj=0;jj<j;jj++)
  { temp1=a.charAt(jj);
   temp2=fibdn[ii];
   if (temp1==temp2)
   {  chk=false;
    document.getElementById("trnameMsg").className="d_err";
              trnameMsg.innerHTML="<font color=#ff0000>有非法字符,请输入正确的个人真实姓名</font>"; 
             }
  }
 }
 		document.getElementById("trnameMsg").className="d_ok";
         trnameMsg.innerHTML="个人真实姓名输入正确";
		 return chk;
         
}}
function depcheck()
{ var chk=true;
var a = document.getElementById("dep").value;
if(a.length<2){
 chk=false;
 document.getElementById("depMsg").className="d_err";
 depMsg.innerHTML="<font color=#ff0000>请输入个人所在部门</font>";
 }else{
 fibdn = new Array ("@","$","%","&","!","*","#");
 i=fibdn.length;
 j=a.length;
 for (ii=0;ii<i;ii++)
 { for (jj=0;jj<j;jj++)
  { temp1=a.charAt(jj);
   temp2=fibdn[ii];
   if (temp1==temp2)
   {  
   chk=false;
   document.getElementById("depMsg").className="d_err";
              depMsg.innerHTML="<font color=#ff0000>有非法字符,请输入正确的个人所在部门</font>"; 
             }
  }
 }
 document.getElementById("depMsg").className="d_ok";
         depMsg.innerHTML="个人所在部门输入正确";
		 return chk;
         
}}
function mobcheck()
{var chk=true;
var kf=0;
 var d,i,j,strTemp;
 dd = document.getElementById("mobi2").value;
 strTemp="0123456789";
 if ( dd.length<11)
{
	document.getElementById("mobmsg").className="d_err";
  chk=false;
  mobmsg.innerHTML="<font color=#ff0000>请输入完整的手机号</font>";}
  else
  {
	  
	  
 for (i=0;i<dd.length;i++)
 {
  j=strTemp.indexOf(dd.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字
  kf=1;
  }
  
 }
 
 
 if (kf==1)
 {
	  chk=false;
	  document.getElementById("mobmsg").className="d_err";
   mobmsg.innerHTML="<font color=#ff0000>手机号只能输入数字</font>";
 }
 else
 document.getElementById("mobmsg").className="d_ok";
 {mobmsg.innerHTML="手机号输入正确";
 }
 
 
  }
 //说明是数字
 return chk;
}


function leixingcheck()
{ var chk=true;
var a = document.getElementById("leixing").value;
if(a.length<=0){
 chk=false;
 document.getElementById("leixingMsg").className="d_err";
leixingMsg.innerHTML="<font color=#ff0000>请选择公司类型</font>";
 }
 else{
	  document.getElementById("leixingMsg").className="d_ok";
         leixingMsg.innerHTML="选择公司类型正确";
 }
 return chk;
}
function sexcheck()
{ var chk=true;
var a = document.getElementById("sex").value;
if(a.length<=0){
 chk=false;
 document.getElementById("sexMsg").className="d_err";
sexMsg.innerHTML="<font color=#ff0000>请选择性别</font>";
 }
 else{
	  document.getElementById("sexMsg").className="d_ok";
         sexMsg.innerHTML="选择性别正确";
 }
 return chk;
}
function xingzhicheck()
{ var chk=true;
document.getElementById("xingzhiMsg").className="d_err";
var a = document.getElementById("xingzhi").value;
if(a.length<=0){
 chk=false;
xingzhiMsg.innerHTML="<font color=#ff0000>请选择公司性质</font>";
 }
 else{
document.getElementById("xingzhiMsg").className="d_ok";
xingzhiMsg.innerHTML="选择公司性质正确";
 }
 return chk;
}
function tycheck(){
	var obj=document.getElementById("tyMsg");
	var chk=true;
	
	if (!document.main.ty.checked){
		chk=false;
}
if (chk){
		
		obj.innerHTML='<font color="#999999">我已看过并同意接受stonenic.com的</font><font color="#FF0000">服务条款</font>';
	}else{
				obj.innerHTML='<font color=#ff0000>你未同意同意接受stonenic.com的注册条款。</font>';
	}
	//alert(chk);
	
	return chk;
}
function moshicheck()
{ var chk=true;
var a = document.getElementById("moshi").value;
if(a.length<=0){
 chk=false;
 document.getElementById("moshiMsg").className="d_err";
moshiMsg.innerHTML="<font color=#ff0000>请选择公司经营模式</font>";
 }
 else{
 document.getElementById("moshiMsg").className="d_ok";
        moshiMsg.innerHTML="选择公司经营模式正确";
 }
 return chk;
}
function farencheck()
{ var chk=true;
var k=0;
var a = document.getElementById("faren").value;
if(a.length<2){
document.getElementById("farenMsg").className="d_err";
 chk=false;
 farenMsg.innerHTML="<font color=#ff0000>请输入完整的法人代表</font>";
 }else{
 fibdn = new Array ("@","$","%","&","!","*","#");
 i=fibdn.length;
 j=a.length;
 for (ii=0;ii<i;ii++)
 { for (jj=0;jj<j;jj++)
  { temp1=a.charAt(jj);
   temp2=fibdn[ii];
   if (temp1==temp2)
   { k=1;
             }
  }
 }
if (k==1)
{chk=false; 
document.getElementById("farenMsg").className="d_err";
             farenMsg.innerHTML="<font color=#ff0000>有非法字符,请输入正确的法人代表</font>"; 
}
else
{ document.getElementById("farenMsg").className="d_ok";
farenMsg.innerHTML="法人代表输入正确";
}
         
}

return chk;}

function namecheck()
{ var k=0;
var chk=true;
var a = document.getElementById("com_name").value;
if(a.length<2){
 chk=false;
 document.getElementById("RenameMsg").className="d_err";
 RenameMsg.innerHTML="<font color=#ff0000>请输入完整的企业名称或个人姓名</font>";
 }else{
 fibdn = new Array ("@","$","%","&","!","*","#");
 i=fibdn.length;
 j=a.length;
 for (ii=0;ii<i;ii++)
 { for (jj=0;jj<j;jj++)
  { temp1=a.charAt(jj);
   temp2=fibdn[ii];
   if (temp1==temp2)
   { 
k=1 ;            }
  }
}

if (k==1)
{chk=false; 
 document.getElementById("RenameMsg").className="d_err";
             RenameMsg.innerHTML="<font color=#ff0000>有非法字符,请输入正确的企业名称或个人姓名</font>"; 
}
else
{ document.getElementById("RenameMsg").className="d_ok"; 
RenameMsg.innerHTML="企业名称输入正确";


}         
} return chk;
}
function linkcheck()
{ var chk=true;
var kg=0;
var a = document.getElementById("link").value;
if(a.length<2){
	chk=false;
	document.getElementById("RelinkMsg").className="d_err";
 RelinkMsg.innerHTML="<font color=#ff0000>请输入完整的联系人姓名</font>";
 }else{
 fibdn = new Array ("@","$","%","&","!","*","#"," ");
 i=fibdn.length;
 j=a.length;
 for (ii=0;ii<i;ii++)
 { for (jj=0;jj<j;jj++)
  { temp1=a.charAt(jj);
   temp2=fibdn[ii];
   if (temp1==temp2)
   { kg=1; }
  }
 }
 if (kg==1) {
	 chk=false;
   document.getElementById("RelinkMsg").className="d_err";
   RelinkMsg.innerHTML="<font color=#ff0000>有非法字符,请输入完整联系人姓名</font>";
 }
 else
 {
	 document.getElementById("RelinkMsg").className="d_ok";
	 RelinkMsg.innerHTML="联系人名输入正确";
 }
return chk;
}}
function telcheck()
{var chk=true;
var kc=0;
 var b,i,j,strTemp;
 b = document.getElementById("tel").value;
 strTemp="0123456789 ";
 if ( b.length<11)
 {
	 document.getElementById("RetelMsg").className="d_err";
 chk=false;
 RetelMsg.innerHTML="<font color=#ff0000>电话号码要求输入区号和电话号码</font>";}
 else
 {	 
 for (i=0;i<b.length;i++)
 {
  j=strTemp.indexOf(b.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字
 kc=1;
  }
 }
 if (kc==1)
 {  chk=false;
  document.getElementById("RetelMsg").className="d_err";
  RetelMsg.innerHTML="<font color=#ff0000>电话号码只能输入数字或空格</font>";
 }
 else
 {   document.getElementById("RetelMsg").className="d_ok";
 RetelMsg.innerHTML="电话号码输入正确";
 } 
 }
 return chk;
}
function faxcheck()
{var chk=true;
var kk=0;
 var c,i,j,strTemp;
 c = document.getElementById("fax").value;
 strTemp="0123456789";
 if ( c.length<11)
{ chk=false;
document.getElementById("RefaxMsg").className="d_err";
 RefaxMsg.innerHTML="<font color=#ff0000>传真要求输入区号和电话号码</font>";}
 else{
 for (i=0;i<c.length;i++)
 {
  j=strTemp.indexOf(c.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字
  kk=1;

  }
 }if (kk==1)
 { chk=false;
 document.getElementById("RefaxMsg").className="d_err";
 RefaxMsg.innerHTML="<font color=#ff0000>传真只能输入数字</font>";
 }
 else
 { document.getElementById("RefaxMsg").className="d_ok";
 RefaxMsg.innerHTML="传真输入正确";
 }}
 
 //说明是数字
  return chk;
}
function mobicheck()


{var chk=true;
var kf=0;
 var d,i,j,strTemp;
 dd = document.getElementById("mobi").value;
 strTemp="0123456789";
 if ( dd.length<11)
{
	document.getElementById("RemobiMsg").className="d_err";
  chk=false;
  RemobiMsg.innerHTML="<font color=#ff0000>请输入完整的手机号</font>";}
  else
  {
	  
	  
 for (i=0;i<dd.length;i++)
 {
  j=strTemp.indexOf(dd.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字
  kf=1;
  }
  
 }
 
 
 if (kf==1)
 {
	  chk=false;
	  document.getElementById("RemobiMsg").className="d_err";
   RemobiMsg.innerHTML="<font color=#ff0000>手机号只能输入数字</font>";
 }
 else
 document.getElementById("RemobiMsg").className="d_ok";
 {RemobiMsg.innerHTML="手机号输入正确";
 }
 
 
  }
 //说明是数字
 return chk;
}



function addresscheck()
{var chk=true;
 var g = document.getElementById("address").value;
 if ( g.length<4){
	 chk=false;
	 document.getElementById("ReaddressMsg").className="d_err";
  ReaddressMsg.innerHTML="<font color=#ff0000>请输入有效的联系地址</font>";
  } else
  {
	   document.getElementById("ReaddressMsg").className="d_ok";
  ReaddressMsg.innerHTML="联系地址输入正确";
  }
  return chk;
  }
  function mailcheck()  
　　　　　{  var chk=true;
　　　　　　var h = document.getElementById("mail").value; 
　　　　　　var pattern = /^([a-zA-Z0-9_-])+([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;  
　　　　　　flag = pattern.test(h);  
　　　　　　if(flag)  
　　　　　　{  
 document.getElementById("RemailMsg").className="d_ok";
　　　　　　　RemailMsg.innerHTML="邮箱输入正确";
　　　　　　}  
　　　　　　else  
　　　　　　　{  
　　　　　　　　RemailMsg.innerHTML="<font color=#ff0000>邮箱输入错误</font>";
　　　　　　　　chk=false; 
 document.getElementById("RemailMsg").className="d_err";
　　　　　　　 }  
return chk;
　　　　　 } 
function webcheck()
{var chk=true;
 var  e = document.getElementById("web").value;
 if ( e.length<11){
	 chk=false;
	  document.getElementById("RewebMsg").className="d_err";
 RewebMsg.innerHTML="<font color=#ff0000>请输入你公司的网址</font>";
 }
 else{
	  document.getElementById("RewebMsg").className="d_ok";
  RewebMsg.innerHTML="网址输入正确";
}
return chk;
}
function uscheck()
{var chk=true;
 var  h = document.getElementById("us").value;
 if ( h.length<30 || h.length>800 ){
 chk=false;
 document.getElementById("ReusMsg").className="d_err";
 ReusMsg.innerHTML="<font color=#ff0000>请填写企业的简介（30～800个汉字）</font>";
 }
 else{
	 document.getElementById("ReusMsg").className="d_ok";
  ReusMsg.innerHTML="企业的简介输入正确";
}
return chk;
}
function out_Povince(){
	var chk=true;
	var obj=document.getElementById("d_Povince");
	var str1=document.getElementById("Povince").value;
	var str2=document.getElementById("City").value;
	var str3=document.getElementById("Area").value;	
	if (str1==9999||str2==9999||str3==9999){chk=false}
		if (str1=="请选择"){chk=false}
	if (chk){
		obj.className="d_ok";
		obj.innerHTML="选择地区正确";
	}else{
		chk=false;
		obj.className="d_err";
		obj.innerHTML="<font color=#ff0000>选择地区错误，请你重新选择！</font>";
	}
	return chk;
}
function chk_reg(){
	var chk=true
	if (!yonghuming()){chk=false}
	if (!passcheck()){chk=false}
	if (!turenamecheck()){chk=false}
	if (!sexcheck()){chk=false}
	if (!depcheck()){chk=false}
	if (!mobcheck()){chk=false}
	if (!mobicheck()){chk=false}
	if (!namecheck()){chk=false}
	if (!leixingcheck()){chk=false}
	if (!xingzhicheck()){chk=false}
	if (!moshicheck()){chk=false}
	if (!farencheck()){chk=false}
	if (!out_Povince()){chk=false}
	if (!uscheck()){chk=false}						
	if (!webcheck()){chk=false}	
	if (!mailcheck()){chk=false}
	if (!telcheck()){chk=false}
	if (!telcheck()){chk=false}
	if (!faxcheck()){chk=false}
	if (!addresscheck()){chk=false}
	if (!linkcheck()){chk=false}
	if (!tycheck()){chk=false}
	
if(chk){
	
	document.getElementById('u_sub').disabled='disabled';
	document.main.submit();
	return true;
	//reset_code();
	}
		return false;
}
