function IsNumeric(strString)

   //  check for valid numeric strings	

   {

   var strValidChars = "0123456789";

   var strChar;

   var blnResult = true;



   if (strString.length == 0) return false;



   //  test strString consists of valid characters listed above

   for (i = 0; i < strString.length && blnResult == true; i++)

      {

      strChar = strString.charAt(i);

      if (strValidChars.indexOf(strChar) == -1)

         {

         blnResult = false;

         }

      }

   return blnResult;

   }
   
function checkEmail() {
	var email = document.getElementById('emailfrom');
	var filter = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	if (!filter.test(document.formcheck.email.value)) {
		return false;
	} else {
		return true;
	}
}

function formCheck(){
	var errmsg = "All fields are required.  Please correct the following errors before submitting:\n";
	var valid = true;
	
	if ( document.formcheck.first_name.value == "" || document.formcheck.first_name.value == "First Name")
        {
                errmsg += " > Please fill in the 'First Name' box.\n";
                valid = false;
        }
		
	if ( document.formcheck.last_name.value == "" || document.formcheck.last_name.value == "Last Name")
        {
                errmsg += " > Please fill in the 'Last Name' box.\n";
                valid = false;
        }
		
	if (!checkEmail())
		{
			errmsg += " > Please enter a valid email address.\n";
			valid = false;
		}	
		
		if (!IsNumeric(document.formcheck.phone.value))
		{
			errmsg += " > Please enter a valid phone number using numbers only.\n";
			valid = false;
		}
		
	if ( document.formcheck.state.value == "" || document.formcheck.state.value == "null")
        {
                errmsg += " > Please select your state.\n";
                valid = false;
        }

			
	if (valid)
		{
			document.formcheck.submit();
		} else
		{
			alert(errmsg);
		}
}
