function validateForm(frm1)
{

  pass = 1; //assume everything is ok
  msg = "The following problems were found when trying to submit this form:\n\n";

  //make sure required fields are not empty
  	if (isEmpty(frm1.fname.value))
  		{
  		  msg = msg + "- First Name cannot be empty\n";
   		 pass = 0;
  		}
  
  
  
   			if (isEmpty(frm1.lname.value))
  			{
  			  msg = msg + "- Last Name cannot be empty\n";
   			 pass = 0;
 			 }
  
   
  if (isEmpty(frm1.email.value))
  {
    msg = msg + "- Email cannot be empty\n";
    pass = 0;
  }
  
  
  
  			 if (isEmpty(frm1.add.value))
  			{
			 msg = msg + "- Address cannot be empty\n";
   			 pass = 0;
 			 }
  
  
  
  				 if (isEmpty(frm1.city.value))
  			{
   				 msg = msg + "- City cannot be empty\n";
   				 pass = 0;
				 }
    				if (isEmpty(frm1.state.value))
 					 {
  				  msg = msg + "- State cannot be empty\n";
   				 pass = 0;
 					 }
  
  
 // if (isEmpty(frm1.country.value))
//  {
 //   msg = msg + "- Country cannot be empty\n";
 //   pass = 0;
 // }
  
  
  
   if(!isNum(frm1.zip.value))
   {
   
    msg = msg + "-Please enter a valid Postal Code\n";
    pass = 0;
   
   }
   
 //validate the email address
  if (!(isEmail(frm1.email.value)))
  {
    msg = msg + "- Please enter a valid email address\n";
    pass = 0;
  }
  
  
   if(frm1.dphone.value!="")
{
  var dphone1=frm1.dphone.value;
   var dphone2=frm1.dphone2.value;
   var dphone3=frm1.dphone3.value;
 
    dphone=dphone1+dphone2+dphone3;
	
  if(!isNum(dphone))
   {
   
    msg = msg + "-Please enter a valid day phone number\n";
    pass = 0;
   
   }
   if(dphone.length < 10)
   {
   
  msg = msg + "-Please enter a valid 10 digit day phone number\n";
    pass = 0;
   }


  }
   
   if(frm1.ephone.value!="")
{
  
 var ephone1=frm1.ephone.value;
   var ephone2=frm1.ephone2.value;
   var ephone3=frm1.ephone3.value;
 
    ephone=ephone1+ephone2+ephone3;
	
  if(!isNum(ephone))
   {
   
    msg = msg + "-Please enter a valid evening phone number\n";
    pass = 0;
   
   }
   if(ephone.length < 10)
   {
   
  msg = msg + "-Please enter a valid 10 digit evening phone number\n";
    pass = 0;
   }
}
   
    if(frm1.fax.value!="")
{
  
   var fax1=frm1.fax.value;
   var fax2=frm1.fax2.value;
   var fax3=frm1.fax3.value;
 
    fax=fax1+fax2+fax3;
	
  if(!isNum(fax))
   {
   
    msg = msg + "-Please enter a valid fax number\n";
    pass = 0;
   
   }
   if(fax.length < 10)
   {
   
  msg = msg + "-Please enter a valid 10 digit fax number\n";
    pass = 0;
   }
   
  }
  
  
  if(frm1.comments.value!="")
{
 var str=frm1.comments.value;
  
  var pos1 = str.indexOf (">");
   
  if (pos1>-1)
  {
  
  alert("invalid character >");
  return false;
  }
  var pos2 =str.indexOf("<");
  if (pos2>-1)
  {
  
  alert("invalid character <");
  return false;
  }
  var pos3 =str.indexOf("%20");
  if (pos3>-1)
  {
  
  alert("invalid character %20");
  return false;
  }
  
  
   var pos4 =str.indexOf("'");
  if (pos4>-1)
  {
  
  alert("invalid character '");
  return false;
  }
   var pos5 =str.indexOf("=");
  if (pos5>-1)
  {
  
  alert("invalid character =");
  return false;
  }
   var pos6 =str.indexOf("*");
  if (pos6>-1)
  {
  
  alert("invalid character *");
  return false;
  }
   var pos7 =str.indexOf("%");
  if (pos7>-1)
  {
  
  alert("invalid character %");
  return false;
  }
  
  
  
  }
   if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg);
    return false;
  }
  
 
  

}

// validators ------------------------------------------------------------------

	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return true;
    else
        return false;
}

