function checkForm(theForm,prefix)
{
	var txtT=prefix;
	if(typeof(eval("theForm."+txtT+"Organization_GB"))=='undefined')   return true;

	eval("var Organization_GB=theForm."+txtT+"Organization_GB");
	eval("var Organization=theForm."+txtT+"Organization");
	eval("var Name_GB=theForm."+txtT+"Name_GB");
	eval("var Name=theForm."+txtT+"Name");
	eval("var CC=theForm."+txtT+"CC");
	eval("var SP=theForm."+txtT+"SP");
	eval("var City=theForm."+txtT+"City");
	eval("var Street=theForm."+txtT+"Street");
	eval("var Street1=theForm."+txtT+"Street1");
	eval("var PC=theForm."+txtT+"PC");
	eval("var Tel=theForm."+txtT+"Tel");
	eval("var Mobile=theForm."+txtT+"Mobile");
	eval("var Fax=theForm."+txtT+"Fax");
	eval("var Email=theForm."+txtT+"Email");
	//eval("var Reference=theForm."+txtT+"Reference");

  Organization_GB.value=trim(Organization_GB.value);  
  Organization.value=trim(Organization.value);
  Name_GB.value=trim(Name_GB.value);  
  Name_GB.value=trim(Name_GB.value);  
  Name.value=trim(Name.value);
  CC.value=trim(CC.value).toUpperCase();
  SP.value=trim(SP.value);    
  City.value=trim(City.value);
  Street.value=trim(Street.value);
  Street1.value=trim(Street1.value);
  PC.value=trim(PC.value);
  Tel.value=trim(Tel.value);
  Fax.value=trim(Fax.value);
  Email.value=trim(Email.value);
  Mobile.value = trim(Mobile.value);
  //Reference.value=trim(Reference.value);
  if (Name_GB.value == "")  {  alert("请填写您的姓名(中文)");    Name_GB.focus();    return false; }
  if (!IsHaveChinese(Name_GB.value))  {     alert("您的姓名中没有任何中文字符");    Name_GB.focus();    return (false);  }

  if (specialchar(Name_GB.value))  { alert("含有系统不允许的字符 ' 或 字符;");  Name_GB.focus();    return (false);   }
  if (Organization_GB.value == ""){ alert("请输入注册组织(中文)");   Organization_GB.focus();   return (false);  }
  if (!IsHaveChinese(Organization_GB.value)){ alert("注册组织(中文)没有任何中文字符");   Organization_GB.focus();   return (false);}
  if(Organization_GB.value.length<2) { alert("注册组织(中文)必须为2个以上的中文");   Organization_GB.focus();   return (false);  }
  if(CC.value==""){  alert("请选择国家");    CC.focus();    return (false);  }
  if (specialchar(CC.value))  { alert("含有系统不允许的字符 ' 或 字符;");    CC.focus(); return (false);   }
  if (/^[A-Z]{2,2}$/.test(CC.value)==false){alert("国家只能由两位大写英文字母组成");    CC.focus();    return (false); }


  if(SP.value=="")
  {  
	  alert("请输入所在的省份"); 
      if(SP.style.display!="none") SP.focus()
	  if(theForm.SSP.style.display!="none") theForm.SSP.focus()
      return (false);  
  }
  if (specialchar(SP.value))  { alert("含有系统不允许的字符 ' 或 字符;");    SP.focus(); return (false);   }
  if(City.value==""){  alert("请输入所在的城市");    City.focus();    return (false);  }
  if(specialchar(City.value))  { alert("含有系统不允许的字符 ' 或 字符;");    City.focus(); return (false);   } 
  if(Street1.value==""){  alert("请输入通信地址(中文)");    Street1.focus();    return (false);  }
  
  if(!IsHaveChinese(Street1.value)){  alert("通信地址没有任何中文字符");    Street1.focus();    return (false);  }
  
  if(specialchar(Street1.value))  { alert("含有系统不允许的字符 ' 或 字符;");    Street1.focus(); return (false);   }
  
  if(specialchar(Street.value))  { alert("含有系统不允许的字符 ' 或 字符; ");    Street.focus(); return (false);   }

  if(checkchinese(Street.value))  {    alert("通信地址址(英文)只能输入英文字母");  Street.focus();    return (false); }
  if(Tel.value==""){  alert("请输入您的电话号码");    Tel.focus();    return (false);  }
  if(/^(\+[0-9]{1,4}\.){0,1}[0-9\-]{5,15}$/.test(Tel.value)==false){alert("您输入的电话号码格式不正确,请重新输入!");Tel.focus();return(false);}
  if(Mobile.value==""){ alert("请输入您的手机号码123");    Mobile.focus();    return (false);}
  if(/^\+[0-9]{2,3}\.1[3,5,8]{1}[0-9]{1}[0-9]{8}/.test(Mobile.value)==false){alert("您输入的移动电话号码格式不正确,请重新输入!");Mobile.focus();return(false);}
  if(!checkEmail(Email.value)){ alert("请您输入正确的email地址");Email.focus();return (false);}

  if (theForm.VHostProtocol1 && !theForm.VHostProtocol1.checked){  alert("确认已阅读并接受会员注册条款协议！ "); theForm.VHostProtocol1.focus(); return (false);   }
  if (theForm.VHostProtocol2 && !theForm.VHostProtocol2.checked){  alert("确认已阅读并接受虚拟主机(空间)租用协议！ "); theForm.VHostProtocol2.focus(); return (false);   }
  if (theForm.VHostProtocol3 && !theForm.VHostProtocol3.checked){  alert("确认已阅读并接受虚拟主机(空间)租用协议！ "); theForm.VHostProtocol3.focus(); return (false);   }
 /* 
  if(Reference.value != "")
  {
	  if(havenoNumber(Reference.value))
  	  {
		alert("请填写推荐人在我司的ID号");
		return false;
  	  }
	  writeCookie("reference",Reference.value,0.5);
  }*/

  return true

} 


function trim(str){
  str=str.replace(/^ {1,}/g,"");
  str=str.replace(/ {1,}$/g,"");
  return str;
 }


 function IsHaveChinese(theelement){
   for(i=0;i<theelement.length;i++){
       if(theelement.charCodeAt(i)>127) return true;
   }
   return false;
}


 function specialchar(theelement){// 特殊字付 ' ;
   text = "';"
   for(i=0;i<=theelement.length-1;i++)
   {  char1=theelement.charAt(i); index=text.indexOf(char1); if(index>=0){ return true;} }
   return false;
}

 function isContainsDigital(strNameEN) { //判读文本框中是否包含数字
	 text ="1234567890";
	 for(i=0;i<=strNameEN.length-1;i++) {
		 char1 = strNameEN.charAt(i);
		 index = text.indexOf(char1);
		 if(index > 0) return true; //包含数字
	 }
	 return false;
 }

function checkchinese(theelement){//如果含有中文字符返回 true
   text="abcdefghijklmnopqrstuvwxyz1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ,/()!@$%&\#*~.;'_-";
   for(i=0;i<=theelement.length-1;i++)
   {
      char1=theelement.charAt(i);
      index=text.indexOf(char1);
      if(index==-1)
      { return true;//有中文
      }  
     //没有中文
   }
   return false;
}

function checkEmail(theelement)
{
   var emal="@";
   for(i=0;i<=theelement.length-1;i++)
   {
     char1=theelement.charAt(i);
     if(char1==emal)return  true;
   }
   return false;
}

function writeCookie(name, value, hours)
{
	var expire = "";
	if(hours != null)
	{
	expire = new Date((new Date()).getTime() + hours * 3600000);
	expire = "; expires=" + expire.toGMTString();
	
	}
	document.cookie = name + "=" + escape(value) + expire;
}
function havenoNumber(theelement)
{//含有非数字字符 返回 true
   text="1234567890 ";
   for(i=0;i<=theelement.length-1;i++)
   {
	  char1=theelement.charAt(i);
	  index=text.indexOf(char1);
	  if(index==-1)
	  {return true; }
   }
   return false;
}


function GetCity(Provinceval)
{
			//alert(Provinceval);
			$.ajax
			(
				{url: 'AjaxGetCitys.net',  
				type: 'POST',  
				data:{values:Provinceval},  
				dataType: 'html',  
				timeout: 10000,  
				error: function(){},  
				success: function(result)
				{
	
					var strReturnCitys=result;
			    var CityArray=new Array();   
			    CityArray=strReturnCitys.split("&");
			    document.getElementById("ddlcity").options.length=1;
			    document.getElementById("ddlDistrict").options.length=1;
			    for(i=0;i<CityArray.length;i++)
			    {
			        var option = window.document.createElement("Option");
			        option.value=CityArray[i].substring(0,6);
			        option.text=CityArray[i].substring(6);
							document.getElementById("ddlcity").options.add(option);
							if(IPCity.indexOf(option.text)!=-1)
							{
	        			option.selected=true;
	        			GetDistrict(document.getElementById("ddlcity"));
	        		}
			    }
				}  
			 }
		 ); 
}
function GetDistrict(City)
{
	//alert(City.value);
	document.getElementById(FIXCity).value=City.options[ City.selectedIndex].text;
	$.ajax
	(
		{url: 'AjaxGetCitys.net',  
		type: 'POST',  
		data:{values:City.value},  
		dataType: 'html',  
		timeout: 10000,  
		error: function(){},  
		success: function(result)
		{

		  var strReturnCitys=result;
	    var CityArray=new Array();   
	    CityArray=strReturnCitys.split("&");
	    
	    document.getElementById("ddlDistrict").options.length=1;
	    for(i=0;i<CityArray.length;i++)
	    {
	        var option = window.document.createElement("Option");
	        option.value=CityArray[i].substring(6);
	        option.text=CityArray[i].substring(6);
	        document.getElementById("ddlDistrict").options.add(option);
	    }
		}  
	 }
	); 
}
function SetDistrict(City)
{
	document.getElementById("txtDistrict").value=City.value;
}
function SetProvince()
{
	var objASP=document.getElementById('ASP');
	var obj=document.getElementById('SSP');
	if(obj!=null)
	{
		for(i=0;i<obj.options.length;i++)
		{
			if(obj.options[i].text.substr(0,2)==IPProvince)
			{
				obj.options[i].selected=true;
				if(objASP!=null)	objASP.value=obj.options[i].value;
				GetCity(obj.options[i].value);
				break;
			}
		}
	}					
}
