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.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);

  if (trim(Name_GB.value) != "")
  {
	  if (!IsHaveChinese(Name_GB.value))  {     alert("您的姓名中沒有任何中文字符");    Name_GB.focus();    return (false);  }
  }
  if(Name.value != "") { if(isContainsDigital(Name.value)) { alert("英文名不允許包含數字"); Name.focus(); return false; }}
  if (specialchar(Name_GB.value))  { alert("含有系統不允許的字符 ' 或 字符");  Name_GB.focus();    return (false);   }
  if (trim(Name_GB.value) == "" && trim(Name.value) == "")
  {
	  alert("中英文(姓名)請任填一項"); Name_GB.focus(); return false;
  }
  if (trim(Organization_GB.value) != "")
  {
	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 (trim(Organization_GB.value) == "" && trim(Organization.value) == "")
  {
	  alert("中英文(組織)請任填一項"); 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 (trim(Stree1.value) != "")
  {
	  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 (trim(Stree.value) != "")
  {
	  if(specialchar(Street.value))  { alert("含有系統不允許的字符 ' 或 字符; ");    Street.focus(); return (false);   }
	  if(checkchinese(Street.value))  {    alert("通信地址址(英文)只能輸入英文字母");  Street.focus();    return (false); }
  }
  if (trim(Stree1.value) == "" && trim(Stree.value) == "")
  {
	  alert("中英文(通信地址)請任填一項"); Stree1.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(/^(\+[0-9]{1,4}\.){0,1}[0-9\-]{5,15}$/.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;
}
