// JavaScript Document
function Jtrim(str){
        var i = 0;
        var len = str.length;
        if ( str == "" ) return( str );
        j = len -1;
        flagbegin = true;
        flagend = true;
        while ( flagbegin == true && i< len)
        {
           if ( str.charAt(i) == " " )
                {
                  i=i+1;
                  flagbegin=true;
                }
                else
                {
                        flagbegin=false;
                }
        }

        while  (flagend== true && j>=0)
        {
            if (str.charAt(j)==" ")
                {
                        j=j-1;
                        flagend=true;
                }
                else
                {
                        flagend=false;
                }
        }

        if ( i > j ) return ("")

        trimstr = str.substring(i,j+1);
        return trimstr;
}
function is_date(str) {
		  
  var myReg =/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])$/;
  if(myReg.test(str)) return true;
  return false;
}
function is_email(str) {
		  
  var myReg =/^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
  if(myReg.test(str)) return true;
  return true;
}
function is_http(str) {
	var myReg=new RegExp("((:http|https|ftp|mms|rtsp)://(&(=amp;)|[A-Za-z0-9\./=\%_~@&#:;\+\-])+)","ig");
  if(myReg.test(str)) return true;
  return true;
}
function data_check() {
		if (Jtrim(document.theform.contactor.value)=='') {
        		window.alert ("联系人姓名不能为空！")
				document.theform.contactor.focus();
       			return false
	        }
		else if(Jtrim(document.theform.contactor.value).length>10){
				window.alert ("联系人姓名不能大于10个字！")
				document.theform.contactor.focus();
                return false
		}
		if (Jtrim(document.theform.ctd.value)=='') {
        		window.alert ("公司名称不能为空！")
				document.theform.ctd.focus();
       			return false
	        }
		else if(Jtrim(document.theform.ctd.value).length>40){
				window.alert ("公司名称不能大于40个字！")
				document.theform.ctd.focus();
                return false
		}
		if (Jtrim(document.theform.add.value)=='') {
        		window.alert ("联系地址不能为空！")
				document.theform.add.focus();
       			return false
	    }
		if (Jtrim(document.theform.tel.value)=='') {
        		window.alert ("联系电话不能为空！")
				document.theform.tel.focus();
       			return false
	    }
		if (Jtrim(document.theform.fax.value)=='') {
        		window.alert ("公司传真不能为空！")
				document.theform.fax.focus();
       			return false
	        }
		if (Jtrim(document.theform.email.value)=='') {
        		window.alert ("电子邮件不能为空！")
				document.theform.email.focus();
       			return false
	        }
		if (Jtrim(document.theform.http.value).length>0&&!is_http(Jtrim(document.theform.http.value))) {
        		window.alert ("公司网址格式不正确！")
				document.theform.http.focus();
       			return false
	    }
		if (Jtrim(document.theform.email.value).length>0&&!is_email(Jtrim(document.theform.email.value))) {
        		window.alert ("email格式不正确！")
				document.theform.email.focus();
       			return false
	    }
		if (Jtrim(document.theform.text.value)=='') {
        		window.alert ("订单内容不能为空！")
				document.theform.text.focus();
       			return false
	    }
		document.theform.submit();
}