
function checkValidation(thisForm)
{
   if(!checkText(thisForm.firstname,"Please Enter Your First Name")){return false;}
   if(!checkText(thisForm.lastname,"Please Enter Your Last Name")){return false;}
   if(!checkText(thisForm.email,"Please Enter Your Email")){return false;}
   //if email is empty, do nothing.  if email textbox is not empty, check for a valid email
   if(thisForm.email.value != "")
   {
	    if(!regExEmail(thisForm.email)){return false;}
   }
   if(!checkText(thisForm.messages,"Please Enter A Message")){return false;}
   return true; //returns true, unless there is a problem! (USE LOWER CASE!!)
}//END OF checkValidation///////////////////////////////////////////////////   






function checkText(fObj,msg)
{//will take in text and check for input
	var currTxt = document.getElementById("" +fObj.name + "1"); 
   if(fObj.value == "")
   {
	   currTxt.innerHTML = "<p class='contact_alert_para'>" + msg + "</p>";
	   fObj.focus();
	   return false;
   }
  return true;	
}
/*
function checkRadio(fObj,msg)
{//takes in radio button or checkbox and checks 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 checkSelect(fObj,msg)
{//checks that the 0 numbered item in the array is not selected
	if(fObj.options[0].selected)
	{
		alert(msg);
		fObj.focus();
		return false;
	}else
	{
		return true;	
	}	

}
*/
function regExEmail(eObj)
{//Uses regular expression for email check
	var currTxt = document.getElementById("" +eObj.name + "1"); 
	var rePattern = /^[a-zA-Z0-9\-]+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;
 if(rePattern.test(eObj.value))
 {
 	return true;
 }
 else
 {
    currTxt.innerHTML = "<br /><p class='alertPara'>Please enter a VALID email address</p>";
	eObj.value = "";
	eObj.focus();
	return false;
 }
}
