// JavaScript Document
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;

function validates(theForm)
{
if(theForm.nametxt.value=="")
{
  alert("Please enter your first name");
  theForm.nametxt.focus();
  return false;
}
if(theForm.lnametxt.value=="")
{
  alert("Please enter your last name");
  theForm.lnametxt.focus();
  return false;
}
if(theForm.addresstxt.value=="")
{
  alert("Please enter your street address");
  theForm.addresstxt.focus();
  return false;
}
if(theForm.citytxt.value=="")
{
  alert("Please enter your city");
  theForm.citytxt.focus();
  return false;
}
if(theForm.statetxt.value=="")
{
  alert("Please enter your state");
  theForm.statetxt.focus();
  return false;
}
if(theForm.countrytxt.value=="")
{
  alert("Please enter your country name");
  theForm.countrytxt.focus();
  return false;
}
if(theForm.phonetxt.value=="")
{
  alert("Please enter your phone number");
  theForm.phonetxt.focus();
  return false;
}
if (checkInternationalPhone(theForm.phonetxt.value)==false){
		alert("Please enter a valid phone number");
		theForm.phonetxt.value="";
		theForm.phonetxt.focus();
		return false;
	}
if(theForm.mailtxt.value=="")
	{
		alert("Please enter your email address");
		theForm.mailtxt.focus();
		return false;
	}
	if(!checkEmail(theForm))
	{
		alert("Invalid email address");
		theForm.mailtxt.focus();
		return false;
	}
	/*if(theForm.arrivaldate.value=="")
{
  alert("Please enter arrival date");
  theForm.arrivaldate.focus();
  return false;
}
if(theForm.depdate.value=="")
{
  alert("Please enter departure date");
  theForm.depdate.focus();
  return false;
}*/
return true;
}
function checkEmail(theForm) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.mailtxt.value)){
		return (true)
	}
	return (false)
}	
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function ResetForm(theform)
  {
  theform.reset();
  return false;
  }
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}