
//去附左右两边的空格
function trim(str)
{
  str=str.replace(/^ {1,}/g,"");
  str=str.replace(/ {1,}$/g,"");
  return str;
}
//function checkchinese(theelement)
//{ //如果含有中文字符返回 true
 //  text="abcdefghijklmnopqrstuvwxyz1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ,/!@$%&\#*~.;'_-";
  // for(i=0;i<theelement.length;i++)
   //{
	 // char1=theelement.charAt(i);
	  //index=text.indexOf(char1);
	  //if(index==-1)  return true;
   //}
   //return false;
//}
function IsHaveChinese(theelement)
{
   for(i=0;i<theelement.length;i++){
       if(theelement.charCodeAt(i)>127) return true;
   }
   return false;
}
function haveEnglish(theelement)
{// 如果含有英文字符返回 true 
   text="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   for(i=0;i<theelement.length;i++)
   {
	  char1=theelement.charAt(i);
	  index=text.indexOf(char1);
	  if(index>=0){ return true; }
   }   return false;
}
function havenonlicet(theelement)
{ text="&#*()<>\"'";
  for(i=0;i<theelement.length;i++)
   {
	  char1=theelement.charAt(i);
	  index=text.indexOf(char1);
	  if(index>=0){return true; }
   }
   return false;
}
function TelorFax(str){
   if(/^[0-9]{1,12}-{0,}[0-9]{0,}$/.test(str)==true)
      return true;
   else 
      return false;
}
function TelorFax2(str){
   if(/^[0-9]{1,4}-{1,1}[0-9]{1,4}-{0,1}[0-9]{5,8}-{0,1}[0-9]{0,}$/.test(str)==true)
      return true;
   else 
      return false;
}
function checkPersonalID(str){
   if(/^[0-9]{15,18}$/.test(str)==false)
	 return false;
   else
	 return true;   
}
function checkCC(str){
   if(/^[A-Z]{2,2}$/.test(str)==false)
	 return false;
   else
     return true;
}
function checkEmail(str)
{
   if(str.indexOf("@")==-1||str.indexOf(".")==-1){
	 return false;
   } 
   return true;
}
function checkdata()
{
	var formElement="";
    formElement=eval("document.all.checkinfo.AName_GB");
	 formElement.value=trim(formElement.value);
	 if(formElement.value=="")
	 {
		alert("姓名不能为空");formElement.focus();
		return false
	 }
     
	formElement=eval("document.all.checkinfo.AMobile");
	formElement.value=trim(formElement.value);
	if(formElement.value=="") { 
		 alert("联系手机不能为空");
		 formElement.focus();
		 return false;
	}
	if(!TelorFax(formElement.value) || formElement.value.length<6) { 
		 alert("请输入正确的手机号格式");
		 formElement.focus();
		 return false;
	}

    formElement=eval("document.all.checkinfo.ATel");
	formElement.value=trim(formElement.value);
	if(formElement.value=="") { 
		 alert("联系电话不能为空");
		 formElement.focus();
		 return false;
	}

	if(!TelorFax(formElement.value) || formElement.value.length<6) { 
		 alert("请输入正确的联系电话格式");
		 formElement.focus();
		 return false;
	}

   formElement=eval("document.all.checkinfo.AEmail");
	formElement.value=trim(formElement.value);
	if(formElement.value=="")
	{ 
		alert("E-Mail不能为空！");
	 	formElement.focus();
	 	return false;
	}

	if(!checkEmail(formElement.value))
	{ 
		alert("错误的E-mail格式");
	 	formElement.focus();
	 	return false;
	}
	if(document.getElementById("agreementdisplay").style.display=="" && document.getElementById("agreement").checked!=true )
	{
		alert("确认已阅读并接受该协议！");
		return false;
	}
	//num<10 || num%5!=0
	/*
	if(document.getElementById("Mb").value==5){
		alert("免费赠送4M独立带宽,如需要购买最少10M起，10M后每5M收费!");
		return false;
	}else{
		if(document.getElementById("Mb").value!=4 || (document.getElementById("Mb").value-4)%5!=0){
			alert("免费赠送4M独立带宽,如需要购买最少10M起，10M后每5M收费!");
			return false;
		}
	}
	*/
	return true;
}	

function checkagreement(){
	if(document.getElementById("agreementdisplay").style.display=="" && document.getElementById("agreement").checked!=true )
	{
		alert("确认已阅读并接受该协议！");
		return false;
	}
	else return true;
}
function killErrors()
{ 
	return true; 
} 
//window.onerror = killErrors;
