// JavaScript Document from 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.paySecureFrm.email.value != document.paySecureFrm.confirmEmail.value)
	{
		alert("Please enter your Confirm e-mail Address again!");
		document.paySecureFrm.confirmEmail.focus();
		return (false);
	}
 }
 
   function FormValidator(theForm)
   {
	  
	  if (theForm.url.value == "")
	  {
		alert("Please enter Website URL");
		theForm.url.focus();
		return (false);
	  }
	 if (theForm.title.value == "")
	  {
		alert("Please enter Website Title");
		theForm.title.focus();
		return (false);
	  }
	  	 if (theForm.description.value == "")
	  {
		alert("Please enter Website Description");
		theForm.description.focus();
		return (false);
	  }
	   if (theForm.reciprocal.value == "")
	  {
		alert("Please enter URL of our website placed");
		theForm.description.focus();
		return (false);
	  }
	  if (theForm.realname.value == "")
	  {
		alert("Please enter your Name");
		theForm.realname.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.country.options[theForm.country.selectedIndex].value == "")
	  {
	  	alert("Please select your Country");
		theForm.country.focus();
		return (false);
	  }
	   if (theForm.imgverify.value == "")
	  {
		alert("Please enter Image Verification");
		theForm.imgverify.focus();
		return (false);
	  }

   }
