function checkpricefield(pri)
{
	var n = 0, i=0;
	if (pri.length > 0)
	{
		for (i=0;i<pri.length;i++)
		{
			if (isNaN(pri.charAt(i)) && pri.charAt(i) != '.')
			{
				return false;
			}
		}
		if ((n = pri.indexOf(".")) != -1)
		{
			n++;
			if ((pri.length - n) > 2)
				return false;
		}
		return true;
	}
	return false;
}

function ResetAirport()
{
	document.FORM1.ukDeptCity.value = tmp;
}
function ReturnAirport()
{
	parent.tmp = airus1;
	window.close();
	awin = false;
	return;
}

function goflight()
{
	window.location = defaultsiteflight;
}
function gohotel()
{
	window.location = defaultsitehotel;
}

//***************
function closePopup()
{
	try
	{
		if (popwin != null)
			popwin.close();
	}
	catch(theException)
	{
	}
}
function checkFormErrorAIR(n)
{
	var diff2;
	var dval = 0;
	var arrstatus = 0;
	closePopup();
	if (document.FORM1.TripType.value == "Roundtrip" || document.FORM1.TripType.value == "Oneway")
	{	// check rounftrip
		document.FORM1.ukDeptCity.value = document.FORM1.ukDeptCity.value.toUpperCase();
		document.FORM1.ukArrvCity.value = document.FORM1.ukArrvCity.value.toUpperCase();
		// check depart city
		if (!checkCity(document.FORM1.ukDeptCity))
		{
			errorMessage("Departure airport code not found");
			document.FORM1.ukDeptCity.focus();
			document.FORM1.ukDeptCity.select();				
			return false;
		}
		
		// check arrival or return city
/*		// set arrival city to MCO
		if (document.FORM1.ukArrvCity.value != "MCO")
		{
			window.alert("Error Arrival airport code");
			document.FORM1.ukArrvCity.value = "MCO";
			document.FORM1.ukArrvCity.focus();
			document.FORM1.ukArrvCity.select();
			return false;
		}
*/			
		// no restriction on arrival city
		if (!checkCity(document.FORM1.ukArrvCity))
		{
			errorMessage("Arrival airport code not found");
			document.FORM1.ukArrvCity.focus();
			document.FORM1.ukArrvCity.select();
			return false;
		}
		if (document.FORM1.ukDeptCity.value == document.FORM1.ukArrvCity.value)	
		{
			errorMessage("No same cities booking");
			document.FORM1.ukDeptCity.focus();
			document.FORM1.ukDeptCity.select();
			return false;
		}
		// check for date
		if (!checkDateError())
		{
			return false;
		}
/*		inY = yy;
		outY = yy;
		if (document.FORM1.dptmon.options.selectedIndex < (mm-1)) outY = yy + 1;
		if (document.FORM1.arvmon.options.selectedIndex >= document.FORM1.dptmon.options.selectedIndex) inY = outY;
		else inY = outY + 1;
	
		startDate = new Date(outY,document.FORM1.dptmon.options.selectedIndex,document.FORM1.dptday.options.selectedIndex + 1);
		endDate = new Date(inY,document.FORM1.arvmon.options.selectedIndex,document.FORM1.arvday.options.selectedIndex + 1);
*/
/*		roundTrip = getRadioValue(document.FORM1.ukRoundTrip);
		if (roundTrip == null) roundTrip = 1;
		
		var datetemp = new Date(new String(date.getMonth()+1)+"/"+new String(date.getDate())+"/"+new String(date.getFullYear()));
		startDate = new Date(document.FORM1.ukDeptDate.value);
		endDate = new Date(document.FORM1.ukRetnDate.value);
		dateDiff = endDate - startDate;
		diff2 = endDate - datetemp;
		if ((diff2/86400000) > 331) 
		{
			document.FORM1.submitButton.disabled = false;
			alert("We cannot book for more than 11 months. Please select different dates.");
			return false;
		}
		else if ((dateDiff/86400000) < 0 && roundTrip == 1)
		{
			document.FORM1.submitButton.disabled = false;
			alert("Departure date can not be later than return date.");
			return false;
		}
		else if (((startDate-datetemp)/86400000) < 0)
		{
				document.FORM1.submitButton.disabled = false;
				alert("Departure date can not be earlier than today.");
				return false;
		}
*/		
/*		else
		{
			document.FORM1.ukDeptDate.value = document.FORM1.dptmon.value+"/"+document.FORM1.dptday.value+"/"+outY;
			document.FORM1.ukRetnDate.value = document.FORM1.arvmon.value+"/"+document.FORM1.arvday.value+"/"+inY;
		}
*/		
/*		dval = checkDate(document.FORM1.ukDeptDate.value);
		if (dval <= 1)
		{
			window.alert("Departure date must be later than today");
//			document.FORM1.dptmon.focus();
			return false;
		}
*/		
/* 05/24/2005
		else if (dval == 1 && !checkTime(document.FORM1.ukDeptTime.value))
		{
			window.alert("Departure date must be later than today");//Invalid Departure time selection");
			document.FORM1.ukDeptTime.focus();
			return false;
		}
*/
		// check for round trip return date and time
		if (roundTrip == 1)
		{
/*			var dva2 = checkDate(document.FORM1.ukRetnDate.value);
			if (dva2 <= 1)
			{
				window.alert("Return date must be later than today");
				document.FORM1.ukRetnDate.focus();
				return false;
			}
*/			
/* 05/24/2005
			else if (dva2 == 1 && !checkTime(document.FORM1.ukRetnTime.value))
			{
				window.alert("Return date must be later");// Invalid Return time selection");
				document.FORM1.ukRetnTime.focus();
					return false;
			}
*/
/*			dval= checkinvaliddate(document.FORM1.ukDeptDate.value ,document.FORM1.ukRetnDate.value);
			if (dval == 0)
			{
				window.alert("Departure date can not be later than Return date");
//				document.FORM1.dptmon.focus();
				return false;
			}
*/			
/*			else if (dval == 1)
			{
				window.alert("No same day roundtrip selection");
//				document.FORM1.dptmon.focus();
				return false;
			}
*/			
/* 05/24/2005
			else if (dval == 1 && !checkinvalidtime(document.FORM1.ukDeptTime.value,document.FORM1.ukRetnTime.value))
			{
				window.alert("Invalid Departure time and return time.\nIt also requires at least 5 hours apasrt");
				document.FORM1.ukDeptTime.focus();
				return false;
			}
*/
		}
		
		var value1 = rmleading0(document.FORM1.ukPassNum.value);
		if (value1 == -1 || isNaN(value1))
		{
			errorMessage("Enter # of adult");
			document.FORM1.ukPassNum.focus();
			document.FORM1.ukPassNum.select();
			return false;
		}	
		var value2 = rmleading0(document.FORM1.ukSenPassNum.value);
		if (value2 == -1 || isNaN(value2))
		{
			errorMessage("Enter # of senior");
			document.FORM1.ukSenPassNum.focus();
			document.FORM1.ukSenPassNum.select();
			return false;
		}		
		var value3 = rmleading0(document.FORM1.ukChdPassNum.value);
		if (value3 == -1 || isNaN(value3))
		{
			errorMessage("Enter # of children");
			document.FORM1.ukChdPassNum.focus();
			document.FORM1.ukChdPassNum.select();
			return false;
		}		
		
		var value4 = rmleading0(document.FORM1.ukInfantPassNum.value);
		if (value4 == -1 || isNaN(value4))
		{
			errorMessage("Enter # of infant in lap");
			document.FORM1.ukInfantPassNum.focus();
			document.FORM1.ukInfantPassNum.select();
			return false;
		}		
		
		var value5 = rmleading0(document.FORM1.ukInfantSeat.value);
		if (value5 == -1 || isNaN(value5))
		{
			errorMessage("Enter # of infant in seat");
			document.FORM1.ukInfantSeat.focus();
			document.FORM1.ukInfantSeat.select();
			return false;
		}		
		var total = value1 + value2 + value3 + value4 + value5;
		if (total <= 0) 
		{
			errorMessage("Check passenger field");
			document.FORM1.ukPassNum.focus();
			document.FORM1.ukPassNum.select();
			return false;
		}
	}
	else if (document.FORM1.TripType.value == "Multicity")
	{	// check for first flight
			document.FORM1.ukDeptCity1.value = document.FORM1.ukDeptCity1.value.toUpperCase();
			document.FORM1.ukArrvCity1.value = document.FORM1.ukArrvCity1.value.toUpperCase();
			// check depart city
			if (!checkCity(document.FORM1.ukDeptCity1))
			{
				errorMessage("Flight1 Departure airport code not found");
				document.FORM1.ukDeptCity1.focus();
				document.FORM1.ukDeptCity1.select();
				return false;
			}
			// check arrival city
			if (!checkCity(document.FORM1.ukArrvCity1))
			{
				errorMessage("Flight1 Arrival airport code not found");
				document.FORM1.ukArrvCity1.focus();
				document.FORM1.ukArrvCity1.select();
				return false;
			}	
			else if (document.FORM1.ukArrvCity1.value == "MCO")
				arrvstatus = 1;
			if (document.FORM1.ukDeptCity1.value == document.FORM1.ukArrvCity1.value)	
			{
				errorMessage("Flight1 no same cities booking");
				document.FORM1.ukArrvCity1.focus();
				document.FORM1.ukArrvCity1.select();
				return false;
			}
			// check for date
			var outY1 = yy;
//			if (document.FORM1.dptmon1.options.selectedIndex < (mm-1)) outY1 = yy + 1;
//			document.FORM1.ukDeptDate1.value = document.FORM1.dptmon1.value+"/"+document.FORM1.dptday1.value+"/"+outY1;

			dval = checkDate(document.FORM1.ukDeptDate1.value);
			if (dval == 0)
			{
				errorMessage("Flight1 depart date must be later than today");
				document.FORM1.ukDeptDate1.focus();
				return false;
			}
/*			else if (dval == 1 && !checkTime(document.FORM1.ukDeptTime1.value))
			{
				window.alert("Invalid Flight1 Departure Time Selection");
				document.FORM1.ukDeptTime1.focus();
				return false;
			}
*/
			// check for second flight
			document.FORM1.ukDeptCity2.value = document.FORM1.ukDeptCity2.value.toUpperCase();
			document.FORM1.ukArrvCity2.value = document.FORM1.ukArrvCity2.value.toUpperCase();
			// check depart city
			if (!checkCity(document.FORM1.ukDeptCity2))
			{
				if (document.FORM1.ukDeptCity2.value.length > 0)
				{
					errorMessage("Flight2 depart airport code not found");
					document.FORM1.ukDeptCity2.focus();
					document.FORM1.ukDeptCity2.select();
					return false;
				}
				else if (arrvstatus != 1)
				{
					errorMessage("MCO must be the trip destination");
					document.FORm1.ukArrvCity1.value = "MCO";
					document.FORM1.ukArrvCity1.focus();
					document.FORM1.ukArrvCity1.select();
					return false;
				}
				else
				{
					Initmulticity(2);
					return true;
				}
			}
			// check arrival city
			if (!checkCity(document.FORM1.ukArrvCity2))
			{
				if (document.FORM1.ukArrvCity2.value.length > 0)
				{
					errorMessage("Flight2 arrival airport code not found");
					document.FORM1.ukArrvCity2.focus();
					document.FORM1.ukArrvCity2.select();
					return false;
				}
/*				else if (arrstatus != 1)
				{
					alert("MCO must be the trip destination");
					document.FORm1.ukArrvCity1.value = "MCO";
					document.FORM1.ukArrvCity1.focus();
					document.FORM1.ukArrvCity1.select();
					return false;
				}
*/
				else
				{
					Initmulticity(2);
					return true;
				}
			}	
			else if (document.FORM1.ukArrvCity2.value == "MCO")
				arrstatus = 2;
			if (document.FORM1.ukDeptCity2.value == document.FORM1.ukArrvCity2.value)
			{
				errorMessage("Flight2 no same cities booking");
				document.FORM1.ukDeptCity2.focus();
				document.FORM1.ukDeptCity2.select();
				return false;
			}
			// check for date
			var outY2 = yy;
//			if (document.FORM1.dptmon2.options.selectedIndex < (mm-1)) outY2 = yy + 1;
//			document.FORM1.ukDeptDate2.value = document.FORM1.dptmon2.value+"/"+document.FORM1.dptday2.value+"/"+outY2;
			dval = checkDate(document.FORM1.ukDeptDate2.value);
			if (dval == 0)
			{
				errorMessage("Flight2 depart date must be later than today");
				document.FORM1.ukDeptDate2.focus();
				return false;
			}
/*			else if (dval == 1 && !checkTime(document.FORM1.ukDeptTime2.value))
			{
				window.alert("Invalid Flight2 Departure Time Selection");
				document.FORM1.ukDeptTime2.focus();
				return false;
			}
*/
			// check for thrid flight
			document.FORM1.ukDeptCity3.value = document.FORM1.ukDeptCity3.value.toUpperCase();
			document.FORM1.ukArrvCity3.value = document.FORM1.ukArrvCity3.value.toUpperCase();
			// check depart city
			if (!checkCity(document.FORM1.ukDeptCity3))
			{
				if (document.FORM1.ukDeptCity3.value.length > 0)
				{
					errorMessage("Flight3 departure airport code not found");
					document.FORM1.ukDeptCity3.focus();
					document.FORM1.ukDeptCity3.select();
					return false;
				}
/*				else if (arrstatus < 1 || arrstatus > 2)
				{
					alert("MCO must be one of the trip destination");
					document.FORM1.ukArrvCity2.value = "MCO";
					document.FORM1.ukArrvCity2.focus();
					document.FORM1.ukArrvCity2.select();
					return false;
				}
*/
				else
				{
					Initmulticity(3);
					return true;
				}
			}
			// check arrival city
			if (!checkCity(document.FORM1.ukArrvCity3))
			{
				if (document.FORM1.ukArrvCity3.value.length > 0)
				{
					errorMessage("Flight3 arrival airport code not found");
					document.FORM1.ukArrvCity3.focus();
					document.FORM1.ukArrvCity3.select();
					return false;
				}
/*				else if (arrstatus < 1 || arrstatus > 2)
				{
					alert("MCO must be one of the trip destination");
					document.FORM1.ukArrvCity2.value = "MCO";
					document.FORM1.ukArrvCity2.focus();
					document.FORM1.ukArrvCity2.select();
					return false;
				}
*/
				else
				{
					Initmulticity(3);
					return true;
				}
			}	
			else if (document.FORM1.ukArrvCity3.value == "MCO")
				arrstatus = 3;
			if (document.FORM1.ukDeptCity3.value == document.FORM1.ukArrvCity3.value)
			{
				errorMessage("Flight3 no same cities booking");
				document.FORM1.ukDeptCity3.focus();
				document.FORM1.ukDeptCity3.select();
				return false;
			}
			// check for date
			var outY3 = yy;
//			if (document.FORM1.dptmon3.options.selectedIndex < (mm-1)) outY3 = yy + 1;
//			document.FORM1.ukDeptDate3.value = document.FORM3.dptmon1.value+"/"+document.FORM1.dptday3.value+"/"+outY3;
			dval = checkDate(document.FORM1.ukDeptDate3.value);
			if (dval == 0)
			{
				errorMessage("Flight3 depart date must be later than today");
				document.FORM1.ukDeptDate3.focus();
				return false;
			}
/*			else if (dval == 1 && !checkTime(document.FORM1.ukDeptTime3.value))
			{
				window.alert("Invalid Flight3 Departure Time Selection");
				document.FORM1.ukDeptTime3.focus();
				return false;
			}
*/
			// check for forth flight
			document.FORM1.ukDeptCity4.value = document.FORM1.ukDeptCity4.value.toUpperCase();
			document.FORM1.ukArrvCity4.value = document.FORM1.ukArrvCity4.value.toUpperCase();
			// check depart city
			if (!checkCity(document.FORM1.ukDeptCity4))
			{
				if (document.FORM1.ukDeptCity4.value.length > 0)
				{
					errorMessage("Flight4 depart airport code not found");
					document.FORM1.ukDeptCity4.focus();
					document.FORM1.ukDeptCity4.select();
					return false;
				}
/*				else if (arrstatus < 1 || arrstatus > 3)
				{
					alert("MCO must be one of the trip destination");
					document.FORM1.ukArrvCity3.value = "MCO";
					document.FORM1.ukArrvCity3.focus();
					document.FORM1.ukArrvCity3.select();
					return false;
				}
*/
				else
				{
					Initmulticity(4);
					return true;
				}
			}
			// check arrival city
			if (!checkCity(document.FORM1.ukArrvCity4))
			{
				if (document.FORM1.ukArrvCity4.value.length > 0)
				{
					errorMessage("Flight4 arrival airport code not found");
					document.FORM1.ukArrvCity4.focus();
					document.FORM1.ukArrvCity4.select();
					return false;
				}
/*				else if (arrstatus < 1 || arrstatus > 3)
				{
					alert("MCO must be one of the trip destination");
					document.FORM1.ukArrvCity3.value = "MCO";
					document.FORM1.ukArrvCity3.focus();
					document.FORM1.ukArrvCity3.select();
					return false;
				}
*/
				else
				{
					Initmulticity(4);
					return true;
				}
			}	
			else if (document.FORM1.ukArrvCity4.value == "MCO")
				arrstatus = 4;
			if (document.FORM1.ukDeptCity4.value == document.FORM1.ukArrvCity4.value)
			{
				errorMessage("Flight4 no same cities booking");
				document.FORM1.ukDeptCity4.focus();
				document.FORM1.ukDeptCity4.select();
				return false;
			}
/*			if (arrstatus < 1 || arrstatus > 4)
			{
				alert("MCO must be one of the trip destination");
				document.FORM1.ukArrvCity3.value = "MCO";
				document.FORM1.ukArrvCity3.focus();
				document.FORM1.ukArrvCity3.select();
				return false;
			}
*/
			// check for date
			var outY4 = yy;
//			if (document.FORM1.dptmon4.options.selectedIndex < (mm-1)) outY4 = yy + 1;
//			document.FORM1.ukDeptDate4.value = document.FORM1.dptmon4.value+"/"+document.FORM1.dptday4.value+"/"+outY4;
			dval = checkDate(document.FORM1.ukDeptDate4.value);
			if (dval == 0)
			{
				errorMessage("Flight4 depart date must be later than today");
				document.FORM1.ukDeptDate4.focus();
				return false;
			}
/*			else if (dval == 1 && !checkTime(document.FORM1.ukDeptTime4.value))
			{
				window.alert("Invalid Flight4 Departure Time Selection");
				document.FORM1.ukDeptTime4.focus();
				return false;
			}
*/
			var value1 = rmleading0(document.FORM1.ukPassNum.value);
			var value2 = rmleading0(document.FORM1.ukSenPassNum.value);
			var value3 = rmleading0(document.FORM1.ukChdPassNum.value);
			var value4 = rmleading0(document.FORM1.ukInfantPassNum.value);
			var value5 = rmleading0(document.FORM1.ukInfantSeat.value);
			var total = value1 + value2 + value3 + value4 + value5;
			if (total == 0) {
				errorMessage("Enter at least 1 passenger");
				document.FORM1.ukPassNum.focus();
				document.FORM1.ukPassNum.select();
				return false;
			}
	}
	return true;
}

function getState(n)
{
	var state = "";
	var data = "";
	var begining = 0, middle=0, end=0, st =0, st2 =0;
	var name = "", value = "";
	var temp = "";
	var dmon=0, dday=0, dyear=0,rmon=0,rday=0,ryear=0;
// 12/03/2004	
	if (n == null || n == '')
		state = "Roundtrip";
	else if (n == 'Roundtrips' || n == 'Roundtripc' || n == 'Onewayc' || n == 'Oneways' || n == 'Multicityc')
		state = n.substring(0, n.length-1);
	else state = n;
	data = getck(state);
	if (state == 'Roundtrip' || state == 'Oneway') 
	{
		if (data != null && data.length > 0)
		{
			while(begining < data.length)
			{
				middle = data.indexOf("=", begining);
				end = data.indexOf("{}", begining);
				if (end == -1)
					end = data.length;
				if ((middle > end) || (middle == -1))
				{
					name = data.substring(begining, end);
					value = '';
				}
				else
				{
					name = data.substring(begining, middle);
					value = data.substring(middle+1, end);
				}
				begining = end + 2;
				if (name == "airsel")
					setselection(unescape(value));
				else if (name == "dc1")
				{
					temp = parseparam("dc1");
					if (temp.length == 0)
						document.FORM1.ukDeptCity.value = unescape(value);
					else
						document.FORM1.ukDeptCity.value = temp;
				}
				else if (name == "da1")
				{
					temp = parseparam("da1");
					if (temp.length == 0)
						document.FORM1.ukArrvCity.value = unescape(value);
					else
						document.FORM1.ukArrvCity.value = temp;
				}
				else if (name == "dd1")
				{
					document.FORM1.ukDeptDate.value = unescape(value);
					if (document.FORM1.ukDeptDate.value != null && (st = document.FORM1.ukDeptDate.value.indexOf("/")) != -1 && (st2 = document.FORM1.ukDeptDate.value.indexOf("/", st+1)) != -1)
					{
						dmon = parseInt(document.FORM1.ukDeptDate.value.substring(0, st));
						dday = parseInt(document.FORM1.ukDeptDate.value.substring(st+1, st2));
						dyear = parseInt(document.FORM1.ukDeptDate.value.substring(st2+1));
//						document.FORM1.dptmon.value = document.FORM1.dptmon.options[dmon-1].value;
//						document.FORM1.dptday.value = document.FORM1.dptday.options[dday-1].value;
					}
					else
					{
						dmon = mm;
						dday = dd;
						dyear = yy;
						if (dmon < mm || (dmon == mm && dday <= dd))
						{
							dmon = mm;
							dday = dd+14;
							if (dmon == 2)
							{
								dday %= 29;
								dday++;
								dmon += (dday / 28);
							}
							else if (dmon == 1 || dmon == 3 || dmon == 5 || dmon == 7 || dmon == 8 || dmon == 10 || dmon == 12)
							{
								dday %= 32;
								dday++;
								dmon += (dday / 31);
							}
							else
							{
								dday %= 31;
								dday++;
								dmon += (dday / 30);
							}
							if (dmon == 13)
							{
								dmon = 1;
								dyear++;
							}
						}
//						document.FORM1.dptmon.value = document.FORM1.dptmon.options[dmon-1].value;
//						document.FORM1.dptday.value = document.FORM1.dptday.options[dday-1].value;
//						document.FORM1.ukDeptDate.value = new String(dmon)+"/"+new String(dday)+"/"+new String(dyear);
					}
				}
				else if (name == "dt1")
					document.FORM1.ukDeptTime.value = unescape(value);
				else if (name == "ad1" && state == 'Roundtrip')
				{
					document.FORM1.ukRetnDate.value = unescape(value);
					if (document.FORM1.ukRetnDate.value != null && (st = document.FORM1.ukRetnDate.value.indexOf("/")) != -1 && (st2 = document.FORM1.ukRetnDate.value.indexOf("/", st+1)) != -1)
					{
						rmon = parseInt(document.FORM1.ukRetnDate.value.substring(0, st));
						rday = parseInt(document.FORM1.ukRetnDate.value.substring(st+1, st2));
						ryear = parseInt(document.FORM1.ukRetnDate.value.substring(st2+1));
//						document.FORM1.arvmon.value = document.FORM1.arvmon.options[rmon-1].value;
//						document.FORM1.arvday.value = document.FORM1.arvday.options[rday-1].value;
					}
					else
					{
						rmon = dmon;
						rday = dday;
						ryear = dyear;
						if (rmon < mm || (rmon == mm && rday < dd) || rmon < dmon || (rmon == dmon && rday <= dday))
						{
							rmon = dmon;
							rday = dday+7;
							if (rmon == 2)
							{
								rday %= 29;
								rday++;
								rmon += (rday / 28);
							}
							else if (rmon == 1 || rmon == 3 || rmon == 5 || rmon == 7 || rmon == 8 || rmon == 10 || rmon == 12)
							{
								rday %= 32;
								rday++;
								rmon += (rday / 31);
							}
							else
							{
								rday %= 31;
								rday++;
								rmon += (rday / 30);
							}
							if (rmon == 13)
							{
								rmon = 1;
								ryear++;
							}
						}
//						document.FORM1.arvmon.value = document.FORM1.arvmon.options[rmon-1].value;
//						document.FORM1.arvday.value = document.FORM1.arvday.options[rday-1].value;
//						document.FORM1.ukRetnDate.value = new String(rmon)+"/"+new String(rday)+"/"+new String(ryear);
					}
				}
				else if (name == "at1" && state == 'Roundtrip')
					document.FORM1.ukRetnTime.value = unescape(value);
				else if (name == "sp")
					document.FORM1.ukSenPassNum.value = unescape(value);
	//			else if (name == "fs" && unescape(value) != '0')
	//				document.FORM1.ukFlightStop.value = unescape(value);
				else if (name == "fc")
					document.FORM1.ukFlightClass.value = unescape(value);
				else if (name == "pn")
					document.FORM1.ukPassNum.value = unescape(value);
				else if (name == "cp")
					document.FORM1.ukChdPassNum.value = unescape(value);
				else if (name == "ifl")
					document.FORM1.ukInfantPassNum.value = unescape(value);
				else if (name == "ifs")
					document.FORM1.ukInfantSeat.value = unescape(value);
			}
		}
		else
		{
			dday = dd + 14;
			dmon = mm;
			limit = getmaxdate(1);
			if (dday > limit)
			{
				dday -= limit;
				dmon++;
 				if(dmon > 12)
					dmon = 1;
			}
//			document.FORM1.dptmon.value = document.FORM1.dptmon.options[dmon-1].value;
//			document.FORM1.dptday.value = document.FORM1.dptday.options[dday-1].value;
			rday = dday + 7;
			rmon = dmon;
			limit = getmaxdate(1);
			if (rday > limit)
			{
				rday -= limit;
				rmon++;
 				if(rmon > 12)
					rmon = 1;
			}
//			document.FORM1.arvmon.value = document.FORM1.arvmon.options[rmon-1].value;
//			document.FORM1.arvday.value = document.FORM1.arvday.options[rday-1].value;
			return;
		}
	}
	else if (state == "Multicity")
	{
		var temp = "";
		var st = 0, st2 = 0;
		while(begining < data.length)
		{
			middle = data.indexOf("=", begining);
			end = data.indexOf("{}", begining);
			if (end == -1)
				end = data.length;
			if ((middle > end) || (middle == -1))
			{
				name = data.substring(begining, end);
				value = '';
			}
			else
			{
				name = data.substring(begining, middle);
				value = data.substring(middle+1, end);
			}
			begining = end + 2;
			if (name == "airsel")
				setselection(unescape(value));
			else if (name == "dc1")
			{
				temp = unescape(value);
				st = 0, st2 = 0;
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptCity1.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptCity2.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptCity3.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
					document.FORM1.ukDeptCity4.value = temp.substring(st, st2);
				else
					document.FORM1.ukDeptCity4.value = temp.substring(st);
			}
			else if (name == "da1")
			{
				temp = unescape(value);
				st = 0, st2 = 0;
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukArrvCity1.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukArrvCity2.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukArrvCity3.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(";", st)) != -1 || (st2 = temp.indexOf(",", st)) != -1)
					document.FORM1.ukArrvCity4.value = temp.substring(st, st2);
				else
					document.FORM1.ukArrvCity4.value = temp.substring(st);
			}
			else if (name == "dd1")
			{
				temp = unescape(value);
				st = 0, st2 = 0;
				if ((st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptDate1.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptDate2.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptDate3.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(",", st)) != -1)
					document.FORM1.ukDeptDate4.value = temp.substring(st, st2);
				else
					document.FORM1.ukDeptDate4.value = temp.substring(st);
			}
			else if (name == "dt1")
			{
				temp = unescape(value);
				st = 0, st2 = 0;
				if ((st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptTime1.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptTime2.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(",", st)) != -1)
				{
					document.FORM1.ukDeptTime3.value = temp.substring(st, st2);
					st = st2+1;
				}
				if ((st2 = temp.indexOf(",", st)) != -1)
					document.FORM1.ukDeptTime4.value = temp.substring(st, st2);
				else
					document.FORM1.ukDeptTime4.value = temp.substring(st);
			}
			else if (name == "sp")
				document.FORM1.ukSenPassNum.value = unescape(value);
//			else if (name == "fs")
//				document.FORM1.ukFlightStop.value = unescape(value);
			else if (name == "fc")
				document.FORM1.ukFlightClass.value = unescape(value);
			else if (name == "pn")
				document.FORM1.ukPassNum.value = unescape(value);
			else if (name == "cp")
				document.FORM1.ukChdPassNum.value = unescape(value);
			else if (name == "ifl")
				document.FORM1.ukInfantPassNum.value = unescape(value);
			else if (name == "ifs")
				document.FORM1.ukInfantSeat.value = unescape(value);
		}
	}
}
function parseparam(type)
{
	var name = "", value = "";
	var st = 0, st2 = 0, pos = 0;
	var temp = "";
	if (ukparam != null && ukparam.length > 0)
	{
		while ((st2 = ukparam.indexOf("()", st)) != -1)
		{
			temp = ukparam.substring(st, st2);
			st = st2+2;
			if ((pos = temp.indexOf("[]")) != -1)
			{
				name = temp.substring(0, pos);
				value = temp.substring(pos+2);
				if (name == type)
					return value;
			}
		}
	}
	return "";
}
function setselection(temp)
{
	
}


function rmleading0(str)
{
 try
 {
  	for (i=0; i<str.length;i++)
  	{
  		if (str.charAt(i) != '0')
  			return parseInt(str.substring(i));
  	}
	}
	catch(theException)
	{
	 	 return -1;
	}
	return 0;
}
function checkinvaliddate(ddate, adate)
{
	var st = 0, st2 =0;
	var dmm = 0;
	var ddd = 0;
	var dyy = 0;
	var amm = 0;
	var add = 0;
	var ayy = 0;
	st = ddate.indexOf("/");
	dmm = rmleading0(ddate.substring(0, st));
	st++;
	st2 = ddate.indexOf("/", st);
	ddd = rmleading0(ddate.substring(st, st2));
	dyy = rmleading0(ddate.substring(st2+1));
	st = adate.indexOf("/");
	amm = rmleading0(adate.substring(0, st));
	st++;
	st2 = adate.indexOf("/", st);
	add = rmleading0(adate.substring(st, st2));
	ayy = rmleading0(adate.substring(st2+1));
	if (dyy <= ayy)
	{
		if (dyy == ayy)
		{
			if (dmm > amm)
				return 0;
			else if (dmm==amm)
			{
				if (ddd >add)
					return 0;
				else if (ddd == add)
					return 1;
			}
		}
		return 2;
	}
	return 0;
}
function checkinvalidtime(dtm, atm)
{
	var dhh =0;
	var dmm = 0;
	var ahh = 0;
	var amm = 0;
	var apm = "";
	if (dtm == "ANY TIME")
		dhh = 23;
	else if (dtm == "Early Morning")
		dhh = 5;
	else if (dtm == "Morning")
		dhh = 8;
	else if (dtm == "Late Morning")
		dhh = 11;
	else if (dtm == "Noon")
		dhh = 12;
	else if (dtm == "Afternoon")
		dhh = 15;
	else if (dtm == "Evening")
		dhh = 19;
	else if (dtm == "Late Evening")
		dhh = 23;
	else 
	{
		if ((st = dtm.indexOf(":")) != -1)
		{
			dhh = rmleading0(dtm.substring(0, st));
			st++
			dmm = rmleading0(dtm.substring(st, st+2));
			apm = dtm.substring(st+2);
			if (apm == "PM" && dhh < 12)
				dhh += 12;
			else if (apm == "AM" && dhh == 12)
				dhh += 12;
		}
	}
	if (atm == "ANY TIME")
		ahh = 23;
	else if (atm == "Early Morning")
		ahh = 5;
	else if (atm == "Morning")
		ahh = 8;
	else if (atm == "Late Morning")
		ahh = 11;
	else if (atm == "Noon")
		ahh = 12;
	else if (atm == "Afternoon")
		ahh = 15;
	else if (atm == "Evening")
		ahh = 19;
	else if (atm == "Late Evening")
		ahh = 23;
	else 
	{
		if ((st = atm.indexOf(":")) != -1)
		{
			ahh = rmleading0(atm.substring(0, st));
			st++
			amm = rmleading0(atm.substring(st, st+2));
			apm = atm.substring(st+2);
			if (apm == "PM" && ahh < 12)
				ahh += 12;
			else if (apm == "AM" && ahh == 12)
				ahh += 12;
		}
	}
	if ((ahh-dhh)>5)
		return true;
	else return false;
}
/*
function checkCity(city)
{
	var st=0, st2=0;
	city.value = trim(city.value,"both");
	if (city.value != "" && city.value.length == 3) 
	{
		if (airportcode.indexOf(city.value) != -1)
			return true;
		if ((st = city2airport_code.indexOf(city.value+",")) != -1 && (st2 = city2airport_code.indexOf("_", st+4)) != -1)
		{
			city.value=city2airport_code.substring(st+4, st2);
			return true;
		}
	}
	else if (city.value != "" && city.value.length > 3)
		return true;
	return false;
}
*/
function checkCity(cityobj)
{
	var state = "", country="", countryfname = "", statefname ="";
	var st = 0;
	var st2 = 0;
	var pos1 = 0;
	var pos2 = 0;
	var sttemp = "", temp="", temp1="";
	var cities = "<option value='' selected>Please select a city";
	var city = trim(cityobj.value,"both");
	if (city.length > 0)
	{
		if ((st = city.indexOf(",")) != -1)
		{
			state = trim(city.substring(st+1), "both");
			city = trim(city.substring(0, st), "both");
			if (city == '' && state == '')
			{
				return false;
			}
			else if ((st = state.indexOf(",")) != -1)
			{
				country = trim(state.substring(st+1), "both");
				state = trim(state.substring(0, st), "both");
				if (country == null)
					country = "";
				if (state == null || state.length == 0)
					state = "";
			}
		}
		else if (city.length == 3) 
		{
			if (airportcode.indexOf(city) != -1)
			{
//				cityobj.value = city;
				return true;
			}
			else if (city2airport_code.indexOf(city+",") != -1)
			{
//				cityobj.value = city;
				return true;
			}
			return false;
		}
		if (city == '')
		{
			return false;
		}
		else if (state == '' && country == '')
		{
			pos1 = 0; pos2 = 0;
			while ((pos2 = USCities1.indexOf(("_"+city+","), pos1)) != -1)
			{
				if (ukCityCount == 0)
				{
					ukCityAbr = USCities1.substring(pos2+1, pos2+city.length+4)+",US";
					ukCity = ukCityAbr;
				}
				sttemp = USCities1.substring(pos2+city.length+2, pos2+city.length+4);
				if ((st2 = usfabr.indexOf(","+sttemp+"_")) != -1 && (st = usfabr.lastIndexOf("_", st2)) != -1)
				{
					cities += "<option value='"+city+","+usfabr.substring(st+1, st2)+",US"+"'>"+city+","+
								usfabr.substring(st+1, st2)+",US";
					if (ukCityCount == 0)
						ukCity = city+","+usfabr.substring(st+1, st2)+",US";
				}
				else
					cities += "<option value='"+USCities1.substring(pos2+1, pos2+city.length+4)+",US"+"'>"+USCities1.substring(pos2+1, pos2+city.length+4)+",US";
				pos1 = pos2+city.length+4;
				ukCityCount++;
			}
			pos1 = 0; pos2 = 0;
			while ((pos2 = USCities2.indexOf(("_"+city+","), pos1)) != -1)
			{
				if (ukCityCount == 0)
				{
					ukCityAbr = USCities2.substring(pos2+1, pos2+city.length+4)+",US";
					ukCity = ukCityAbr;
				}
				sttemp = USCities2.substring(pos2+city.length+2, pos2+city.length+4);
				if ((st2 = usfabr.indexOf(","+sttemp+"_")) != -1 && (st = usfabr.lastIndexOf("_", st2)) != -1)
				{
					cities += "<option value='"+city+","+usfabr.substring(st+1, st2)+",US"+"'>"+city+","+usfabr.substring(st+1, st2)+",US";
					if (ukCityCount == 0)
						ukCity = city+","+usfabr.substring(st+1, st2)+",US";
				}
				else
					cities += "<option value='"+USCities2.substring(pos2+1, pos2+city.length+4)+",US"+"'>"+USCities2.substring(pos2+1, pos2+city.length+4)+",US";
				pos1 = pos2+city.length+4;
				ukCityCount++;
			}
			pos1 = 0; pos2 = 0;
			while ((pos2 = CanadaCities.indexOf(("_"+city+","), pos1)) != -1)
			{
				if (ukCityCount == 0)
				{
					ukCityAbr = CanadaCities.substring(pos2+1, pos2+city.length+4)+",CA";
					ukCity = ukCityAbr;
				}
				sttemp = CanadaCities.substring(pos2+city.length+2, pos2+city.length+4);
				if ((st2 = canfabr.indexOf(","+sttemp+"_")) != -1 && (st = canfabr.lastIndexOf("_", st2)) != -1)
				{
					cities += "<option value='"+city+","+canfabr.substring(st+1, st2)+",CANADA"+"'>"+city+","+canfabr.substring(st+1, st2)+",CANADA";
					if (ukCityCount == 0)
						ukCity = city+","+canfabr.substring(st+1, st2)+",CANADA";
				}
				else
					cities += "<option value='"+CanadaCities.substring(pos2+1, pos2+city.length+4)+",CANADA"+"'>"+CanadaCities.substring(pos2+1, pos2+city.length+4)+",CANADA";
				pos1 = pos2+city.length+4;
				ukCityCount++;
			}
			pos1 = 0; pos2 = 0;
			while ((pos2 = WorldCities1.indexOf(("_"+city+","), pos1)) != -1)
			{
				if (ukCityCount == 0)
				{
					ukCityAbr = city+",,"+WorldCities1.substring(pos2+city.length+2, pos2+city.length+4);
					ukCity = ukCityAbr;
				}
				sttemp = WorldCities1.substring(pos2+city.length+2, pos2+city.length+4);
				if ((st2 = countrynabr.indexOf(","+sttemp+"_")) != -1 && (st = countrynabr.lastIndexOf("_", st2)) != -1)
				{
					cities += "<option value='"+city+","+countrynabr.substring(st+1, st2)+"'>"+city+","+countrynabr.substring(st+1, st2);
					if (ukCityCount == 0)
					{
						ukCityAbr = city+",,"+countrynabr.substring(st+1, st2);
						ukCity = ukCityAbr;
					}
				}
				else
					cities += "<option value='"+WorldCities1.substring(pos2+1, pos2+city.length+4)+"'>"+WorldCities1.substring(pos2+1, pos2+city.length+4);
				pos1 = pos2+city.length+4;
				ukCityCount++;
			}
			pos1 = 0; pos2 = 0;
			while ((pos2 = WorldCities2.indexOf(("_"+city+","), pos1)) != -1)
			{
				if (ukCityCount == 0)
				{
					ukCityAbr = city+",,"+WorldCities2.substring(pos2+city.length+2, pos2+city.length+4);
					ukCity = ukCityAbr;
				}
				sttemp = WorldCities2.substring(pos2+city.length+2, pos2+city.length+4);
				if ((st2 = countrynabr.indexOf(","+sttemp+"_")) != -1 && (st = countrynabr.lastIndexOf("_", st2)) != -1)
				{
					cities += "<option value='"+city+","+countrynabr.substring(st+1, st2)+"'>"+city+","+countrynabr.substring(st+1, st2);
					if (ukCityCount == 0)
					{
						ukCityAbr = city+",,"+countrynabr.substring(st+1, st2);
						ukCity = ukCityAbr;
					}
				}
				else
					cities += "<option value='"+WorldCities2.substring(pos2+1, pos2+city.length+4)+"'>"+WorldCities2.substring(pos2+1, pos2+city.length+4);
				pos1 = pos2+city.length+4;
				ukCityCount++;
			}
			pos1 = 0; pos2 = 0;
			while ((pos2 = WorldCities3.indexOf(("_"+city+","), pos1)) != -1)
			{
				if (ukCityCount == 0)
				{
					ukCityAbr = city+",,"+WorldCities3.substring(pos2+city.length+2, pos2+city.length+4);
					ukCity = ukCityAbr;
				}
				sttemp = WorldCities3.substring(pos2+city.length+2, pos2+city.length+4);
				if ((st2 = countrynabr.indexOf(","+sttemp+"_")) != -1 && (st = countrynabr.lastIndexOf("_", st2)) != -1)
				{
					cities += "<option value='"+city+","+countrynabr.substring(st+1, st2)+"'>"+city+","+countrynabr.substring(st+1, st2);
					if (ukCityCount == 0)
					{
						ukCityAbr = city+",,"+countrynabr.substring(st+1, st2);
						ukCity = ukCityAbr;
					}
				}
				else
					cities += "<option value='"+WorldCities3.substring(pos2+1, pos2+city.length+4)+"'>"+WorldCities3.substring(pos2+1, pos2+city.length+4);
				pos1 = pos2+city.length+4;
				ukCityCount++;
			}
			if (ukCityCount == 0)
			{
				return false;
			}
			else if (ukCityCount == 1)
			{
				cityobj.value = ukCityAbr;
				return true;
			}
			else
			{
				ukCityAbr = cities;
			}
		}
		else if (state != '')
		{	// must be US or Canada or International
			// check abr code
			if (state == "UK")
			{
				country = "GB";
				countryfname = "GREAT BRITAIN";
				state = "";
			}
			else if (state == "HK")
			{
				country = "CN";
				countryfname = "CHINA";
				state = "";
			}
			else if ((pos2 = usfabr.indexOf(","+state+"_")) != -1 && (pos1 = usfabr.lastIndexOf("_", pos2)) != -1)
			{
				statefname = usfabr.substring(pos1+1, pos2);
				country = "US";
				countryfname = "US";
			}
			else if ((pos2 = canfabr.indexOf(","+state+"_")) != -1 && (pos1 = canfabr.lastIndexOf("_", pos2)) != -1)
			{
				statefname = canfabr.substring(pos1+1, pos2);
				country = "CA";
				countryfname = "CANADA";
			}
			else if ((pos1 = usfabr.indexOf("_"+state+",")) != -1 && (pos2 = usfabr.indexOf("_", pos1+state.length+2)) != -1)
			{
				statefname = state;
				state = usfabr.substring(pos1+state.length+2, pos2);
				country = "US";
				countryfname = "US";
			}
			else if ((pos1 = canfabr.indexOf("_"+state+",")) != -1 && (pos2 = canfabr.indexOf("_", pos1+state.length+2)) != -1)
			{
				statefname = state;
				state = canfabr.substring(pos1+state.length+2, pos2);
				country = "CA";
				countryfname = "CANADA";
			}
			else if ((pos2 = countrynabr.indexOf(","+state+"_")) != -1 && (pos1 = countrynabr.lastIndexOf("_", pos2)) != -1)
			{
				country = state;
				countryfname = countrynabr.substring(pos1+1, pos2);
				state = "";
			}
			else if ((pos1 = countrynabr.indexOf("_"+state+",")) != -1 && (pos2 = countrynabr.indexOf("_", pos1+state.length+2)) != -1)
			{
				countryfname = state;
				country = countrynabr.substring(pos1+state.length+2, pos2);
				state = "";
			}
			if (country.length > 0)
			{
				if (country == "US" || country == "CA")
				{
					cityobj.value = city+","+statefname+","+countryfname;
					ukCity = city+","+statefname+","+countryfname;
					ukCityAbr = city+","+state+","+country;
				}
				else
				{
					cityobj.value = city+","+countryfname;
					ukCity = city+",,"+countryfname;
					ukCityAbr = city+",,"+country;
				}
			}
			else
			{
				cityobj.value = city+","+statefname;
				ukCity = city+",,"+statefname;
				ukCityAbr = city+",,"+state;
			}
		}
		else
		{
			temp = ","+country+"_";
			pos2 = countrynabr.indexOf(temp);
			pos1 = countrynabr.lastIndexOf("_", pos2);
			if (pos2 != -1 && pos1 != -1)
			{
				countryfname = countrynabr.substring(pos1+1, pos2);
			}
			else
			{
				temp1 = "_"+country+",";
				pos1 = countrynabr.indexOf(temp1);
				pos2 = countrynabr.indexOf("_", pos1+temp1.length);
//				if ((pos1 = countrynabr.indexOf(temp1)) != -1 && (pos2 = counbtrynabr.indexOf("_", pos1+temp1)) != -1)
				if (pos1 != -1 && pos2 != -1)
				{
					countryfname = country;
					country = countrynabr.substring(pos1+temp1.length, pos2);
				}
			}
			cityobj.value = city+","+countryfname;
			ukCity = city+",,"+countryfname;
			ukCityAbr = city+",,"+country;
		}
	}
	else
	{
		return false;
	}
	// convert state, country to abbr.
	return true;
}

function getmaxdate(delay){
    var limit = 30;
    var leap = 0;

	if(((yy % 4 == 0) && (yy % 100 != 0)) || (yy % 400 == 0))
		leap = 1;
    if(mm == 1||mm == 3||mm == 5||mm == 7||mm == 8||mm == 10||mm == 12)
        limit = 31;
    else if(mm == 4||mm == 6||mm == 9||mm == 11)
        limit = 30;
    else if(mm == 2)
	{
        if(leap == 1)
            limit = 29;
        else
            limit = 28;
    }
    return limit;
}

function checkDate(dt)
{
	var st = 0, st2 =0;
	var mon = 0;
	var day = 0;
	var year = 0;
	var syear = "";
	var now = new Date();
	var d = now.getDate();
	var m = now.getMonth() + 1;
	var y = now.getYear();
	if (y < 1900)
		y += 1900;
	if ((st = dt.indexOf("/")) != -1)
	{
		mon = rmleading0(dt.substring(0, st));
		st++;
		if ((st2 = dt.indexOf("/",st)) != -1)
		{
			day = rmleading0(dt.substring(st, st2));
			syear = dt.substring(st2+1);
			if (syear.length == 2)
				year = rmleading0("20"+syear);
			else 
				year = rmleading0(syear);	// could be invalid
			if (year == y)
			{
				if (mon > m)
					return 2;
				else if (mon == m && day > d)
					return 2;
				else if (mon == m && day == d)
					return 1;
			}
			else if (year > y && year <= y+1)
				return 2;
		}
	}
	return 0;
}
function getAdvDate(delay){
    var limit = 30;
    var leap = 0;
	var rtn = "";
	var now = new Date();
	var date = now.getDate()+delay;
	var month = now.getMonth()+1;
	var year = now.getYear();
	if (year < 1900)
		year += 1900;

	if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
		leap = 1;
        
        if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
            limit = 31;
        else if(month == 4||month == 6||month == 9||month == 11)
            limit = 30;
        else if(month == 2)
            if(leap == 1)
                limit = 29;
            else
                limit = 28;
        if(date>limit)
	{

 		if((month+1)>12)
		    rtn =  1+"/"+(date-limit)+"/"+(year+1);
		else
		   rtn = (month+1)+"/"+(date-limit)+"/"+year;

        }
	else
	{

	    rtn = month+"/"+date+"/"+year;
	}
	return rtn;
}

function closeDocument()
{
   document.close();
}


function getRadioValue(radioObject)
{
	var i =0;
	var value = null;
	try
	{
  	for(i=0;i<radioObject.length;i++)
  	{
  		if(radioObject[i].checked)
			{
  			value = radioObject[i].value;
  			break;
  		}
  	}
	}
	catch(theException)
	{
	 try
	 {
	 		value = radioObject.value;
	 }
	 catch(theException)
	 {
	 }
	}
	return value;
}
function setck(name, value, state)
{
	if (state == true)
		document.cookie = name + "="+ escape(value)+ "; expires="+week[wk]+", "+ ((dd<10)?"0"+new String(dd):new String(dd))+"-"+month[mm-1]+"-"+new String(yy+10)+" 00:00:01 GMT";
	else
		document.cookie = name + "="+ escape(value);
}
function getck(ckname)
{
	var name, value;
	var begining, middle, end;
/*	var cookies = new Object();
	for (name in cookies)
	{
		cookies = new Object();
		break;
	}
*/	
	begining = 0;
	while(begining < document.cookie.length)
	{
		middle = document.cookie.indexOf("=", begining);
		end = document.cookie.indexOf(";", begining);
		if (end == -1)
			end = document.cookie.length;
		if ((middle > end) || (middle == -1))
		{
			name = document.cookie.substring(begining, end);
			value = '';
		}
		else
		{
			name = document.cookie.substring(begining, middle);
			value = document.cookie.substring(middle+1, end);
		}
//		cookies[name] = unescape(value);
		begining = end + 2;
		if (name == ckname)
			return unescape(value);
	}
	return "";
}
function removeck(name)
{
	document.cooke = name + "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function sendToTopframeAIR()
{
//	document.FORM1.submitButton.disabled = true;
    if(checkFormErrorAIR())
    {
		if(document.FORM1.TripType.value == "Roundtrip" || document.FORM1.TripType.value == "Oneway")
		{
			deptCity = document.FORM1.ukDeptCity.value.toUpperCase();
			arrvCity = document.FORM1.ukArrvCity.value.toUpperCase();
			deptDate = document.FORM1.ukDeptDate.value;
			retnDate = document.FORM1.ukRetnDate.value;
			
			try
			{
				deptTime = document.FORM1.ukDeptTime.options[document.FORM1.ukDeptTime.selectedIndex].value;
			}
			catch(theException)
			{
				deptTime = document.FORM1.ukDeptTime.value;
			}
			//roundTrip = getRadioValue(document.FORM1.ukRoundTrip);
			//if (roundTrip == null) roundTrip = 1;
			passNum = document.FORM1.ukPassNum.value;
			chdPassNum = document.FORM1.ukChdPassNum.value;
			senPassNum = document.FORM1.ukSenPassNum.value;
			infantPassNum = document.FORM1.ukInfantPassNum.value;
			infantSeat = document.FORM1.ukInfantSeat.value;
			flightClass = document.FORM1.ukFlightClass.options[document.FORM1.ukFlightClass.selectedIndex].value;
			try
			{
				flightStops = document.FORM1.ukFlightStop.option[document.FORM1.ukFlightStop.selectedIndex].value;
			}
			catch(theException)
			{
				flightStops = document.FORM1.ukFlightStop.value;
			}
			VID = document.FORM1.VID.value;
//			if (document.FORM1.VID.value.indexOf('OT') == -1 && document.FORM1.VID.value != "OTFLKS" && document.FORM1.VID.value.indexOf("ADTK") == -1 && document.FORM1.VID.value != "OTBB" && document.FORM1.VID.value != "APW")
//				tripSearch = getRadioValue(document.FORM1.ukTripSearch);
//			else
				tripSearch = document.FORM1.ukTripSearch.value;
			if (tripSearch.indexOf("air") != -1)
				setCurrentResultState("air", VID);
			else if (tripSearch.indexOf("hotel") != -1)
				setCurrentResultState("hotel", VID);
			hotelRoom = document.FORM1.ukHotelRoom.value;
			lastTripType = document.FORM1.lastTripType.value;
			try
			{
				retnTime = document.FORM1.ukRetnTime.options[document.FORM1.ukRetnTime.selectedIndex].value;
			}
			catch(theException)
			{
				retnTime = document.FORM1.ukRetnTime.value;
			}
			
			searched = 1;
		}
/*		else if(document.FORM1.TripType.value == "Multicity")
		{
			lastTripType = "Multicity";
			deptCity1 = document.FORM1.ukDeptCity1.value.toUpperCase();
			arrvCity1 = document.FORM1.ukArrvCity1.value.toUpperCase();
			deptDate1 = document.FORM1.ukDeptDate1.value;
			deptTime1 = document.FORM1.ukDeptTime1.options[document.FORM1.ukDeptTime1.selectedIndex].value;
			VID = document.FORM1.VID.value;
	
			if(document.FORM1.ukDeptCity2.value!="")
			{
				deptCity2 = document.FORM1.ukDeptCity2.value.toUpperCase();
				arrvCity2 = document.FORM1.ukArrvCity2.value.toUpperCase();
				deptDate2 = document.FORM1.ukDeptDate2.value;
				deptTime2 = document.FORM1.ukDeptTime2.options[document.FORM1.ukDeptTime2.selectedIndex].value;
			}
			else
			{
				deptCity2 = "";
				arrvCity2 = "";
				deptDate2 = "";
				deptTime2 = "";
			}

			if(document.FORM1.ukDeptCity3.value!="")
			{
				deptCity3 = document.FORM1.ukDeptCity3.value.toUpperCase();
				arrvCity3 = document.FORM1.ukArrvCity3.value.toUpperCase();
				deptDate3 = document.FORM1.ukDeptDate3.value;
				deptTime3 = document.FORM1.ukDeptTime3.options[document.FORM1.ukDeptTime3.selectedIndex].value;
			}
			else
			{
				deptCity3 = "";
				arrvCity3 = "";
				deptDate3 = "";
				deptTime3 = "";
			}
			if(document.FORM1.ukDeptCity4.value!="")
			{
				deptCity4 = document.FORM1.ukDeptCity4.value.toUpperCase();
				arrvCity4 = document.FORM1.ukArrvCity4.value.toUpperCase();
				deptDate4 = document.FORM1.ukDeptDate4.value;
				deptTime4 = document.FORM1.ukDeptTime4.options[document.FORM1.ukDeptTime4.selectedIndex].value;
			}
			else
			{
				deptCity4 = "";
				arrvCity4 = "";
				deptDate4 = "";
				deptTime4 = "";
			}
			passNum1 = document.FORM1.ukPassNum.value;
			senPassNum1 = document.FORM1.ukSenPassNum.value;
			chdPassNum1 = document.FORM1.ukChdPassNum.value;
			infantPassNum1 = document.FORM1.ukInfantPassNum.value;
			infantSeat1 = document.FORM1.ukInfantSeat.value;
			flightClass1 = document.FORM1.ukFlightClass.options[document.FORM1.ukFlightClass.selectedIndex].value;
			try
			{
				flightStops1 = document.FORM1.ukFlightStop.options[document.FORM1.ukFlightStop.selectedIndex].value;
			}
			catch(theException)
			{
				flightStops1 = document.FORM1.ukFlightStop.value;
			}
//			lastTripType = document.FORM1.TripType.value;
			document.FORM1.lastTripType.value = "Multicity";
			document.FORM1.ukDeptCity.value = deptCity1+";"+deptCity2+";"+deptCity3+";"+deptCity4;
			document.FORM1.ukArrvCity.value = arrvCity1+";"+arrvCity2+";"+arrvCity3+";"+arrvCity4;
			if (deptCity1 == null || deptCity1 == "")
			{
				document.FORM1.ukDeptDate.value = ",,,";
				document.FORM1.ukDeptTime.value = ",,,";
			}
			else if (deptCity2 == null || deptCity2 == "")
			{
				document.FORM1.ukDeptDate.value = deptDate1+",,,";
				document.FORM1.ukDeptTime.value = deptTime1+",,,";
			}
			else if (deptCity3 == null || deptCity3 == "")
			{
				document.FORM1.ukDeptDate.value = deptDate1+","+deptDate2+",,";
				document.FORM1.ukDeptTime.value = deptTime1+","+deptTime2+",,";
			}
			else if (deptCity4 == null || deptCity4 == "")
			{
				document.FORM1.ukDeptDate.value = deptDate1+","+deptDate2+","+deptDate3+",";
				document.FORM1.ukDeptTime.value = deptTime1+","+deptTime2+","+deptTime3+",";
			}
			else
			{
				document.FORM1.ukDeptDate.value = deptDate1+","+deptDate2+","+deptDate3+","+deptDate4;
				document.FORM1.ukDeptTime.value = deptTime1+","+deptTime2+","+deptTime3+","+deptTime4;
			}
			document.FORM1.ukRoundTrip.value = "2";
			roundTrip = "2";
			searched = 1;
			setCurrentResultState("air", VID);
		}
*/		
		document.FORM1.ukAirline.value = opselect1;
		document.FORM1.op.value = "wfs";
//		document.FORM1.sID.value = sID;
//		document.FORM1.sDate.value = sDate;
//		document.FORM1.lDate.value = lDate;
		document.FORM1.action = servletsite;
		document.FORM1.method = "post";
		document.FORM1.defaultsite.value = defaultsite;
		document.FORM1.serversite.value = servletsite;
		document.FORM1.hostsite.value = hostsite;
		stopped = false;
		resetresult();
		window.status = "Searching... Please wait.";
			var mess = "airsel="+getselection()+"{}"+
				"dc1=" + document.FORM1.ukDeptCity.value.toUpperCase()+"{}"+
				"da1=" + document.FORM1.ukArrvCity.value.toUpperCase()+"{}"+
				"dd1=" + document.FORM1.ukDeptDate.value+"{}";
				"ad1=" + document.FORM1.ukRetnDate.value+"{}";
			try
			{
				mess += ((document.FORM1.TripType.value == "Multicity")?document.FORM1.ukDeptTime.value+"{}":"dt1=" + document.FORM1.ukDeptTime.options[document.FORM1.ukDeptTime.selectedIndex].value+"{}");
			}
			catch(theException)
			{
				mess += ((document.FORM1.TripType.value == "Multicity")?document.FORM1.ukDeptTime.value+"{}":"dt1=" + document.FORM1.ukDeptTime.value+"{}");
			}
			mess +=	((document.FORM1.TripType.value == "Multicity")?"":"ad1="+ document.FORM1.ukRetnDate.value+"{}");
			try
			{
				((document.FORM1.TripType.value == "Multicity")?"":((lastTripType == "Oneway")?"":"at1="+ document.FORM1.ukRetnTime.options[document.FORM1.ukRetnTime.selectedIndex].value+"{}"));
			}
			catch(theException)
			{
				((document.FORM1.TripType.value == "Multicity")?"":((lastTripType == "Oneway")?"":"at1="+ document.FORM1.ukRetnTime.value+"{}"));
			}
			mess +=
//				"rt=" + getRadioValue(document.FORM1.ukRoundTrip)+"{}"+
				"rt=" + roundTrip+"{}"+
				"sp=" + document.FORM1.ukSenPassNum.value+"{}";
			try
			{
				mess += "fs=" + document.FORM1.ukFlightStop.options[document.FORM1.ukFlightStop.selectedIndex].value+"{}";
			}
			catch(theException)
			{
				mess += "fs="+document.FORM1.ukFlightStop.value+"{}";
			}
			mess +=	"fc=" + document.FORM1.ukFlightClass.options[document.FORM1.ukFlightClass.selectedIndex].value+"{}"+
				"pn=" + document.FORM1.ukPassNum.value+"{}"+
				"cp=" + document.FORM1.ukChdPassNum.value+"{}"+
				"ifl=" + document.FORM1.ukInfantPassNum.value+"{}"+
				"ifs=" + document.FORM1.ukInfantSeat.value+"{}";
			setck(lastTripType, mess, true);
//		document.FORM1.submitButton.disabled = false;
		xml = document.FORM1.xml.value;
		if (xml.indexOf("<BACKGROUND>") == -1)
			xml += "<BACKGROUND>Y</BACKGROUND>";
		if (xml.indexOf("<ADTKLODGING>") == -1)
			xml += "<ADTKLODGING>removecomparearea</ADTKLODGING>";
		if (xml.indexOf("<BROWSER>") == -1)
			xml += "<BROWSER>"+browsertype+"</BROWSER>";
		if (xml.indexOf("<FLIGHTSCHEDULE>") == -1)
			xml += "<FLIGHTSCHEDULE>yes</FLIGHTSCHEDULE>";
		document.FORM1.xml.value = xml;
		document.FORM1.submit();
		return false;
	}
	else
	{
		//alert('else');
		document.FORM1.submitButton.disabled = false;
		return false;
	}
}
function getselection()
{
}
function resetresult()
{
	resultindex = 0;
	resultair = "";
	resulthotel = "";
	resultstatus = true;
}

function setCurrentResultState(type)
{
	currentResultState = type;
	hotelcounter = 0;
}
function getCurrentResultState()
{
	return currentResultState;
}
function setsearchType(searchtype)
{
	lastTripType = searchtype;
}

// This function will trim leading and/or trailing spaces from a string
// arg = the value you wish to have trimmed..
// func = "left" for Ltrim(), "right" for RTrim() or "both" for Trim()

//===================================
function trim(arg,func) {
//===================================

	var trimvalue = "";
	var lastpos = 0, i =0, pos = 0;
	var arglen = arg.length;
	if (arg == null || arglen < 1) return trimvalue;

	if (func == "left" || func== "both") {
		i = 0;
		pos = -1;
		while (i < arglen) {
			if (arg.charCodeAt(i) != 32 &&
!isNaN(arg.charCodeAt(i))) {
				pos = i;
				break;
			}
			i++;
		}
	}

	if (func == "right" || func== "both") {
		lastpos = -1;
		i = arglen;
		while (i >= 0) {
			if (arg.charCodeAt(i) != 32 &&
!isNaN(arg.charCodeAt(i))) {
				lastpos = i;
				break;
			}
			i--;
		}
	}
	if (pos < 0) pos = 0;
	if (lastpos < 0 || lastpos < pos)
		lastpos = pos;
	if (func == "left")
	 {
		//trimvalue = arg.substring(pos,arglen-1);
		trimvalue = arg.substring(pos,arglen);
	}

	if (func == "right") {
		trimvalue = arg.substring(0,lastpos+1);
	}

	if (func == "both") {
		trimvalue = arg.substring(pos,lastpos + 1);
	}
	return trimvalue;
}

function setStringLength(str, len)
{
	var pos = 0;
	var data = "";
	try
	{
		while (pos < str.length)
		{
			if (str.length > (pos+len))
			{
				if (str.charAt(pos+len-1) == ' ' || str.charAt(pos+len) == ' ')
					data += str.substring(pos, pos+len)+"<br>";
				else
					data += str.substring(pos, pos+len)+"-<br>";
			}
			else
				data += str.substring(pos);
			pos += len;
		}
		return data;
	}
	catch(theException)
	{
	}
	return str;
}
function settrip(type)
{
	setck("trippage", type, false);
//	if (hostsite.length == 0)
	{
		if (document.FORM0.hostsite != null && document.FORM0.hostsite.value.length > 0)
			hostsite = document.FORM0.hostsite.value;
	}
//	if (hostsite != null && hostsite.length > 0 && (hostsite.indexOf("myt.fsldev.com") != -1 || hostsite.indexOf("mytravelrebates.com") != -1))
//	{
		if (type == "Roundtrip")
			window.location = hostsite;
		else if (type == "Oneway")
			window.location = hostsite;
		else if (type == "Multicity")
			window.location = hostsite;
		else if (type == "hotel")
			window.location = hostsite;
/*	}
	else
	{
		if (type == "Roundtrip")
			window.location =hostsite+"rt.html";
		else if (type == "Oneway")
			window.location = hostsite+"ow.html";
		else if (type == "Multicity")
			window.location = hostsite+"mc.html";
		else if (type == "hotel")
			window.location = hostsite+"index1.html";
	}
*/
}

function gettrip1()
{
	var state = getck("trippage");
	if (state == null || state == "" || state != 'hotel')
		state = "hotel";
	setck("trippage", state, false);
	return state;
}
function gettrip(type)
{
	var state = getck("trippage");
	if (type == 'Roundtrip')
	{
		if (state == null  || state == '' || state != 'Roundtrip')
		{
			state = 'Roundtrip';
			setck("trippage", state, false);
		}
	}
	else if (type == 'Multicity')
	{
		if (state == null || state == '' || state != 'Multicityc')
		{
			state = 'Multicity'; //'Multicityc';
			setck("trippage", state, false);
		}
	}
	else if (type == 'Oneway')
	{
		if (state == null || state == '' || state != 'Oneway')
		{
			state = 'Oneway';
			setck("trippage", state, false);
		}
	}
	else if (type == 'hotel')
	{
		if (state == null || state == '' || state != 'hotel')
		{
			state = 'hotel';
			setck("trippage", state, false);
		}
	}
	return state;
}
function checkNum(value,selectNum){	
		var a = rmleading0(value);
		var b = a;
		if (b != value || b == -1)
		{
			if (selectNum == 1){
				document.FORM1.ukPassNum.focus();
				document.FORM1.ukPassNum.select();
				}
			if (selectNum == 2){
				document.FORM1.ukSenPassNum.focus();
				document.FORM1.ukSenPassNum.select();
				}
			if (selectNum == 3){
				document.FORM1.ukChdPassNum.focus();
				document.FORM1.ukChdPassNum.select();
				}
			if (selectNum == 4){
				document.FORM1.ukInfantPassNum.focus();
				document.FORM1.ukInfantPassNum.select();
				}
			if (selectNum == 5){
				document.FORM1.ukInfantSeat.focus();
				document.FORM1.ukInfantSeat.select();
				}
  			errorMessage(value + " is not a number");
  			return false;
		}
		return true;
}
function calopened()
{
//	document.getElementById('idclass').style.visibility= 'hidden';
}
function calclosed()
{
//	document.getElementById('idclass').style.visibility= 'visible';
}
function setfooter()
{
 setContent('footer', getfooter());
}
function setinit()
{
		try
		{
  		document.FORM1.ukDeptDate.value = parent.ukDeptDate;
  		document.FORM1.ukRetnDate.value = parent.ukRetnDate;
  		document.FORM1.ukDeptCity.value = parent.ukDeptCity;
  		document.FORM1.ukArrvCity.value = parent.ukArrvCity;
  		document.FORM1.xml.value = parent.XML;
  		document.FORM1.session.value = parent.Session;
  		document.FORM1.VID.value = parent.VID;
  		document.FORM1.defaultsite.value = parent.defaultsite;
  		document.FORM1.hostsite.value = parent.hostsite;
  		document.FORM1.serversite.value = parent.serversite;
  		document.FORM1.ukAirline.value = parent.ukAirline;
  		document.FORM1.ukPassNum.value = parent.ukPassNum;
  		document.FORM1.ukFlightStop.value = parent.ukFlightStop;
  		document.FORM1.ukHotelRoom.value = parent.ukHotelRoom;
  		document.FORM1.ukSenPassNum.value = parent.ukSenPassNum; 
  		document.FORM1.ukChdPassNum.value = parent.ukChdPassNum; 
  		document.FORM1.ukTripSearch.value = parent.tripSearch;
  		document.FORM1.lastTripType.value = parent.lastTripType;
  		document.FORM1.ukRoundTrip.value = parent.ukRoundTrip;
			document.FORM1.ukDeptTime.value = parent.ukDeptTime;
			document.FORM1.ukRetnTime.value = parent.ukRetnTime;
			document.FORM1.TripType.value = parent.lastTripType;
			document.FORM1.ukFlightClass.value = parent.ukFlightClass;
			document.FORM1.ukInfantSeat.value = parent.ukInfantSeat;
			document.FORM1.ukInfantPassNum.value = parent.ukInfantPassNum;
		}
		catch(theException)
		{}
}

function sendToTopframeHOTEL()
{
//alert('in topframe2');
	var st = 0, st2 = 0;
	ukCity = "";
	ukCityAbr = "";
	ukCities = "";
	ukCityCount = 0;
	ct = "", mess="", xml="";
//alert('2');
//	document.FORM2.submitButton.disabled = true;
	var regExpr = /[!\"?$?\^\&\*\(\)\+\-\=\`\?\?\{\}\:\;\'\@\#\~\|\\\<\>\,\.\?\/\[\]]/g
	//alert(document.FORM2.ukArrvCity.value);
	  if (document.FORM2.ukArrvCity.value == "")
	  {
		   errorMessage("Please select a city");
//		document.FORM2.submitButton.disabled = false;
		  return false;
	  }
		else if (!checkDateError())
		{
		//alert('in checkdateerror');
			return false;
		}
    else if(checkFormErrorHOTEL())
    {
//    	document.FORM2.ukArrvCity.value = ukCityAbr;
  		arrvCity = document.FORM2.ukArrvCity.value.toUpperCase();
  		if ((st = arrvCity.indexOf(",,")) != -1)
  			arrvCity = arrvCity.substring(0, st+1)+arrvCity.substring(st+2);
  		st = 0;
  		deptDate = document.FORM2.ukDeptDate.value;
  		retnDate = document.FORM2.ukRetnDate.value;
  		passNum = document.FORM2.ukPassNum.value;
  		VID = document.FORM2.VID.value;
//		setCurrentResultState("hotel");
//		try
			{
//			hotelRoom = document.FORM2.ukHotelRoom.options[document.FORM2.ukHotelRoom.selectedIndex].value;
			}
//		catch(theException)
  		{
  			hotelRoom = document.FORM2.ukHotelRoom.value;
  		}
  		htlName = document.FORM2.ukHotelName.value;
  		try
  		{
  			htlRate = document.FORM2.ukHtlRating.options[document.FORM2.ukHtlRating.selectedIndex].value;
  		}
  		catch(theException)
  		{
  			htlRate = document.FORM2.ukHtlRating.value;
  		}
  		lastTripType = "Roundtrip";
  		searched = 1;
  		document.FORM2.ukAirline.value = opselect2;
  		document.FORM2.op.value = "wfsh";
  		document.FORM2.action = servletsite2;
  		document.FORM2.method = "post";
  		document.FORM2.defaultsite.value = defaultsite2;
  		document.FORM2.serversite.value = servletsite2;
  		document.FORM2.hostsite.value = hostsite2;
 		
  		stopped = false;
//		resetresult();
  		window.status = "Searching... Please wait.";
  		mess = "da1=" + arrvCity+"{}"+
//			"da0=" + ukCityAbr+"{}"+
			"dd1=" + document.FORM2.ukDeptDate.value+"{}"+
			"ad1="+ document.FORM2.ukRetnDate.value+"{}"+
//			"dd1m="+ document.FORM2.arvmon.value+"{}"+
//			"dd1d="+ document.FORM2.arvday.value+"{}"+
//			"dd1y="+ toYear+"{}"+
//			"ad1m="+document.FORM2.dptmon.value+"{}"+
//			"ad1d="+document.FORM2.dptday.value+"{}"+
//			"ad1y="+toYear+"{}"+
				"";
  		try
  		{
  			mess += "hrm="+ document.FORM2.ukHotelRoom.options[document.FORM2.ukHotelRoom.selectedIndex].value;
  		}
  		catch(theException)
  		{
  			mess += "hrm="+ document.FORM2.ukHotelRoom.value+"{}";
  		}
  		mess += "hlnm="+ document.FORM2.ukHotelName.value+"{}"+
  			"hlrt="+ htlRate+"{}"+
  			"pn=" + document.FORM2.ukPassNum.value+"{}";
  		setck("hotel", mess, true);
  		xml = document.FORM2.xml.value;
  		if (xml.indexOf("<BACKGROUND>") == -1)
  			xml += "<BACKGROUND>Y</BACKGROUND>";
  		if (xml.indexOf("<ADTKLODGING>") == -1)
  			xml += "<ADTKLODGING>removecomparearea</ADTKLODGING>";
  		if ((st = xml.indexOf("<BROWSER>")) != -1  && (st2 = xml.indexOf("</BROWSER>", st+9)) != -1)
  			xml = xml.substring(0, st+9)+browsertype+xml.substring(st2);
  		else
  			xml += "<BROWSER>"+browsertype+"</BROWSER>";
  		if ((st = xml.indexOf("<UKARRVCITY>")) != -1 && (st2 = xml.indexOf("</UKARRVCITY>", st+12)) != -1)
  			xml = xml.substring(0, st+12)+ukCityAbr+xml.substring(st2);
  		else
  			xml += "<UKARRVCITY>"+ukCityAbr+"</UKARRVCITY>";
  		document.FORM2.xml.value = xml;
  		document.FORM2.submit();
  		return false;
    }
    else
    {
	//	 document.FORM2.submitButton.disabled = false;
		 return false;
    }
}
function checkFormErrorHOTEL(n)
{
	var dval = 0, dva2=0, value1=0, value6=0;
	var arrstatus = 0;
	closePopup();
	var regExpr = /[!\"?$?\^\&\*\(\)\+\-\=\`\?\?\{\}\:\;\'\@\#\~\|\\\<\>\,\.\?\/\[\]]/g
	//check city
//	document.FORM2.submitButton.disabled = true;
	if (document.FORM2.ukArrvCity.value == "")
	{
//		document.FORM2.submitButton.disabled = false;
		errorMessage("Enter a destination");
		return false;
	}
	
	//Get rid of all punctuation and wierd stuff and replace with comas
	document.FORM2.ukArrvCity.value = document.FORM2.ukArrvCity.value.replace(regExpr, ",");
	document.FORM2.ukArrvCity.value = document.FORM2.ukArrvCity.value.toUpperCase();
	// check arrival or return city
	// no restriction on arrival city
	if (!checkCity(document.FORM2.ukArrvCity))
	{
		if (ukCityCount == 0)
		{
			errorMessage("Check destination");
			document.FORM2.ukArrvCity.focus();
//			document.FORM2.ukArrvCity.select();
		}
		return false;
	}
	// check for date
		if (!checkDateError())
		{
			return false;
		}
/*	dval = checkDate(document.FORM2.ukDeptDate.value);
	if (dval == 0)
	{
		window.alert("Departure date error");
		document.FORM2.am.focus();//ukDeptDate.focus();
		return false;
	}
	dva2 = checkDate(document.FORM2.ukRetnDate.value);
	if (dva2 == 0)
	{
		window.alert("Return date error");
		document.FORM2.dm.focus();//ukRetnDate.focus();
		return false;
	}
	dval= checkinvaliddate(document.FORM2.ukDeptDate.value ,document.FORM2.ukRetnDate.value);
	if (dval == 0)
	{
		window.alert("Departure date can not be later than Return date");
		document.FORM2.am.focus();//ukDeptDate.focus();
		return false;
	}
*/
/*
	value1 = rmleading0(document.FORM2.ukPassNum.value);
	if (value1 < 1 || value1 > 4)
	{
		alert("Guest # is 1 - 4");
		document.FORM2.ukPassNum.focus();
		document.FORM2.ukPassNum.select();
		return false;
	}
*/
/*
//	try
	{
//		value6 = rmleading0(document.FORM2.ukHotelRoom.options[document.FORM2.ukHotelRoom.selectedIndex].value);
	}
//	catch(theException)
	{
		value6 = rmleading0(document.FORM2.ukHotelRoom.value);
	}
	if (value6 < 1 || value6 > 1)
	{
		alert("Room # can only be 1");
		document.FORM2.ukHotelRoom.focus();
//		try
		{
//			document.FORM2.ukHotelRoom.select();
		}
//		catch(theException)
		{
		}
		return false;
	}
*/	
	return true;
}


function validateFormCAR()
{
	var toDay = new Date();
	var toMonth = toDay.getMonth();
	var toYear = toDay.getFullYear();
	var inY, outY;
	var startDate;
	var endDate;
	var dateDiff;
	var diff2;
//	var regExpr = /[ !\"?$?\^\&\*\(\)\+\-\=\`\?\?\{\}\:\;\'\@\#\~\|\\\<\>\,\.\?\/\[\]]/g
	var regExpr = /[!\"?$?\^\&\*\(\)\+\-\=\`\?\?\{\}\:\;\'\@\#\~\|\\\<\>\,\.\?\/\[\]]/g
	//check city
//	document.FORM4.submitButton.disabled = true;
try
{
 		changedate(document.FORM4.ukDeptDate, 'pickup');
		changedate(document.FORM4.ukRetnDate, 'dropoff');
		document.FORM4.ukArrvCity.value = document.FORM4.txtPickupCity.value;
	if (document.FORM4.ukArrvCity.value == "")
	{
//		document.FORM1.submitButton.disabled = false;
		errorMessage("Please enter a destination");
		return false;
	}
	//Get rid of all punctuation and wierd stuff and replace with comas
	document.FORM4.ukArrvCity.value = document.FORM4.ukArrvCity.value.replace(regExpr, ",");
	
	return checkDateErrorCAR();
	//alert('hello2');
		if (!sendToTopframeCAR())
		{
//			document.FORM1.submitButton.disabled = false;
			return false;
		}

/*	
	var datetemp = new Date(new Date(date.getMonth())+"/"+new Date(date.getDate())+"/"+new Date(date.getFullYear()));
	startDate = new Date(document.FORM4.ukDeptDate.value);
	endDate = new Date(document.FORM4.ukRetnDate.value);
	dateDiff = endDate - startDate;
	diff2 = endDate - datetemp;
	
	if ((dateDiff/86400000) > 30)
	{
//		document.FORM1.submitButton.disabled = false;
		alert("We cannot book for more than 30 nights. Please select different dates.");
		return false;
	}
	else if ((diff2/86400000) > 331)
	{
//		document.FORM1.submitButton.disabled = false;
		alert("We cannot book for more than 11 months. Please select different dates.");
		return false;
	}
	else if ((dateDiff/86400000) < 1)
	{
//		document.FORM1.submitButton.disabled = false;
		alert("The check out date must be later than check in date.");
		return false;
	}
	else if (((startDate-datetemp)/86400000) < 1)
	{
//		document.FORM1.submitButton.disabled = false;
		alert("The check in date can not be earlier than today.");
		return false;
	}
	else
	{
		if (!sendToTopframeCAR())
		{
//			document.FORM1.submitButton.disabled = false;
			return false;
		}
	}
*/
	
}
catch(theException)
{
//alert("validateform error");	
}	
	return true;
}

function sendToTopframeCAR()
{
//alert('In here');
	var st = 0, st2 = 0;
	ukCity = "";
	ukCityAbr = "";
	ukCities = "";
	ukCityCount = 0;
	ct = "", mess="", xml="";
try
{	
//	document.FORM4.submitButton.disabled = true;
		var regExpr = /[!\"?$?\^\&\*\(\)\+\-\=\`\?\?\{\}\:\;\'\@\#\~\|\\\<\>\,\.\?\/\[\]]/g
//    try
    {
     		changedate(document.FORM4.ukDeptDate, 'pickup');
    		changedate(document.FORM4.ukRetnDate, 'dropoff');
    		document.FORM4.ukArrvCity.value = document.FORM4.txtPickupCity.value;
    	if (document.FORM4.ukArrvCity.value == "")
    	{
    //		document.FORM4.submitButton.disabled = false;
    		errorMessage("Enter pick up airport code");
    		return false;
    	}
    	//Get rid of all punctuation and wierd stuff and replace with comas
    	document.FORM4.ukArrvCity.value = document.FORM4.ukArrvCity.value.replace(regExpr, ",");
    	if (!checkDateError())
				 return false;
    }
//    catch(theException)
    {
    //alert("validateform error");	
    }	
    if(checkFormErrorCAR())
    {
  		arrvCity = document.FORM4.ukArrvCity.value.toUpperCase();
  		if ((st = arrvCity.indexOf(",,")) != -1)
  			arrvCity = arrvCity.substring(0, st+1)+arrvCity.substring(st+2);
  		st = 0;
  		deptDate = document.FORM4.ukDeptDate.value;
  		retnDate = document.FORM4.ukRetnDate.value;
  		VID = document.FORM4.VID.value;
  		lastTripType = "Roundtrip";
  		searched = 1;
  		document.FORM4.ukCars.value = opselect3;
  		document.FORM4.op.value = "wfsc";
  		document.FORM4.action = servletsite3;
  		document.FORM4.method = "post";
  		stopped = false;
  		window.status = "Searching... Please wait.";
  		mess = "da1=" + arrvCity+"{}"+
  			"da0=" + ukCityAbr+"{}"+
  			"dd1=" + document.FORM4.ukDeptDate.value+"{}"+
  			"ad1="+ document.FORM4.ukRetnDate.value+"{}"+
  				"";
  		setck("car", mess, true);
  		xml = document.FORM4.xml.value;
  		if (xml.indexOf("<BACKGROUND>") == -1)
  			xml += "<BACKGROUND>Y</BACKGROUND>";
  		if (xml.indexOf("<ADTKLODGING>") == -1)
  			xml += "<ADTKLODGING>removecomparearea</ADTKLODGING>";
  		if ((st = xml.indexOf("<BROWSER>")) != -1  && (st2 = xml.indexOf("</BROWSER>", st+9)) != -1)
  			xml = xml.substring(0, st+9)+browsertype+xml.substring(st2);
  		else
  			xml += "<BROWSER>"+browsertype+"</BROWSER>";
  		if ((st = xml.indexOf("<UKARRVCITY>")) != -1 && (st2 = xml.indexOf("</UKARRVCITY>", st+12)) != -1)
  			xml = xml.substring(0, st+12)+ukCityAbr+xml.substring(st2);
  		else
  			xml += "<UKARRVCITY>"+ukCityAbr+"</UKARRVCITY>";
  		document.FORM4.defaultsite.value = defaultsite3;
  		document.FORM4.serversite.value = servletsite3;
  		document.FORM4.hostsite.value = hostsite3;
  		document.FORM4.xml.value = xml;
  		document.FORM4.submit();
  		return false;
    }
    else
    {
//  		document.FORM4.submitButton.disabled = false;
  		return false;
    }
}
catch(theException)
{
}
}
function checkFormErrorCAR(n)
{
	var dval = 0, dva2=0, value1=0, value6=0;
	var arrstatus = 0;
	closePopup();
	document.FORM4.ukArrvCity.value = document.FORM4.ukArrvCity.value.toUpperCase();
	// check arrival or return city
	// no restriction on arrival city
	if (!checkCity(document.FORM4.ukArrvCity))
	{
		if (ukCityCount == 0)
		{
			errorMessage("Error in city name/airport code\n 3 Digital Airport Code or \n 'City,State/Country' ");
			document.FORM4.ukArrvCity.focus();
//			document.FORM4.ukArrvCity.select();
		}
		return false;
	}
	// check for date
	return true;
}
