// JavaScript Document
//<script language="javascript">
function autoCheck(itype){
    //var objRe = /<\s*(\S+)(\s[^>]*)?>[\s\S]*<\s*\/\1\s*>/
	//var objRe="/(?i)((FTP|HTTP)://|www\.)([\w\d\-]+(\.[\w\d\-]+)+)(:\d\d?\d?\d?\d?)?(((/[%+\w\d\-\\\.]*)+)*)(\?[^\s=&]+=[^\s=&]+(&[^\s=&]+=[^\s=&]+)*)?(#[\w\d\-%+]+)?/"
	//var objRe=/[Hh][Tt][Tt][Pp][\:][\/]{2}/
	var objhref=/\<[Aa][\s]+[Hh][Rr][Ee][Ff]=/
	var objweb=/([a-z]|[0-9])(.net|.com|.cn|.org)\b/
    var objhtmla=/<\s*(\S+)(\s[^>]*)?>/g
    var objhtmlb=/<\s*\/\1\s*>/g
// 除去所有空白
   String.prototype.Trim = function()
   {
       var regEx = /\s*/g;
       return this.replace(regEx,'');              
   }
   String.prototype.len=function()
   {
       return this.replace(objhtmla,"").replace(objhtmlb,"").length;
   }   
    if(itype=="isnull"){
		var otmp=document.getElementsByTagName("INPUT");
		if(otmp!=null){
			for(i=0;i<otmp.length;i++){
				if (otmp[i].value.indexOf("'")!=-1)
				{
					alert("此项输入有非法字符'");
					otmp[i].focus();
					return false;
				}				
                if(objhref.test(otmp[i].value)&&otmp[i].name!="logName"&&otmp[i].name!="logPassword"){
				    alert("不能加入超连接");
					otmp[i].focus();
					return false;
				}
                if(!objweb.test(otmp[i].value.toLowerCase())&&otmp[i].value!=""&&otmp[i].name=="copnetAdress"){
				    alert("输入网址不正确");
					otmp[i].focus();
					return false;
				}				
				
				if(otmp[i].value==""&&otmp[i].name!="username"&&otmp[i].name!="password"&&otmp[i].name!="copnetAdress"&&otmp[i].name!="conPersonQQ"&&otmp[i].name!="conPersonMSN"&&otmp[i].name!="whynotpass"){
					if(otmp[i].name=="copPinpai"){
					   alert("代理品牌不能为空!");
					}else{
					   alert("此项不能为空!");
					}
					otmp[i].focus();
					return false;
				}
			}
		}
		var otmp=document.getElementsByTagName("select");
		if (otmp!=null)
		{
			if (otmp[0].value=="--")
			{
				alert("请选择一项！");
				otmp[0].focus();
				return false;
			}
		}
		var otmp=document.getElementsByTagName("textarea");
		if (otmp!=null)
        {
			if(otmp[0].value.Trim()==""){
				alert("企业介绍不能为空");
				otmp[0].focus();
				return false;
			}
            if(objhref.test(otmp[0].value)){
				alert("不能加入超链接");
				otmp[0].focus();
				return false;
			}
            if(objweb.test(otmp[0].value.toLowerCase())){
				alert("企业介绍不能加入网址");
				otmp[0].focus();
				return false;
			}
			//var areatext
			//areatext=otmp[0].value
			//alert (areatext)
			//alert (objhtmla.replace(areatext))
			//alert (areatext)
			if (otmp[0].value.len()>150)
			{
				alert("描述超过字数限制");
				otmp[0].focus();
				return false;
			}
		}
	}	
	return true;
}
function IsNum(str)
{
 var i;
 for (i=0;i<str.length;i++)
 {
 if (str.charAt(i) < "0" || str.charAt(i)> "9")
 return false;
 }
 return true;
}
function isValidEmailAddress(strEmail)
{
 var i, strDomain, cChar;
 var nDotCount=0;
 var bFindAlpha=false;
 var bLastIsDot=false;
 var strValid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.";

 if(strEmail=="") return false;
 i=strEmail.indexOf("@");
 if(i==-1 || i==0 || i==strEmail.length-1) return false;
 strDomain = strEmail.substring(i+1,strEmail.length);
 if(strDomain.indexOf("@")!=-1) return false;
 if(strDomain.charAt(0)==".") return false;
 if(strDomain.charAt(strDomain.length-1)==".") return false;
 for(i=0;i<strDomain.length;i++) {
 cChar = strDomain.charAt(i);
 if(strValid.indexOf(cChar)==-1) return false;
 if(cChar==".") {
 if(bLastIsDot) return false;
 bLastIsDot=true;
 nDotCount++;
 }else bLastIsDot=false;
 if( (("a"<=cChar) && (cChar<="z")) || (("A"<=cChar)&&(cChar<="Z")) )
 bFindAlpha=true;
 }
 if(bFindAlpha && (0==nDotCount)) return false;
 return true;
}
//</script>
