function validate_contact(arg)
{
 with(arg)
 {
	   if(name.value=="")
	   {
		  alert("Please enter your name");
		  name.focus();
		  return false; 
	   }
	   if(subject.value=="")
	   {
		  alert("Please enter subject");
		  subject.focus();
		  return false; 
	   }
	   
	   if(email.value=="")
	   {
		  alert("Please enter email address");
		  email.focus();
		  return false; 
	   }
	   if(email_validate(email)==false)
		{
			alert("You have entered an invalid email address");
			email.select();
			email.focus();
			return false;
		}
	   if(phone.value=="")
	   {
		  alert("Please enter phone number");
		  phone.focus();
		  return false; 
	   }
	   else
		{
			 if(phoneValidation(arg.phone.value)==false)
			 {
				alert("Invalid phone number");
				phone.select();
				phone.focus();
				return false;
			 }	
		}
	  if(comments.value=="")
	   {
		  alert("Please enter comments");
		  comments.focus();
		  return false; 
	   }
	   
	  
	   
 }
 arg.submit();
}

function email_validate(objForm) 
 {
	
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = objForm.value;
   if(reg.test(address) == false)
   {
      //alert('Invalid Email Address');
      return false;
   }
  }
  
function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}	
function phoneValidation(strString)
{
   var strValidChars = "0123456789-+ ";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
			return false;
         }
      }
}
