var chrSlash= "/";var intMinYear=2005;var intMaxYear=2010;// ******************************************************************************************************************************function isInteger(strParm)
// ******************************************************************************************************************************{	var i;    for (i = 0; i < strParm.length; i++)
	{   var chrAtPos = strParm.charAt(i);        // Check that current character is number		if ((chrAtPos < "0") || (chrAtPos > "9")) 
		{
			return false;
		}    }	return true; // All characters are numbers}// ******************************************************************************************************************************function stripCharsInBag(strParm, bag)
// ******************************************************************************************************************************{	var i;	var strReturn = "";	// Search through string's characters one by one	for (i = 0; i < strParm.length; i++)
	{           var chrAtPos = strParm.charAt(i);		// If character is not in bag, append to returnString        if (bag.indexOf(chrAtPos) == -1) 
		{
			strReturn += chrAtPos;
		}	}    return strReturn;}// ******************************************************************************************************************************function daysInFebruary(intYear)
// ******************************************************************************************************************************{	// February has 29 days in any year evenly divisible by four, EXCEPT for centurial years which are not also divisible by 400    return (((intYear % 4 == 0) && ( (!(intYear % 100 == 0)) || (intYear % 400 == 0))) ? 29 : 28 );}
// ******************************************************************************************************************************function DaysArray(n)
// ******************************************************************************************************************************{	for (var i = 1; i <= n; i++) 
	{		this[i] = 31 						// Default to 31		if (i==4 || i==6 || i==9 || i==11) 	// Thirty days hath...
		{
			this[i] = 30
		}		if (i==2)
		{
			this[i] = 29						// February
		}   }    return this}// ******************************************************************************************************************************function isValidDate(strParmDate)
// ******************************************************************************************************************************{	var daysInMonth = DaysArray(12)	var pos1=strParmDate.indexOf(chrSlash)	var pos2=strParmDate.indexOf(chrSlash,pos1+1)	var strMonth=strParmDate.substring(0,pos1)	var strDay=strParmDate.substring(pos1+1,pos2)	var strYear=strParmDate.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("Please enter dates in the format 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<intMinYear || year>intMaxYear)
	{		alert("Please enter a valid 4 digit year between "+intMinYear+" and "+intMaxYear+".");		return false;	}	if (strParmDate.indexOf(chrSlash,pos2+1)!=-1 || isInteger(stripCharsInBag(strParmDate, chrSlash))==false)
	{		alert("Please enter a valid date.");		return false;	}	return true;}


// ******************************************************************************************************************************function isValidEMailAddress(strEMail) 
// ******************************************************************************************************************************{
	var intPosAt=strEMail.indexOf("@")
	var intPosDot=strEMail.indexOf(".")
	var intStringLength=strEMail.length
	// Must have @ symbol
	if (intPosAt<=0 || intPosAt==intStringLength)
	{
		return false;
	}
	// Must have . symbol
	if (strEMail.intPosDot<=0 || intPosDot==intStringLength)
	{
		return false;
	}
	// May not have more than 1 @ symbol
	if (strEMail.indexOf("@",(intPosAt+1))!=-1)
	{
		return false;
	}
	// The . symbol may not immediately precede or follow the @ symbol
	if (strEMail.substring(intPosAt-1,intPosAt)=="." || strEMail.substring(intPosAt+1,intPosAt+2)==".")
	{
		return false;
	}
	// A . symbol must follow the @ symbol
	if (strEMail.indexOf(".",(intPosAt+2))==-1)
	{
		return false;
	}
	// May not contain blanks
	if (strEMail.indexOf(" ")!=-1)
	{
		return false;
	}
	return true;				
}

// ******************************************************************************************************************************function validateForm(frmTarget)// ******************************************************************************************************************************{	if (frmTarget.Name.value == "") 
	{
		alert("Please enter your name.");
		frmTarget.Name.select();
		frmTarget.Name.focus();		return false;	}
	if (frmTarget.EMail.value == "")
	{
		alert("Please enter your e-mail address.");
		frmTarget.EMail.select();
		frmTarget.EMail.focus();		return false;	}
	if (isValidEMailAddress(frmTarget.EMail.value)==false)
	{
		alert("Please enter a valid e-mail address.");
		frmTarget.EMail.select();
		frmTarget.EMail.focus();		return false;	}

//	if (frmTarget.DateOfArrival.value == "")
//	{
//		alert("Please enter your intended date of arrival.");
//		frmTarget.DateOfArrival.select();
//		frmTarget.DateOfArrival.focus();//		return false;//	}
//	if (isValidDate(frmTarget.DateOfArrival.value)==false)
//	{
//		frmTarget.DateOfArrival.select();
//		frmTarget.DateOfArrival.focus();//		return false;//	}
//	if (frmTarget.DateOfDeparture.value == "")
//	{
//		alert("Please enter your intended date of departure.");
//		frmTarget.DateOfDeparture.select();
//		frmTarget.DateOfDeparture.focus();//		return false;//	}
//	if (isValidDate(frmTarget.DateOfDeparture.value)==false)
//	{
//		frmTarget.DateOfDeparture.select();
//		frmTarget.DateOfDeparture.focus();//		return false;//	}
	return true;
}// ******************************************************************************************************************************
