 function checkForm(thisForm)
   {       //if checkText fails, kick it out! (uses NOT operator, !)

    if(!checkText(thisForm.Name,"Please Enter Your Name")){return false;}
    
    if(!checkText(thisForm.Phone,"Please Enter Your Phone Number")){return false;}
    
    if(thisForm.Email.value !="")
       { 
	    if(!regExEmail(thisForm.Email)){return false;}
        }

    return true; //returns true, unless there is a problem! 
   }

  function checkText(fObj,msg)
   {       //will take in a text and check for input
    if(fObj.value == "")
     {
	   alert(msg);
	   fObj.focus();
	   return false;
     }
    return true;	
   }
   
  function checkRadio(fObj,msg)
    {     //will take in a radio button or checkbox and check for input

	for(x=0; x<fObj.length;x++)
	  {
		if(fObj[x].checked)
		{   //good!!
			return true;
		}
	  }
	
    alert(msg);
    fObj[0].focus();//focus on first element of array of named elements
    return false;

   }
   
  function regExEmail(eObj)
  {//Uses regular expression for email check
     var rePattern = /^[a-zA-Z0-9\-]+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;
     if(rePattern.test(eObj.value))
     {
 	  return true;
     }else{
           alert("Please enter a valid email address");
	       eObj.value = "";
	       eObj.focus();
	       return false;
          }
   }
   

