
function trimSpace(str)
{
  var i,j;
  if(str == "") return "";
  for(i=0;i<str.length;i++)
    if(str.charAt(i) != ' ') break;
  if(i >= str.length) return "";

  for(j=str.length-1;j>=0;j--)
    if(str.charAt(j) != ' ') break;

  return str.substring(i,j+1);
}
/* 
用途：检查输入字符串是否只由英文字母和数字组成 
输入： 
str：字符串 
返回： 
返回false 
*/ 
function str_en(str)
        {        
          if(!trimSpace(str).match(/^[a-zA-Z0-9]+$/i))
           {
             return false;             
           }
      }
/*
用途：检查数字并控制位数
str:字符串
返回：flase
*/	  
function str_int(str)
        {        
          if(!trimSpace(str).match(/[0-9]{6}/i))
           {
             return false;             
           }
      }
/*
用途：检查email地址
str:字符串
返回：flase
*/
function str_email(str)
        {        
          if(!trimSpace(str).match(/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/i))
           {
             return false;             
           }
      }
function chk_out()
{
		
var a=document.getElementById('Subject');
var b=document.getElementById('first');
var c=document.getElementById('last');
//var d=document.getElementById('company');

var e=document.getElementById('email');
//var f=document.getElementById('address');

var g=document.getElementById('city');

var h=document.getElementById('state');
var i=document.getElementById('zip');
//var j=document.getElementById('daytime');
//var k=document.getElementById('evening');
var l=document.getElementById('comments');

var error_a = "Require Fields must be entered!";
var error_b = "Require Fields must be entered!";
var error_c = "Require Fields must be entered!";
//var error_d = "The e-maill address you entered is not valid!";

var error_e = "The e-maill address you entered is not valid!";
//var error_f = "The e-maill address you entered is not valid!";

var error_g = "Require Fields must be entered!";
var error_h = "Require Fields must be entered!";
var error_i = "Require Fields must be entered!";
var error_l = "Require Fields must be entered!";

/**/


if(trimSpace(a.value).length==0||a.value=="contact_us.php"){
	alert(error_a);
	a.focus();
    return false;
	}

if(trimSpace(b.value).length==0){
	alert(error_b);
	b.focus();
    return false;
	}

if(trimSpace(c.value).length==0){
	alert(error_c);
	c.focus();
    return false;
	}
/*	
if((trimSpace(d.value).length==0)||(str_email(d.value)==false)){
	alert(error_d);
	d.focus();
    return false;
	}
*/	

if((trimSpace(e.value).length==0)||(str_email(e.value)==false)){
	alert(error_e);
	e.focus();
    return false;
	}

/*	
if((trimSpace(f.value).length==0&&trimSpace(e.value).length!=0)||(trimSpace(f.value).length!=0&&(str_email(f.value)==false))){
	alert(error_f);
	f.focus();
    return false;
	}
*//**/
if(trimSpace(g.value).length==0){
	alert(error_g);
	g.focus();
    return false;
	}

if(trimSpace(h.value).length==0){
	alert(error_h);
	h.focus();
    return false;
	}	
	if(trimSpace(i.value).length==0){
	alert(error_i);
	i.focus();
    return false;
	}
	if(trimSpace(l.value).length==0){
	alert(error_l);
	l.focus();
    return false;
	}
return true;
}