// JavaScript Document form checks


function ltrim (s){
	return s.replace( /^\s*/, "" );
}

function rtrim (s){
	return s.replace( /\s*$/, "" );
}

function trim (s){
	return rtrim(ltrim(s));
}

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

 function ConfirmEmail()
 {
 	if (document.webFrm.email.value != document.webFrm.confirmEmail.value)
	{
		alert("Please enter your Confirm e-mail Address again!");
		document.webFrm.confirmEmail.focus();
		return (false);
	}
 }
 
   function FormValidator(theForm)
   {
	  
	 
	  if (theForm.arrival_day.value == "")
	  {
		alert("Please select arrival date");
		theForm.arrival_day.focus();
		return (false);
	  }
	   if (theForm.arrival_month.value == "")
	  {
		alert("Please select arrival month");
		theForm.arrival_month.focus();
		return (false);
	  }
	   if (theForm.arrival_year.value == "")
	  {
		alert("Please select arrival year");
		theForm.arrival_year.focus();
		return (false);
	  }
	 
	   
	   if (theForm.out_day.value == "")
	  {
		alert("Please select check out date");
		theForm.out_day.focus();
		return (false);
	  }
	  if (theForm.out_month.value == "")
	  {
		alert("Please select check out month");
		theForm.out_month.focus();
		return (false);
	  }
	  if (theForm.out_year.value == "")
	  {
		alert("Please select check out year");
		theForm.out_year.focus();
		return (false);
	  }
	   
	  if (theForm.realname.value == "")
	  {
		alert("Please enter Your Name");
		theForm.realname.focus();
		return (false);
	  }
	   if (theForm.lastname.value == "")
	  {
		alert("Please enter Your Last Name");
		theForm.lastname.focus();
		return (false);
	  }
	  if (theForm.email.value == "")
	  {
		alert("Please enter your e-mail Address");
		theForm.email.focus();
		return (false);
	  }
	  if (!isEmailAddr(theForm.email.value))
	  {
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		theForm.email.focus();
		return (false);
	  }
	   
	  if (theForm.email.value.length < 3)
	  {
		alert("Email should be more then 3 characters");
		theForm.email.focus();
		return (false);
	  }
	  	  
	  if (theForm.confirmEmail.value != theForm.email.value)
	  {
		alert("Please enter your Confirm e-mail Address");
		theForm.confirmEmail.focus();
		return (false);
	  }
	   if (theForm.party.value == "")
	  {
		alert("What wedding party you are attending?");
		theForm.party.focus();
		return (false);
	  }
	  	  if (theForm.imgverify.value == "")
	  {
		alert("Please enter Image Verification");
		theForm.imgverify.focus();
		return (false);
	  }
	  

   }
