
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function validate_email(field,alerttxt)
{

with (field)
  {
var returnval=emailfilter.test(value)
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2||returnval==false)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}



function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);
    return false;
    }
  else
    {
    return true;
    }
  }
}

function validatecharacters(string1,alerttxt)
{

var valid = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.";

		for (var i=0; i < string1.length; i++)
		{
		temp = "" + string1.substring(i, i+1);


			if (valid.indexOf(temp) == "-1")
			{
			alert(alerttxt);
			return false;
			}
		}


		return true
}

function validatePhone(aphone)
{
var valid = " +-0123456789";

		for (var i=0; i < aphone.length; i++)
		{
		temp = "" + aphone.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			{
			alert("Please input a valid Phone Number!.")
			return false;
			}
		}
		return true
}

function validate_form(thisform)
{

with (thisform)
  {

 if (validate_required(name,"Name field cannot be empty!")==false)
    {name.focus();return false;}

 if (validatecharacters(name.value,"Invalid characters in  Name!")==false)
    {name.focus();return false;}
	
	 if (validate_required(address,"Address field cannot be empty!")==false)
    {address.focus();return false;}

 if (validatecharacters(address.value,"Invalid characters in address!")==false)
    {address.focus();return false;}
	
	 if (validate_required(city,"City field cannot be empty!")==false)
    {city.focus();return false;}
	
	 if (validate_required(state,"State field cannot be empty!")==false)
    {state.focus();return false;}
	
	 if (validate_required(country,"Country field cannot be empty!")==false)
    {country.focus();return false;}

 if (validate_required(email,"Please provide an email address!")==false)
    {email.focus();return false;}

 if (validate_email(email,"Please provide an valid email address!")==false)
    {email.focus();return false;}
	
	 if (validate_required(phone,"phone field cannot be empty!")==false)
    {phone.focus();return false;}


 if (validatePhone(phone.value,"Please provide a valid Phone Number!")==false)
    {phone.focus();return false;}
	
	 if (validate_required(location,"location field cannot be empty!")==false)
    {location.focus();return false;}

 if (validatecharacters(location.value,"Invalid characters in location!")==false)
    {location.focus();return false;}
	
	 if (validate_required(tour1,"pick a category!")==false)
    {tour1.focus();return false;}
	 if ( document.form1.tour1.checked == false && document.form1.tour2.checked == false && document.form1.tour3.checked == false && document.form1.tour4.checked == false)
{ alert ( "Please select atleast one banner !" ); return false; }


 if (validate_required(profile,"Please add your message!")==false)
    {profile.focus();return false;}
    
 if (validate_required(captchacode,"Please enter the characters shown in the image!")==false)
    {captchacode.focus();return false;}
	
	

	

 if ( document.contactusform.agree.checked == false )
    { alert ( "Please agree with Terms of service !" ); return false; }

 }

}
// JavaScript Document
