//Written By: Kevin Stover - kstover@gmail.com
// November, 2008
// This script checks to see if everything with a class of "required" is filled in.
// It does not check for valid information, only that something is entered.
// If you need more validation, please use another include.
// USAGE: 
// (1) make sure that the main jQuery .js file is included.
// (2) include this .js file in the <head> of your document.
// (3) in your <form> tag, include:   onSubmit="return basic_form_check();"   i.e. <form name="form1" method="post" action="process_form.php" onSubmit="return basic_form_check();">
// (4) give everything you want to be "required" a class of "required"
// (5) anything that is blank will be given an additional class of "error". 
// If you want your boxes to indicate which ones have failed, create an "error" class in your css.
// This script will also put the browsers focus/cursor into the first empty required field.
function basic_form_check(){
   tmp = 1;
   submit = 1;
   $(".required").each(function(){
      //alert(tmp);
      if(this.value == ''){
         if($(this).hasClass("error")){
            //alert('error');
         }else{
            this.className=this.className + " error";
         }
         //alert(this.className);
         submit = 0;
         if(tmp == 1){
            //alert('hi');
            this.focus();
         }
      tmp++;
      }else{
         $(this).removeClass("error");
      
      }
         
         
      
   });
   if(submit == 0){
      alert("Please fill out all required fields.");
      return false;
   }else{
      //alert('hi');
   }
}
