function valCountry(thisform) 
{
// place any other field validations that you require here
// validate myradiobuttons
	myOption = -1;
	for (i=thisform.cntryO.length-1; i > -1; i--) 
	{
		if (thisform.cntryO[i].checked) 
		{
			myOption = i; i = -1;
		}
	}
	if (myOption == -1) 
	{
		alert("You must select a country");
		return false;
	}

}

var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

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 trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
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){
var bracket=3;
strPhone=trim(strPhone);
if(strPhone.indexOf("+")>1) return false;
if(strPhone.indexOf("-")!=-1)bracket=bracket+1;
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false;
var brchr=strPhone.indexOf("(");
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false;
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false;
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
 
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this;
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
	return true;
}

function validateForm() {
	var returnValue = true;
	var err = "";
	
	err += "The form was not submitted because one or more errors occured.\n";
	err += "Please correct these error(s) and re-submit.\n\n";
	err += "----------------------------\n\n";
	

	// Validate first name
	if (document.getElementById("Contact Name").value == "") {
		err += "Please enter a contact name.\n";
		returnValue = false;
	}


	// Validate the email address is valid
	if (document.getElementById("Email Address").value == "" && contactPref == "Email" ) {
		err += "Please Enter an Email Address.\n";
		returnValue = false;
	} 

	if (document.getElementById("Email Address").value != "") {
		var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
		var chkEmail = document.getElementById("Email Address");
		 if (chkEmail.value.search(emailRegEx) == -1) {
			err += "Please enter a valid email address\n";
			returnValue = false;
		 }
	}
	
// Validate that contact information is entered
	var HmPhone=document.getElementById("Home/Office Phone");
	var cellPhone=document.getElementById("Mobile Phone");
	var faxNo=document.getElementById("Fax");
	var contactPref = document.getElementById("Preferred Method of Contact").value;
	
	if (contactPref == "") {
		err += "Please select a contact preference.\n";
		returnValue = false;
	} 
	
	if (contactPref == "Home/Office Phone" && HmPhone.value == "") {
		err += "Please Enter a Valid Home Phone Number.\n";
		returnValue = false;
	} 
	if (HmPhone.value != "") {
		if (checkInternationalPhone(HmPhone.value)==false || HmPhone.value == "123456") 
		{
			err += "Please Enter a Valid Home Phone Number.\n";
			HmPhone.value="";
			returnValue = false;
		}
	} 
	
	if (contactPref == "Mobile Phone" && cellPhone.value == "") {
		err += "Please Enter a Valid Cell Phone Number.\n";
		returnValue = false;
	} 
	if (cellPhone.value != "") {
		if (checkInternationalPhone(cellPhone.value)==false || cellPhone.value == "123456") {
			err += "Please Enter a Valid Cell Phone Number.\n";
			cellPhone.value="";
			returnValue = false;
		}
	} 

	if (faxNo.value != "") {
		if (checkInternationalPhone(faxNo.value)==false || (faxNo.value == "123456")) {
			err += "Please Enter a Valid Fax Number.\n";
			faxNo.value="";
			returnValue = false;
		}
	} 

	// Validate the number of rooms
	if(document.getElementById("Number of Rooms").value == "0" )  {
		err += "Select the number of rooms you will require.\n";
		returnValue = false;
	}

	// Validate the number of adults
	if(document.getElementById("Adults").value == "0" )  {
		err += "Select the number of adults that will need accomodations.\n";
		returnValue = false;
	}

// Validate Arrival Date
	var arrdt=document.getElementById("Arrival Date").value;
	if (arrdt == "") {
		err += "Please let us know your arrival date.\n";
		returnValue = false;
	} else {
		if (!isDate(arrdt)){
			err += "Please enter a valid arrival date.\n";
			returnValue = false;
		}
	}

	// Validate Departure Date
	var departdt=document.getElementById("Departure Date").value;
	if (departdt == "") {
		err += "Please let us know you departure date.\n";
		returnValue = false;
	} else {
		if (!isDate(departdt)){
			err += "Please enter a valid departure date.\n";
			returnValue = false;
		}
	}
	
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
// Enter the words to be filtered in the line below:
	var swear_words_arr=new Array("joke","riddle");
	
	var swear_alert_arr=new Array;
	var swear_alert_count=0;
	
	var compare_text=document.getElementById("FindUs").value;
	for(var i=0; i<swear_words_arr.length; i++)
	{
		for(var j=0; j<(compare_text.length); j++)
		{
		if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase())
			{
				swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
				swear_alert_count++;
			}
		}
	}
	
	var alert_text="";
	for(var k=1; k<=swear_alert_count; k++)
	{
	alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
	}
		
	if(swear_alert_count==0) {
		var compare_text=document.getElementById("Comments").value;
		for(var i=0; i<swear_words_arr.length; i++)
		{
			for(var j=0; j<(compare_text.length); j++)
			{
			if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase())
				{
					swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
					swear_alert_count++;
				}
			}
		}
		
		var alert_text="";
		for(var k=1; k<=swear_alert_count; k++)
		{
		alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
		}
	}
	
	if (swear_alert_count != 0)
	{
		err += "Invalid text has been entered.\n";
		document.getElementById("FindUs").value = "";
		document.getElementById("Comments").value = "";
		returnValue = false;
	}

       
	/*if (err != "") {
		alert(err);
		returnValue = false;
	} else {
		returnValue = true;
	}
	*/	
	return returnValue;
}
