	function validate_name(field,fieldname) 
	{
	  with (field)
	  {
	    if (value.length < 1) {
		  alert("The " + fieldname + " box is empty. Please enter your " + fieldname + ".");
		  return false;
		}
		return true;
	  }
	}
	
	function validate_email(field,required)
	{
	  with (field)
	  {
	  var apos=value.indexOf("@");
	  var dotlastpos=value.lastIndexOf(".");
	  var alastpos=value.lastIndexOf("@");
	  var invalidChars = "()[]\\\;,\":<>";
	
	  if ( ( required && (value.length<6 || apos<1 || dotlastpos-apos<2 || apos!=alastpos || value.length - dotlastpos < 2)) || 
	       ( !required && value.length>0 && (value.length<6 || apos<1 || dotlastpos-apos<2 || apos!=alastpos || value.length - dotlastpos < 2)))
	  {
	    alert("The Email box does not appear to contain a valid email address. Please correct this.");
		return false;
	  }
		 
      for (var i = 0; i < value.length; i++) {
          if (invalidChars.indexOf(value.charAt(i)) >= 0) {
             alert ("The Email box has special characters. \nThese are not allowed: ( ) [ ] \\ \; , \" : < >\nThis is the character found: \"" + value.charAt(i) + "\"");
             return false;
          }
       }
	  return true;
	  }
	}
	
	function validate_field(field,minfieldlength,fieldname)
	{
	  with (field)
	  {	  
	  	if ( value.toLowerCase().indexOf('http') != -1 || 
		value.toLowerCase().indexOf('.com') != -1 || 
		value.toLowerCase().indexOf('.edu') != -1 || 
		value.toLowerCase().indexOf('.ru') != -1 ||
		value.toLowerCase().indexOf('www.') != -1 || 
		value.toLowerCase().indexOf('.org') != -1 ||  
		value.toLowerCase().indexOf('a href') != -1 || 
		value.toLowerCase().indexOf('url') != -1 || 
		value.toLowerCase().indexOf('link') != -1 || 
		value.toLowerCase().indexOf('<p>') != -1 || 
		value.toLowerCase().indexOf('<html>') != -1 )
		{
		   alert("Please do not submit URLs or HTML in the " + fieldname + " box.\n" + 
		         "This includes \"HTTP://\" and \".com/\" type information.\n" +
				 "If you must send an address to us, please email the information to info (.at.) wymanpiano.com directly.");
		   return false;
		}
		
		if (value.length < minfieldlength) 
		{
		    alert("The " + fieldname + " box does not appear to contain a valid " + fieldname + ". Please correct this. \nThe minimum length is: " + minfieldlength);
		    return false;
		}
		return true;
      }
	}
	
	function validate_zip(field,required)
	{
	  with (field) 
	  {
	    if ( (value.length < 5 && required) || (value.length > 5 && value.length < 10) || value.length > 10) 
		{
		  alert("The Zip Code box is invalid because it has " + value.length + " characters.\nPlease use 5 characters (without hyphen) or 10 characters (including hyphen) in the Zip Code box.");
		  return false;
		}
		if (value.length > 5 && value.charAt(5) != "-") 
		{
		  alert("Please uze a Hyphen \"-\" to separate the 9-digit Zip Code like this:  12345-6789");
		  return false;
		}

		if (  (value.length == 5 && (value.substring(0,4) - 0 != value.substring(0,4))) ||
              (value.length == 10 && (value.substring(6,9) - 0 != value.substring(6,9))) )	 {
		  alert("The Zip Code box does not contain a valid Zip Code. Use a format of either 12345 or 12345-6789.");
		  return false;
		}
		return true;
	  }
	}
	
	function validate_phone(field,fieldname,required)
	{
	  with (field) 
	  {
	    var numberonly = "";
	    for (var i=0;i<value.length;i++)
		{
		  if(value.charAt(i) >=0 || value.charAt(i) <= 9) {
		    numberonly += value.charAt(i);
		  }
		}
	    if ( (numberonly.length < 10 && required) || (numberonly.length > 0 && numberonly.length < 10 && !required) ) 
		{
		  alert("Please check the " + fieldname + " phone number and try again. It needs to have 10 digits including area code.");
		  return false;
		}
		value = "";
		if ( numberonly.length != 0 ) {
		  if (numberonly.length > 10) {
		    value += numberonly.substring(0,numberonly.length-10);
		  }
		  value += "(" + numberonly.substring(numberonly.length-10,numberonly.length-7) + ")" + numberonly.substring(numberonly.length-7,numberonly.length-4) + "-" + numberonly.substring(numberonly.length-4,numberonly.length)
		}
		return true;
	  }
	}
	
	function validate_dropdown(field,fieldname)
	{
	  with (field)
	  {
	     if (field.selectedIndex==0)
		 {
		   alert("Please make a selection from the " + fieldname + "drop down list.");
		   return false;
		 }
		 return true;
	  }
	}