// 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.pro_nums.value)=='') {
        		window.alert ("请输入订购数量 ！")
				document.theform.pro_nums.focus();
       			return false
	        }
		
		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.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.text.value)=='') {
        		window.alert ("具体内容不能为空 ！")
				document.theform.text.focus();
       			return false
	    }
		pro_names = "";
		var o_pro_name = document.theform.elements["pro_name"];
		for (i=0;i<o_pro_name.length;i++){
			if(o_pro_name[i] && o_pro_name[i].checked){
				pro_names+= 	o_pro_name[i].value + ", ";
			}
		}

		document.theform.text.value+= "\n\n产品名称：" + pro_names;
		document.theform.text.value+= "\n\n订购数目：" + document.theform.pro_nums.value;
		document.theform.submit();
}