//Global paths for all applications
//Jan 12 06 
var host			= window.location.host;
var secHost			= window.location.host;
var secProtocol		= 'http://';
var protocol		= 'http://';
var siteName		= 'iTravelMexico';
var websiteCMSurl	= '/Main/' ;
var hotelsURL		= '/Hotels/' ;
var packageUrl		= '/Main/';
var flightHotelURL	= '/AirPlusHotel/' ;
var banManProServer	= 'ads.itravel2000.com';


//----------------------------------------------

function NavigateToEastWest(formName, pageAnchor, parameters)
{
	NavigateTo(formName + (isWestGateway(commonForm.tm_gateway.value) ? "West.aspx" : "East.aspx"), 
		pageAnchor, parameters);
}

//-------------------------------------------------------------------------------------------
//NavigateTo		: Submits current form and sents the navicagion to other form
//	formName		: pass the formName (not the full ASPX or HTML , just identifier).
//	pageAnchor		: pass anchor name if you have specific anchor on the page to naviage to
//	parameters		: pass all parameters pass the redirected form.
//-------------------------------------------------------------------------------------------
function NavigateTo(formName, pageAnchor, parameters)
{
	document.commonForm.target = "" ;
	var actionForm ='' ;
	switch(formName)
	{
		case "PasswordRetrieveSuccess":
			actionForm = protocol + host + websiteCMSurl + "PasswordRetrieve-success.aspx";
			break;
		case "ForgotPassword":
			actionForm = protocol + host + websiteCMSurl + "PasswordRetrieve.aspx";
			break;
		case "SignupToWinResort":
		case "signUpToWinResort":
			actionForm = protocol + host + websiteCMSurl + "signUpToWinResort.aspx";
			break;
		case "CustomerTestimonials":
			actionForm = protocol + host + websiteCMSurl + "CustomerTestimonials.aspx";
			break;
		case "OurCompany":
			actionForm = protocol + host + websiteCMSurl + "OurCompany.aspx";
			break;
		case "OurAgents":
			actionForm = protocol + host + websiteCMSurl + "OurAgents.aspx";
			break;
		case "GetAwayForLess":
			actionForm = protocol + host + websiteCMSurl + "GetAwayForLess.aspx";
			break;
		case "OurPartners":
			actionForm = protocol + host + websiteCMSurl + "OurPartners.aspx";
			break;
		case "NiagaraFalls":
			actionForm = protocol + host + websiteCMSurl + "Niagara.aspx";
			break;
		case "CustomerSurveySuccess":
			actionForm = protocol + host + websiteCMSurl + "CustomerSurveyConfirmation.aspx";
			break;
		case "CustomerSurvey":
			actionForm = protocol + host + websiteCMSurl + "CustomerSurvey.aspx";
			break;
		case "CustomerServiceEmailSuccess":
			actionForm = protocol + host + websiteCMSurl + "CustomerServiceEmail-success.aspx";
			break;
		case "CustomerServiceEmail":
			actionForm = protocol + host + websiteCMSurl + "CustomerServiceEmail.aspx";
			break;
		case "CustomerServiceFAQ":
			actionForm = protocol + host + websiteCMSurl + "FAQ.aspx";
			break;
		case "Cruises":
			//window.location.href = "http://www.galileocruiseplus.com/cruises/cruises.jsp?cobrand=33911";
			actionForm = protocol + host + websiteCMSurl + "Cruises.aspx";
			break;
		case "CarsRail":
			actionForm = protocol + host + websiteCMSurl + "Cars.aspx";
			break;
		case "Packages":
			actionForm = protocol + host + websiteCMSurl + "Packages.aspx";
			break;
				case "fh_ConfirmReserve":
			actionForm = secProtocol + secHost + flightHotelURL + "ConfirmReserve.aspx";
			break;
		case "fh_Summary":
			actionForm = secProtocol + secHost + flightHotelURL + "Summary.aspx";
			break;
		case "fh_PaymentDetail":
			actionForm = secProtocol + secHost + flightHotelURL + "PaymentDetail.aspx";
			break;
		case "fh_HotelDetail":
			actionForm = protocol + secHost + flightHotelURL + "HotelDetail.aspx";
			break;
		case "fh_Review":
			actionForm = protocol + secHost + flightHotelURL + "ReviewPackage.aspx";
			break;
		case "fh_ReviewSummary":
			actionForm = secProtocol + secHost + flightHotelURL + "ReviewSummary.aspx";
			break;
		case "fh_ListProducts":
			actionForm = protocol + secHost + flightHotelURL + "ListProducts.aspx";
			break;
		case "fh_ChangeFlight":
			actionForm = protocol + secHost + flightHotelURL + "ChangeFlight.aspx";
			break;
		case "fh_PassengerInfo":
			actionForm = secProtocol + secHost + flightHotelURL + "PassengerDetail.aspx";
			break;
		case "fh_SearchResults":
		case "FlightHotelResult":
			actionForm = protocol + secHost + flightHotelURL + "SearchResults.aspx";
			break;
		case "fh_InsuranceInfo":
			actionForm = protocol + secHost + flightHotelURL + "InsuranceInfo.aspx";
			break;
		case "fh_AdultAges":
			actionForm = protocol + secHost + flightHotelURL + "AdultAges.aspx";
			break;
		case "fh_FlightRules":
			actionForm = protocol + secHost + flightHotelURL + "FlightRules.aspx";
			document.commonForm.target = "_new" ;
			break;
		case "fh_SearchResults":
		case "FlightHotelResult":
			actionForm = protocol + secHost + flightHotelURL + "SearchResults.aspx";
			break;
		case "Tools":
		case "ToolsFeatures":
			actionForm = protocol + host + websiteCMSurl + "ToolsFeatures.aspx" ;
			break;
		case "UsefulLinks":
			actionForm = protocol + host + websiteCMSurl + "UsefulLinks.aspx" ;
			break;
		case "CurrencyConverter":
			actionForm = protocol + host + websiteCMSurl + "CurrencyConverter.aspx" ;
			break;
		case "CurrencyConverterResult":
			actionForm = protocol + host + websiteCMSurl + "CurrencyConverterResult.aspx" ;
			break;
		case "SiteMap":
			actionForm = protocol + host + websiteCMSurl + "SiteMap.aspx" ;
			break;
		case "SignupToWin":
			actionForm = protocol + host + websiteCMSurl + "SignupToWin.aspx" ;
			break;
		case "SignIn":
			actionForm = protocol + host + websiteCMSurl + "AccountSignIn.aspx" ;
			break;
		case "SignOut":
			if(confirm("Are you sure you want to Sign-out from itravel2000 website?"))
			{
				actionForm = protocol + host + websiteCMSurl + "AccountSignIn.aspx" ;
				parameters ="sign-out=1" ;
			}
			else
			{
				return;
			}
			break;
		case "AccountEdit":
			actionForm = protocol + host + websiteCMSurl + "AccountEdit.aspx" ;
			break;
		case "AccountShow":
			actionForm = protocol + host + websiteCMSurl + "AccountShow.aspx" ;
			break;
		case "RegisterNow":
		case "SignUp":
			actionForm = protocol + host + websiteCMSurl + "AccountSignUp.aspx" ;
			break;
		case "AccountSignUp":
			actionForm = protocol + host + websiteCMSurl + "AccountSignUp.aspx" ;
			break;
		case "Home":
		case "HomePage":
			actionForm = protocol + host + websiteCMSurl + "HomePage.aspx";
			break;
		case "Deals":
			actionForm = protocol + host + websiteCMSurl + "Deals.aspx";
			break;
		case "DealsAdmin":
			actionForm = protocol + host + websiteCMSurl + "DealsAdmin.aspx";
			break;
		case "TopDestinations":
			actionForm = protocol + host + websiteCMSurl + "TopDestinations.aspx";
			break;
		case "LasVegas":
			var targetUrl;

			targetUrl = "http://lasvegas.itravel2000.com/";
			targetUrl += isWestGateway(commonForm.tm_gateway.value) ? "west" : "east";
			targetUrl += "/lasvegas";
			window.open(targetUrl);
			return;
			break;
		case "Hotels":
			actionForm = protocol + host + websiteCMSurl + "Hotels.aspx";
			break;
		case "h_HotelResults":
			actionForm = protocol + secHost + hotelsURL + "SearchResults.aspx";
			break;
		case "h_ListProducts":
			actionForm = protocol + secHost + hotelsURL + "ListProducts.aspx";
			break;
		case "h_Review":
			actionForm = protocol + secHost + hotelsURL + "HotelReview.aspx";
			break;
		case "h_HotelDetail":
			actionForm = protocol + secHost + hotelsURL + "HotelDetail.aspx";
			break;
		case "h_PassengerInfo":
			actionForm = protocol + secHost + hotelsURL + "HotelReserve.aspx";
			break;
		case "h_PaymentDetail":
			actionForm = secProtocol + secHost + hotelsURL + "HotelReserve2.aspx";
			break;
		case "h_Summary":
			actionForm = secProtocol + secHost + hotelsURL + "Summary.aspx";
			break;
		case "h_ConfirmReserve":
			actionForm = secProtocol + secHost + hotelsURL + "HotelConfirmation.aspx";
			break;
		case "Flights":
			actionForm = protocol + host + websiteCMSurl + "Flights.aspx";
			break;
		case "ContactInfo":
			actionForm = protocol + host + websiteCMSurl + "CustomerService.aspx";
			break;
		case "GatewaySearch":
			actionForm = protocol + host + websiteCMSurl + "GatewaySearch.aspx";
			parameters = parameters == null ? "referrer=1" : parameters + "&referrer=1" ;
			break;
		case "softvoyage":
			actionForm = "http://dho-sax.softvoyage.com/cgi-bin/handler.cgi";
			break;
		case "p_SearchResults":
			//actionForm = protocol + host + websiteCMSurl + "PackageSearch.aspx";
			actionForm = protocol + host + packageUrl + "PackageSearch.aspx";
			parameters = parameters == null ? "referrer=1" : parameters + "&referrer=1" ;
			break;
		case "Group":
			actionForm = protocol + host + websiteCMSurl + "GroupTravel.aspx";
			break;
		case "Corporate":
			actionForm = protocol + host + websiteCMSurl + "CorporateTravel.aspx";
			break;
		case "Careers":
			actionForm = protocol + host + websiteCMSurl + "Careers.aspx";
			break;
		case "Privacy":
			actionForm = protocol + host + websiteCMSurl + "Privacy.aspx";
			break;
		case "MediaRelations":
			actionForm = protocol + host + websiteCMSurl + "mediaCurrent.aspx";
			break;
		case "bookingTermsConditions":
			actionForm = protocol + host + websiteCMSurl + "bookingTermsConditions.aspx";
			actionForm = "http://www.itravel200.com/bookingTermsConditions.aspx"
			document.commonForm.target = "_new" ;
			break;
		case "ContestRules":
			actionForm = protocol + host + websiteCMSurl + "ContestRules.aspx";
			break;
		case "TermsConditions":
			actionForm = protocol + host + websiteCMSurl + "TermsConditions.aspx";
			document.commonForm.target = "_new" ;
			break;
		case "TermsAndConditions":
			actionForm = protocol + host + websiteCMSurl + "TermsConditions.aspx";
			break;
		case "MediaCurrent":
			actionForm = protocol + host + websiteCMSurl + "MediaCurrent.aspx";
			break;
		case "MediaLogos":
			actionForm = protocol + host + websiteCMSurl + "MediaLogos.aspx";
			break;
		case "MediaArchive":
			actionForm = protocol + host + websiteCMSurl + "MediaArchive.aspx";
			break;
			
		case "Error":
			actionForm = protocol + host + websiteCMSurl + "Error.aspx";
			break;
		case "TechnicalSupport":
			actionForm = protocol + host + websiteCMSurl + "TechnicalSupport.aspx";
			break;
		case "TechnicalSupportSuccess":
			actionForm = protocol + host + websiteCMSurl + "TechnicalSupportSuccess.aspx";
			break;
		default:
			if(formName.indexOf('.') >= 0)
			{
				actionForm = protocol + host + websiteCMSurl + formName ;
			}
			else
			{
				actionForm = '';
			}
			break;
	}
	
	if(actionForm!='')
	{
		document.commonForm.action = actionForm + (pageAnchor==null?'':'#' + pageAnchor) + (parameters==null?"":"?" + parameters);
		if (document.commonForm.__VIEWSTATE != null)
		{
			// Rename the viewstate hidden input control
			// to allow us to use server controls and validators
			document.commonForm.__VIEWSTATE.value = ''; 
			document.commonForm.__VIEWSTATE.name = 'NOVIEWSTATE'; 
		}
		document.commonForm.submit();
	}
}

function SearchPackages(fromCity, toCountry, toAirportCode)
{
	NavigateTo("Packages" , null ,"p_departCity="+ fromCity + "&p_destCountry=" + toCountry + "&p_destCity=" + toAirportCode) ;
}

function SearchFlights(fromCity, toCity) 
{
	NavigateTo("Flights" , null ,"departCity="+ fromCity + "&destCity=" + toCity) ;
}

function SearchHotels(cityName)
{
	NavigateTo("Hotels" , null ,"destCountry=0&qdestCity=" + ((cityName==null)?'':cityName)) ;
}
function SearchFlightHotels(fromCity, toCity)
{
	NavigateTo("HomePage" , null ,"currentTab=divFlightHotel&destCity=" + toCity + "&departCity=" + fromCity) ;
}

function SearchCars(fromCity, toCity, carCompany)
{
	NavigateTo("CarsRail" , null ,"departCity="+ fromCity + "&destCity=" + toCity + "&carCompany=" + ((carCompany==null)?'':carCompany)) ;
}

function SearchCruises(supplier)
{
	NavigateTo(supplier + "Cruises.aspx") ;
}

function ViewDeals(dealCategory, fromCity, toCity, dealType)
{
	var cat = "";

	if (dealCategory != null && dealCategory.length > 2)
	{
		// Full name passed, abbreviate
		cat = dealCategory.toLowerCase();
		switch(cat)
		{
			case "flight":
			case "flights":
				cat = "ft";
				break;
			case "hotel":
			case "hotels":
				cat = "hl";
				break;
			case "flight+hotel":
			case "flightplushotel":
			case "flightplushotels":
				cat = "fh";
				break;
			case "package":
			case "packages":
				cat = "pk";
				break;
			case "car":
			case "cars":
				cat = "cr";
				break;
			case "cruise":
			case "cruises":
				cat = "cs";
				break;
		}
	}
	else if (dealCategory != null)
	{
		cat = dealCategory;	
	}
				
			
	var parameters = dealCategory != null?"cat=" + cat: "";
	parameters += fromCity != null?"&dep=" + fromCity: "";
	parameters += toCity != null?"&des=" + toCity: "";
	parameters += dealType != null?"&dtp=" + dealType: "";
	
	var param = new String(parameters);
	if (param.length > 0)
	{
		if (param.charAt(0)=="&")
		{
			// Remove prefix '&'
			parameters = param.substr(1, param.length - 1);
		}
	}


	if (parameters != "")
		NavigateTo("Deals", null, parameters.toLowerCase());
	else
		NavigateTo("Deals");

}

//Function to validate whether title of each passenger is entered or not
function ValidateTitle(adults, children)
{
	
	var titles = null ;
	var titleEntered ;
	for(i=1; i <= adults; i++)
	{
		titles = document.getElementsByName("title1_" + i) ;
		titleEntered = false;
		for(j=0 ; j< titles.length ; j++)
		{
			if(titles[j].checked)
			{
				titleEntered = true ;
				break;
			}
		}
		if(!titleEntered)
			return false;
	}
	
	for(i=1; i <= children; i++)
	{
		titles = document.getElementsByName("ch_title1_" + i) ;
		titleEntered = false;
		for(j=0 ; j< titles.length ; j++)
		{
			if(titles[j].checked)
			{
				titleEntered = true ;
				break;
			}
		}
		if(!titleEntered)
			return false;
	}		
	return true;
}

//-------------------------------------------------------------
//Function: CheckGateway
//Use     : Add this function on each function's BodyLoad event
//-------------------------------------------------------------
function CheckGateway(userWant)
{
	//if(userWant!=null || (document.all.tm_gateway != null && document.all.tm_gateway.value == ""))
	if(userWant!=null)
	{
		
		var width = 340;
		var height = 230;
		
		if(navigator.appName == 'Netscape')
		{
			height = 200;
			var left = (screen.width - width)/2
			var top = (screen.height - height)/2
			window.open(websiteCMSurl + "SelectCity.aspx", window, 
				'width='+width+'px,height='+height+'px,scroll=no,resizable=no,status=yes,help=no,top=' + top + 'px,left='+ left + 'px' );
		}
		else
		{	
			var selectedCity = showModalDialog(websiteCMSurl + "SelectCity.aspx", window, 'dialogWidth:'+width+'px;dialogHeight:'+height+'px;scroll:no;resizable:no;status:yes;center:yes;help:no;');
			if(selectedCity != null) 
			{
				document.commonForm.tm_gateway.value = selectedCity ;
				document.commonForm.tm_saveGateway.value = "1" ; //1:true , 0:false
				if (document.commonForm.__VIEWSTATE != null)
				{
					document.commonForm.__VIEWSTATE.value = ''; 
					document.commonForm.__VIEWSTATE.name = 'NOVIEWSTATE'; 
				}

				document.commonForm.action = window.location.href;
				document.commonForm.submit();
			}
		}
	}
	/*
	else if(document.commonForm.tm_showLanding != null && document.commonForm.tm_showLanding.value == "1")
	{
		var oldLocation = encodeURIComponent(window.location.pathname) ;
		window.location.href = websiteCMSurl + "LandingPage.aspx?returnPath=" + oldLocation + (commonForm.tm_gateway.value.length>0?'&gateway=' + commonForm.tm_gateway.value:'') ;
	}*/
}

function SubmitChangeCity(gateways)
{
	window.opener.document.getElementById('tm_gateway').value = gateways ;
	window.opener.document.getElementById('tm_saveGateway').value = "1" ;
	window.opener.document.commonForm.action = window.opener.location ;
	window.opener.document.commonForm.submit();

}

function ToSentence(textBox)
{
   // Capitalizes the first letter
	var text = textBox.value;
	
	if (text.length > 1)
	{
		textBox.value = text.substr(0, 1).toUpperCase() 
		+ text.substr(1, text.length - 1);
	}
	else
	{
		textBox.value = text.toUpperCase();
	}
}

function Filter(textBox, valid)
{
	// Returns only valid characters in raw string
	var filtered = "";
	var raw = textBox.value;
	
	if (raw.length > 0) 
	{
		// raw is not a null string
		for (var i=0; i < raw.length; i++)
		{
			if (valid.indexOf(raw.substr(i, 1), 0) >= 0)
			{
				filtered += raw.substr(i, 1);
			}
		}
	}
	textBox.value =  filtered;
}

function CharDelete(textBox, ch)
{
	// Delete an instance of a character, ch from string
	var filtered = "";
	var raw = textBox.value;
	
	if (raw.length > 0) 
	{
		// raw is not a null string
		for (var i=0; i < raw.length; i++)
		{
			c = raw.substr(i, 1);
			if (c != ch)
			{
				filtered += c;
			}
		}
	}
	textBox.value =  filtered;
}
function ToUpper(textBox)
{
	// Make all characters upper
	var raw = textBox.value;
	
	textBox.value =  raw.toUpperCase();
}

function FormatCurrency(amount, unit)
{
	var minus = "";
	var money = amount;
	
	if(isNaN(money)) 
	{ 
		money = 0.00; 
	}
	if(money < 0) 
	{ 
		minus = "-"; 
	}
	money = Math.abs(money);
	money = parseInt((money + .005) * 100);
	money = money / 100;
				
	var formatted;
	if (money != 0)
	{
		formatted = new String(money);
	}
	else
	{
		formatted = new String("0");
	}
		
	if(formatted.indexOf(".") < 0) 
	{ 
		formatted += ".00"; 
	}
	if(formatted.indexOf(".") == (formatted.length - 2)) 
	{ 
		formatted += "0"; 
	}
	formatted = minus + formatted;
	
	return (unit + formatted);
}

function clearText(thefield)
{
	if (thefield.defaultValue==thefield.value)
		thefield.value = ""
}

function UnclearText(thefield)
{
	if (thefield.value == "")
	{
		thefield.value=thefield.defaultValue;
	}
}


// New window functionality
// Open window with specified parameters
function WindowOpen(url, windowName, windowParameters)
{
	var windowParametersInternal;

	if (windowParameters == null)
	{
		var width, height, top, left;

		width = WindowGetDefaultWidth(url);
		height = WindowGetDefaultHeight(url);
		top = (screen.height - height) / 2 - 30; //30px for taskbar at the bottom
		left = (screen.width - width) / 2;
		windowParametersInternal = "location=no, menubar=no, resizable=no, scrollbars=no, toolbar=no, height=" + height + ", width=" + width + ", top=" + top + ", left=" + left;
	}
	else
	{
		windowParametersInternal = windowParameters;
	}

	return window.open(url, windowName, windowParametersInternal);
}

function ShowDialog(url, arguments)
{
	var width = WindowGetDefaultWidth(url);
	var height = WindowGetDefaultHeight(url);
	var features = "dialogHeight:" + height + "px;dialogWidth:" + width + "px;" +"resizable:no;status:no;";

	return window.showModalDialog(url, arguments, features);
}

function GetURLwithoutArg( url )
{
	var newUrl = url ;
	var idx = url.indexOf("?") ;
	if( idx > 0 )
	{
		newUrl = url.substr(0, idx) ;
	}
	return newUrl  ;
}

// Callback functions
// Callback function that is called before any action processing
function OnAction(action)
{
	if (window.OnCustomAction == null || OnCustomAction(action))
	{
		f_mainFrame.f_action.value = action;
		f_mainFrame.submit();
	}
}			

// Callback function that is called after any action processing
function OnActionProcessed(action, param1, param2, param3)
{
	if (window.OnCustomActionProcessed == null || OnCustomActionProcessed(action, param1, param2, param3))
	{
	}
}

// Function that is called after any exception occured on the server. You can call this function to process your
// custom error messages.
function OnException(message)
{
//	if (window.OnCustomException == null || OnCustomException(message))
	if (window.OnCustomException != null)
	{
		if (OnCustomException(message))
		{
			if (document.commonForm.errorElement != null)
			{
				document.commonForm.errorElement.style.display = 'inline';
				document.commonForm.errorElement.innerText = message;
				alert(message);
			}
			else
			{
				alert(message);
			}
		}
	}
	else
	{
		alert(message);
	}
}

document.ondblclick = new Function ("return DblClick();");
function DblClick()
{
	return false;
}
// Block selection and right click on a page
//document.onselectstart = new Function ("return OnSelectStart();");
//document.oncontextmenu = new Function ("return OnContextMenu();"); // Right mouse click
//document.onkeydown = new Function ("return OnKeyDown();");
function OnSelectStart()
{
	if (event.srcElement.tagName != 'TEXTAREA' && event.srcElement.tagName != 'INPUT')
		return false;

	return true;
}

function OnContextMenu()
{
	if (event.srcElement.tagName != 'TEXTAREA' && event.srcElement.tagName != 'INPUT')
		return false;

	return true;
}

function OnKeyDown() 
{
	if (event.keyCode == 8)
	{
		if (event.srcElement.tagName != 'TEXTAREA' && event.srcElement.tagName != 'INPUT')
			event.returnValue=false;
	}
	
	return true;
}


// Form updated flag
var formChanged = false;

function OnFormChanged()
{
	formChanged = true;
}

//Validation
function Validate(messageRequired, messageType)
{
	var errMess = "" ;
	var arr ;

	if( messageRequired.length > 0 )
	{
		var arr = ValidateRequired() ;
		if( arr.length > 0 )
		{
			errMess = errMess + messageRequired + arr.join(", ") + "\n\n";
		}
	}
	
	if( messageType == null )
	{
		if( messageType.length > 0 )
		{
			arr = ValidateFieldType();
			if( arr.length > 0 )
			{
				errMess = errMess + messageType + arr.join(", ") + "\n\n" ;
			}
		}
	}

	if( errMess.length > 0 )
	{

		if (window.OnCustomException == null || OnCustomException(errMess))
		{
			if (document.commonForm.errorElement != null)
			{
				document.commonForm.errorElement.style.display = 'inline';
				document.commonForm.errorElement.innerText =  errMess ;
			}
		}
		return true ;
	}
	return false ;
}

function ValidateRequired()
{
	var arr = new Array();
	var coll = document.all.tags("INPUT");
	for (i=0; i<coll.length; i++) 
	{
		var elm = coll.item(i) ;
		if(elm.Validate == "true")
		{
			if(elm.Required == "true")
			{
				if ( elm.value.replace(/ /g,"") == "" ) 
				{
					arr = arr.concat(elm.FieldTitle) ;
				}
			}
		}
	}
	return arr ;
}

function ValidateFieldType()
{
	var arr = new Array();
	var coll = document.all.tags("INPUT");
	for (i=0; i<coll.length; i++) 
	{
		var elm = coll.item(i) ;
		if(elm.Validate == "true")
		{
//			if(elm.Required == "true")
//			{
				if ( elm.value.replace(/ /g,"") != "" ) 
				{
					var flag = false ;
					switch (elm.FieldValidationType)
					{
					   case "2": //integer
						var i = Number(elm.value) ;
						if( isNaN(i) == true )
						{
							flag = true ;
						}
						else
						{
							var i1 = parseInt(elm.value) ;
							if( i != i1 )
							{
								flag = true ;
							}
						}
						break ;
					   case "3": //float
						var fl = Number(elm.value) ;
						if( isNaN(fl) == true )
						{
							flag = true ;
						}
						break ;
					   case "4": //DateTime
						var d = Date.parse(elm.value) ;
						if( isNaN(d) == true )
						{
							flag = true ;
						}
						break ;
					   case "1": // String
						break ;
					   case "0": // none
						break ;
					   case "5": // boolean
						break ;
 					   default: 
						break ;
					}
					if( flag == true )
					{
						arr = arr.concat(elm.FieldTitle) ;
					}
				}
//			}
		}
	}
	return arr ;
}

//string functions
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
}

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length - 1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	}
	return strTemp;
}

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} 
	return strTemp;
}

//document events Disable functions
document.oncontextmenu = DisableContextMenu ;
//document.onkeydown = DisableKeydown ;
function DisableContextMenu() 
{
	if( event.srcElement.tagName != "INPUT" )
	{
		return false; 
	}
}
function DisableKeydown() 
{
	if(navigator.appName == "Netscape")
		return false;
	
	if( (event.altKey == true) || (event.ctrlKey == true) )
	{
		if( (event.keyCode != 65) && //a
			(event.keyCode != 67) && //c
			(event.keyCode != 86) && //v
			(event.keyCode != 88) )  //x
		{
			event.cancelBubble = true ;
			event.returnValue = false ;  
			return false; 
		}
	}
}

//decode
function DecodeArray(obj)
{
	var i = 0 ;
	if( obj != null )
	{
		if( typeof(obj) != "object" )
		{
			obj = unescape(obj) ;
		}
		else
		{
			for( i = 0; i < obj.length; i++)
			{
				obj[i] = DecodeArray(obj[i]) ;
			}
		}
	}
	return obj ;
}

//Application	: TopMenu control
//Function		: Changes the current Affiliate ID of PageCommon control to the new selection
//				  and send it to HomePage.
function ChangeCurrentAffiliate()
{
	document.all.pc_currentAffiliateID.value = document.all.affiliateList.options[document.all.affiliateList.selectedIndex].value ;
	NavigateTo('ChangeAffiliate') ;
}


// Validates date
function IsValidDate(dateStr, format)
{
	if (format == null) 
	{
		format = "DMY"; 
	}
	
	format = format.toUpperCase();
	if (format.length != 3) 
	{ 
		format = "DMY"; 
	}
		
	if ( (format.indexOf("M") == -1) 
		|| (format.indexOf("D") == -1) 
		|| (format.indexOf("Y") == -1)) 
	{ 
		format = "MDY"; 
	}
		
	if (format.substring(0, 1) == "Y") 
	{ 
		// If the year is first
		var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
		var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
	} 
	else if (format.substring(1, 2) == "Y") 
	{ 
		// If the year is second
		var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
		var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
	}
	else 
	{ 
		// The year must be third
		var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
		var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
	}
   
	// If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
	if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) 
	{ 
		return false; 
	}
   
	var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
	
	// Check to see if the 3 parts end up making a valid date
   if (format.substring(0, 1) == "M") 
   { 
		var mm = parts[0]; 
	}
	else if (format.substring(1, 2) == "M") 
	{ 
		var mm = parts[1]; 
	}
	else
	{
		var mm = parts[2];
	}
	
	if (format.substring(0, 1) == "D")
	{ 
		var dd = parts[0]; 
	}
	else if (format.substring(1, 2) == "D") 
	{ 
		var dd = parts[1]; 
	}
	else
	{ 
		var dd = parts[2];
	}
	
	if (format.substring(0, 1) == "Y") 
	{ 
		var yy = parts[0]; 
	}
	else if (format.substring(1, 2) == "Y")
	{
		var yy = parts[1];
	}
	else
	{
		var yy = parts[2];
	}
   
	if (parseFloat(yy) <= 50) 
	{ 
		yy = (parseFloat(yy) + 2000).toString(); 
	}
	if (parseFloat(yy) <= 99)
	{ 
		yy = (parseFloat(yy) + 1900).toString();
	}
   
	var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
	if (parseFloat(dd) != dt.getDate()) 
	{ 
		return false; 
	}
	
	if (parseFloat(mm)-1 != dt.getMonth()) 
	{ 
		return false;
	}
	
	return true;
}

function Request(key)
{
	var strQueryString=QueryString();

	if (strQueryString.length < 1)
		return "";

	arrTmp=strQueryString.split("&");

	for (var i=0; i<arrTmp.length; i++)
	{

		var arrTmp2=arrTmp[i].split("=");

		if (arrTmp2.length < 1)
			continue;

		var curKey=arrTmp2[0];

		var curValue=(arrTmp2.length < 2)?"":arrTmp2[1];

		if (curKey.toLowerCase() == key.toLowerCase())

			return curValue;
	}

	return "";

}

function QueryString()
{
	var strFullUrl=document.location+"";

	var arrTmp=strFullUrl.split("?");

	if (arrTmp.length < 2)
		return "";
	 
	return arrTmp[1];

}


/// Validation functions

function IsValidCardNumber(cardTypeCode, cardNumber)
{
	if(isNaN(cardNumber))
	{
		return false;
	}
	
	var i;
	
	//1. Calculate Luhn Sum
	var sum = 0;
	var IsEvenDigit = false;	//First digit is not even, second is, first is not...
	var digit, digitSum1, digitSum2;
	for (i = cardNumber.length-1; i >= 0; i--)
	{
		digit = parseInt(cardNumber.substr(i,1));
		if (! IsEvenDigit)
			sum += digit;
		else
		{
			digitSum1 = digit * 2;
			digitSum2 =	parseInt((digitSum1 / 10).toString()) + digitSum1 % 10;
			sum += digitSum2;
		}
		IsEvenDigit = ! IsEvenDigit;
	}
	//2. Check Luhn Sum
	if (sum % 10 != 0) 
	{
		return false; //Luhn summ check failed - Number is not valId
	}
	//3. Check criterias specific to a selected credit card type 
	switch (parseInt(cardTypeCode))
	{
		case 1: //VISA
			if (!((cardNumber.length==13 || cardNumber.length==16) &&
				(cardNumber.substr(0,1) == "4")))
				return false;
			break;
		case 2: //MasterCard
			if (!((cardNumber.length==16) &&
				(parseInt(cardNumber.substr(0,2)) >= 51 
				&& parseInt(cardNumber.substr(0,2)) <= 55)))
				return false;
			break;
		case 3: //AMEX
			if (!((cardNumber.length==15) &&
				(cardNumber.substr(0,2)=="34" || cardNumber.substr(0,2)=="37")))
				return false;
			break;
	}
	
	return true; 
}	

function IsValidEmail(emailStr)
{
	if (emailStr=="")
	{
		return true;
	}
	
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) 
	{
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			return false;
		}
	}

	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			return false;
		}
	}

	if (user.match(userPat)==null)
	{
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				return false;
			}
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			return false;
		}
	}

	if (len<2) 
	{
		return false;
	}

	return true;
}

function validateGC() 
{
  var regex = /^[A-Za-z0-9]+$/;
  var re =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (document.getElementById('firstname').value == "") {
    alert("Please enter your firstname");
    setFocus('firstName');
    return false;
  }else if (document.getElementById('lastname').value == "") {
    alert("Please enter your lastname");
    setFocus('lastName');
    return false;
  }else if (document.getElementById('address').value == "") {
    alert("Please enter your address");
    setFocus('address');
    return false;
  } else if (document.getElementById('city').value == "") {
    alert("Please enter your city or town.");
    setFocus('city');
    return false;
  }else if (document.getElementById('email').value == "" ) {
    alert("Please enter your e-mail address");
    setFocus('email');
    return false;
  } else if (!re.test(document.getElementById('email').value)) {
    alert("Please enter a valid email address");
    setFocus('email');
    return false;
  }else if (document.getElementById('postalCode').value == "" ) {
    alert("Please enter your postalCode");
    setFocus('postalCode');
    return false;
  }else if(!regex.test(document.getElementById('postalCode').value)){
    alert('Invalid postal code.  Please type in your postal code, using no spaces or hyphens.');
    setFocus('postalCode');
    return false;
  }else if (document.getElementById('hPhone').value == "" ) {
    alert("Please enter your home phone");
    setFocus('hPhone');
    return false;
  }else if (document.getElementById('wPhone').value == "" ) {
    alert("Please enter your work phone.");
    setFocus('wPhone');
    return false;
  }else if (! IsValidPhone(document.getElementById('hPhone').value)) {
    alert("Please enter a valid home phone");
    setFocus('hPhone');
    return false;
  }else if (! IsValidPhone(document.getElementById('wPhone').value)) {
    alert("Please enter a valid work phone.");
    setFocus('wPhone');
    return false;
  }else if (document.getElementById('amount').value == "" ) {
    alert("Please select gift certificate amount");
    setFocus('amount');
    return false;
  }
  return true;
}


function IsAlphabeticOnly(value)
{	
	var regex=/^[a-zA-Z]+$/;
	return regex.test(value);
	
}

function IsAlphabeticAndSpaceOnly(value)
{	
	var regex = /^[a-zA-Z]+[ ]+[a-zA-Z]+$/;
	return regex.test(value);
	
}

function IsValidPhone(number)
{
	/*
	if (isNaN(number))
	{
		return false;
	}
	else 
	*/
	
	if(number.length >= 10 && number.length <= 14)
	{	
		var regex =	/^\(?\d{3}\)?\.?-?\s*\d{3}\s*-?\.?\d{4}$/;	//	/^[0-9 \.\(\)-]+$/;
		return regex.test(number);
		
	}	
	else
		return false;
}

function IsDateOk(date)
{
	var dateSelected = new Date(date);
	var mm = dateSelected.getMonth() + 1;
	if (isNaN(mm))
	{
		return false;
	}
	var dd = dateSelected.getDate();
	if (isNaN(dd))
	{
		return false;
	}
	var yy = dateSelected.getFullYear();
	if (isNaN(yy))
	{
		return false;
	}
	var dateString = mm + "/" + dd + "/" + yy;
	return IsValidDate(dateString, "MDY");
}


function GoBack(pageNumber)
{
	if(pageNumber != null && !isNaN(parseInt(pageNumber)))
	{
		history.go(pageNumber) ;
	}
	else if(pageNumber != null)
	{
		history.go("'" + pageNumber + "'") ;
	}
	else
	{
		history.go(-1) ;
	}
}

function DoLeftToolSearch()
{
	if(document.all.searchValue != null && document.all.searchValue.value.length>0)
	{
		document.all.pc_resSearchSource.value = 2 //LeftMenu
		for(var i = 0; i < document.all.searchOption.length; i++) 
		{
			if(document.all.searchOption[i].checked)
				document.all.pc_resSearchOption.value = document.all.searchOption[i].value ;
		}
		document.all.pc_resSearchValue.value = document.all.searchValue.value;
		NavigateTo('ReservationList');
		return true;
	}
	else
	{
		var leftToolControls = window.document.forms[0];
			for(var i=0; i<leftToolControls.length; i++)
			{
				var temp = leftToolControls.elements[i].type;
				if((temp == "radio") && (leftToolControls.elements[i].checked) && leftToolControls.elements[i].name== 'searchOption') 
				{ 
					if(leftToolControls.elements[i].value=='1')
					{
					alert('Please enter Booking Number to search reservation.') ;
					}
					else if(leftToolControls.elements[i].value=='2')
					{
						alert('Please enter Customer Name to search reservation.') ;
					}
					else if(leftToolControls.elements[i].value=='3')
					{
						alert('Please enter Booking Status to search reservation.') ;
					}
					else if(leftToolControls.elements[i].value=='4')
					{
						alert('Please enter Agent Name to search reservation.') ;
					}
					document.all.pc_resSearchOption.value = leftToolControls.elements[i].value ;
				}
			}
		return false;
	}
}

function dateDiff(dateFrom ,dateTo) 
{
	var diff  = new Date();

	diff.setTime(Math.abs(dateFrom.getTime() - dateTo.getTime()));

	var timediff = diff.getTime();

	days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 

	return days; 
}

//---------------------------------------
//Code for bussy animation
//---------------------------------------
var timerID = 0;
var dotCount = 1;
var tStart  = null;
var prevValue  = null;

function UpdateTimer() 
{
	if(timerID) {
		clearTimeout(timerID);
		clockID  = 0;
	}

	if(!tStart)
		tStart   = new Date();

	document.all.bussyText.innerHTML = "Total search time " + dotCount + " sec." ;
	dotCount++;
		
	timerID = setTimeout("UpdateTimer()", 1000);
}

function Start() 
{
	tStart   = new Date();
	prevValue = document.all.bussyText.innerHTML ;
	timerID  = setTimeout("UpdateTimer()", 1000);
}

function Stop() 
{
	if(timerID) {
		clearTimeout(timerID);
		timerID  = 0;
	}
	tStart = null;
}
	function Reset() {
	tStart = null;
}
//---------------------------------------

//-----------------------------------------
///Following function will populate cities
//-----------------------------------------

function ChangeCity(cityList ,code)
{
	cityList.options.length=1;
	
	if(code==5) //Caribbean
	{
		cityList.options[1] = new Option('Antigua','ANU');
		cityList.options[2] = new Option('Aruba','AUA');
		cityList.options[3] = new Option('Barbados','BGI');
		cityList.options[4] = new Option('Bermuda','BDA');
		cityList.options[5] = new Option('Cayo Coco','CCC'); 
		cityList.options[6] = new Option('Freeport','FPO'); 
		cityList.options[7] = new Option('Havana','HAV'); 
		cityList.options[8] = new Option('Holguin','HOG'); 
		cityList.options[9] = new Option('Liberia','LIR');
		cityList.options[10] = new Option('La Romana','LRM'); 
		cityList.options[11] = new Option('Montego Bay','MBJ'); 
		cityList.options[12] = new Option('Nassau','NAS'); 
		cityList.options[13] = new Option('Puerto Plata','POP'); 
		cityList.options[14] = new Option('Punta Cana','PUJ'); 
		cityList.options[15] = new Option('Santiago de Cuba','SCU'); 
		cityList.options[16] = new Option('Santo Domingo','SDQ'); 
		cityList.options[17] = new Option('St. Kitts','SKB');
		cityList.options[18] = new Option('St. Lucia','UVF');
		cityList.options[19] = new Option('Turks & Caicos','PLS'); 
		cityList.options[20] = new Option('Varadero','VRA'); 
	}
	else if(code==4) //Mexico
	{
		cityList.options[1] = new Option('Acapulco','ACA'); 
		cityList.options[2] = new Option('Akumal','CUN'); 	
		cityList.options[3] = new Option('Cabo San Lucas','SJD');
		cityList.options[4] = new Option('Cancun','CUN');	
		cityList.options[5] = new Option('Chichen Itza','CZA');
		cityList.options[6] = new Option('Corredor','PBC');
		cityList.options[7] = new Option('Cozumel','CZM');
		cityList.options[8] = new Option('Guadalajara','GDL');
		cityList.options[9] = new Option('Huatulco','HUX');
		cityList.options[10] = new Option('Isla Holbox','CUN');
		cityList.options[11] = new Option('Isla Mujeres','ISJ');
		cityList.options[12] = new Option('Ixtapa','ZIH');	
		cityList.options[13] = new Option('Kantenah','CUN');
		cityList.options[14] = new Option('Manzanillo','ZLO');
		cityList.options[15] = new Option('Marina Vallarta','PVR');
		cityList.options[16] = new Option('Mazatlan','MZT');
		cityList.options[17] = new Option('Merida','MID');	
		cityList.options[18] = new Option('Mexico City','MEX');
		cityList.options[19] = new Option('Nuevo Vallarta','PVR');
		cityList.options[20] = new Option('Palenque','PQM');
		cityList.options[21] = new Option('Playa del Carmen','PCM');
		cityList.options[22] = new Option('Puerto Aventuras','CUN');
		cityList.options[23] = new Option('Puerto Escondido','PXM');
		cityList.options[24] = new Option('Puerto Morelos','CUN');
		cityList.options[25] = new Option('Puerto Vallarta','PVR');
		cityList.options[26] = new Option('Punta Bete','CUN');
		cityList.options[27] = new Option('Punta Maroma','CUN');
		cityList.options[28] = new Option('San Cristobal','SZT');
		cityList.options[29] = new Option('San Jose del Cabo','SJD');
		cityList.options[30] = new Option('Tulum','TUY');	
		cityList.options[31] = new Option('Uxmal','CUN');	
		cityList.options[32] = new Option('Xpu-Ha','CUN');	
	}
	else if(code==3) //Europe
	{
		cityList.options[1] = new Option('Amsterdam','AMS');
		cityList.options[2] = new Option('Antwerp','ANR');
		cityList.options[3] = new Option('Berlin','TXL');
		cityList.options[4] = new Option('Brussels','BRU');
		cityList.options[5] = new Option('Budapest','BUD');
		cityList.options[6] = new Option('Dresden','DRS');
		cityList.options[7] = new Option('Dublin','DUB');
		cityList.options[8] = new Option('Frankfurt','FRA');
		cityList.options[9] = new Option('Geneva','GVA');
		cityList.options[10] = new Option('Hamburg','HAM');
		cityList.options[11] = new Option('Innsbruck','INN');
		cityList.options[12] = new Option('Krakow','KRK');
		cityList.options[13] = new Option('London','LON');	// LHR LGW
		cityList.options[14] = new Option('Lugano','LUG');
		cityList.options[15] = new Option('Malaga','AGP');
		cityList.options[16] = new Option('Munich','MUC');
		cityList.options[17] = new Option('Paris','CDG');
		cityList.options[18] = new Option('Prague','PRG');
		cityList.options[19] = new Option('Salzburg','SZG');
		cityList.options[20] = new Option('Vienna','VIE');
		cityList.options[21] = new Option('Warsaw','WAW');
		cityList.options[22] = new Option('Zurich','ZRH');
	}
	else if(code==2) //USA
	{
		cityList.options[1] = new Option('Albuquerque','ABQ');
		cityList.options[2] = new Option('Atlanta','ATL');
		cityList.options[3] = new Option('Baltimore','BWI');
		cityList.options[4] = new Option('Charlotte','CLT');
		cityList.options[5] = new Option('Chicago','CHI');		// ORD MDW
		cityList.options[6] = new Option('Cleveland','CLE');
		cityList.options[7] = new Option('Dallas','DFW');
		cityList.options[8] = new Option('Denver','DEN');
		cityList.options[9] = new Option('Fort Myers','RSW');
		cityList.options[10] = new Option('Ft. Lauderdale','FLL');		
		cityList.options[11] = new Option('Honolulu','HNL');
		cityList.options[12] = new Option('Houston','HOU');		// IAH
		cityList.options[13] = new Option('Las Vegas','LAS');
		cityList.options[14] = new Option('Los Angeles','LAX');
		cityList.options[15] = new Option('Kona','KOA');
		cityList.options[16] = new Option('Maui','OGG');
		cityList.options[17] = new Option('Memphis','MEM');
		cityList.options[18] = new Option('Miami','MIA');
		cityList.options[19] = new Option('Myrtle Beach','MYR');
		cityList.options[20] = new Option('Nashville','BNA');
		cityList.options[21] = new Option('Newark','EWR');
		cityList.options[22] = new Option('New Orleans','MSY');
		cityList.options[23] = new Option('New York','NYC');	// EWR LGA JFK
		cityList.options[24] = new Option('Orlando','ORL');
		cityList.options[25] = new Option('Palm Beach','PBI');
		cityList.options[26] = new Option('Palm Springs','PSP');
		cityList.options[27] = new Option('Pensacola','PNS');
		cityList.options[28] = new Option('Philadelphia','PHL');
		cityList.options[29] = new Option('Phoenix','PHX');
		cityList.options[30] = new Option('Pittsburgh','PIT');
		cityList.options[31] = new Option('Portland','PDX');
		cityList.options[32] = new Option('Raleigh','RDU');
		cityList.options[33] = new Option('Reno','RNO');
		cityList.options[34] = new Option('Sacramento','SAC');
		cityList.options[35] = new Option('Salt Lake City','SLC');
		cityList.options[36] = new Option('Santa Monica','SMO');			
		cityList.options[37] = new Option('San Antonio','SAT');
		cityList.options[38] = new Option('San Diego','SAN');
		cityList.options[39] = new Option('San Francisco','SFO');
		cityList.options[40] = new Option('San Jose','SJC');
		cityList.options[41] = new Option('Sarasota','SRQ');
		cityList.options[42] = new Option('Scottsdale','SCF');	
		cityList.options[43] = new Option('Seattle','SEA');
		cityList.options[44] = new Option('Sedona','SDX');
		cityList.options[45] = new Option('St. Augustine','UST');
		cityList.options[46] = new Option('St. Petersburg','PIE');
		cityList.options[47] = new Option('Tampa','TPA');
		cityList.options[48] = new Option('Tucson','TUS');				
		cityList.options[49] = new Option('Washington','WAS');	// IAD DCA BWI
	}
	else if(code==1) // canada
	{
		/*cityList.options[1] = new Option('Banff', 'YBA');
		cityList.options[2] = new Option('Calgary', 'YYC');
		cityList.options[3] = new Option('Edmonton', 'YEG');
		cityList.options[4] = new Option('Halifax', 'YHZ');
		cityList.options[5] = new Option('Kamloops', 'YKA');
		cityList.options[6] = new Option('Kelowna', 'YLW');
		cityList.options[7] = new Option('Montreal', 'YUL');
		cityList.options[8] = new Option('Ottawa', 'YOW');
		cityList.options[9] = new Option('Prince George', 'YXS');
		cityList.options[10] = new Option('Toronto', 'YYZ');
		cityList.options[11] = new Option('Vancouver', 'YVR');
		cityList.options[12] = new Option('Victoria', 'YYJ');*/
		
		cityList.options[1] = new Option('Abbotsford, BC', 'YXX');
		cityList.options[2] = new Option('Amos, PQ', 'YEY');
		cityList.options[3] = new Option('Atikokan, ON', 'YIB');
		cityList.options[4] = new Option('Baie Comeau, PQ', 'YBC');
		cityList.options[5] = new Option('Banff, AB', 'YBA');
		cityList.options[6] = new Option('Blanc Sablon, PQ', 'YBX');
		cityList.options[7] = new Option('Bonaventure, PQ', 'YVB');
		cityList.options[8] = new Option('Brandon, MB', 'YBR');
		cityList.options[9] = new Option('Burns Lake, BC', 'YPZ');
		cityList.options[10] = new Option('Calgary, AB', 'YYC');
		cityList.options[11] = new Option('Campbell River, BC', 'YBL');
		cityList.options[12] = new Option('Castlegar, BC', 'YCG');
		cityList.options[13] = new Option('Chapleau, ON', 'YLD');
		cityList.options[14] = new Option('Charlottetown, PE', 'YYG');
		cityList.options[15] = new Option('Chibougamau, PQ', 'YMT');
		cityList.options[16] = new Option('Comox, BC', 'YQQ');
		cityList.options[17] = new Option('Coppermine, NU', 'YCO');
		cityList.options[18] = new Option('Cornwall, ON', 'YCC');
		cityList.options[19] = new Option('Courtenay, BC', 'YCA');
		cityList.options[20] = new Option('Cranbrook, BC', 'YXC');
		cityList.options[21] = new Option('Churchill, MB', 'YYQ');
		cityList.options[22] = new Option('Dauphin, MB', 'YDN');
		cityList.options[23] = new Option('Dawson Creek, BC', 'YDQ');
		cityList.options[24] = new Option('Deer Lake, NF', 'YDF');
		cityList.options[25] = new Option('Deer Lake, ON', 'YVZ');
		cityList.options[26] = new Option('Dryden, ON', 'YHD');
		cityList.options[27] = new Option('Edmonton, AB', 'YEG');
		cityList.options[28] = new Option('Elliot Lake, ON', 'YEL');
		cityList.options[29] = new Option('Esquimalt, BC', 'YPF');
		cityList.options[30] = new Option('Fredericton, NB', 'YFC');
		cityList.options[31] = new Option('Fort Mcmurray, AB', 'YMM');
		cityList.options[32] = new Option('Fort Simpson, NT', 'YFS');
		cityList.options[33] = new Option('Fort Smith, NT', 'YSM');
		cityList.options[34] = new Option('Fort St John, BC', 'YXJ');
		cityList.options[35] = new Option('Gaspe, PQ', 'YGP');
		cityList.options[36] = new Option('Gander, NF', 'YQX');
		cityList.options[37] = new Option('Gatineau, PQ', 'YND');
		cityList.options[38] = new Option('Gillam, MB', 'YGX');
		cityList.options[39] = new Option('Gillies Bay, BC', 'YGB');
		cityList.options[40] = new Option('Grande Prairie, AB', 'YQU');
		cityList.options[41] = new Option('Goose Bay, NF', 'YYR');
		cityList.options[42] = new Option('Halifax, NS', 'YHZ');
		cityList.options[43] = new Option('Hamilton, ON', 'YHM');
		cityList.options[44] = new Option('Hay River, NT', 'YHY');
		cityList.options[45] = new Option('High Level, AB', 'YOJ');
		cityList.options[46] = new Option('Holman Island, NT', 'YHI');
		cityList.options[47] = new Option('Hornepayne, ON', 'YHN');
		cityList.options[48] = new Option('Hudson Bay, SK', 'YHB');
		cityList.options[49] = new Option('Iles De La Madeleine, PQ', 'YGR');
		cityList.options[50] = new Option('Igloolik, NU', 'YGT');
		cityList.options[50] = new Option('Inuvik, NT', 'YEV');
		cityList.options[51] = new Option('Iqaluit, NU', 'YFB');
		cityList.options[52] = new Option('Jasper, AB', 'YJA');
		cityList.options[53] = new Option('Kamloops, BC', 'YKA');
		cityList.options[54] = new Option('Kapuskasing, ON', 'YYU');
		cityList.options[55] = new Option('Kelowna, BC', 'YLW');
		cityList.options[56] = new Option('Kenora, ON', 'YQK');
		cityList.options[57] = new Option('Kitchener, ON', 'YKF');
		cityList.options[58] = new Option('Kingston, ON', 'YGK');
		cityList.options[59] = new Option('Kuujjuarapik, PQ', 'YGW');
		cityList.options[60] = new Option('Kuujjuaq, PQ', 'YVP');
		cityList.options[61] = new Option('La Ronge, SK', 'YVC');
		cityList.options[62] = new Option('La Tuque, PQ', 'YLQ');
		cityList.options[63] = new Option('Lethbridge, AB', 'YQL');
		cityList.options[64] = new Option('London, ON', 'YXU');
		cityList.options[65] = new Option('Marathon, ON', 'YSP');
		cityList.options[66] = new Option('Medicine Hat, AB', 'YXH');
		cityList.options[67] = new Option('Moncton, NB', 'YQM');
		cityList.options[68] = new Option('Mont Joli, PQ', 'YYY');
		cityList.options[69] = new Option('Montreal, PQ', 'YMQ');
		cityList.options[70] = new Option('Moosonee, ON', 'YMO');
		cityList.options[71] = new Option('Nanaimo, BC', 'YCD');
		cityList.options[72] = new Option('North Bay, ON', 'YYB');
		cityList.options[73] = new Option('Oshawa, ON', 'YOO');
		cityList.options[74] = new Option('Ottawa, ON', 'YOW');
		cityList.options[75] = new Option('Peace River, AB', 'YPE');
		cityList.options[76] = new Option('Pembroke, ON', 'YTA');
		cityList.options[77] = new Option('Penticton, BC', 'YYF');
		cityList.options[78] = new Option('Powell River, BC', 'YPW');
		cityList.options[79] = new Option('Port Hardy, BC', 'YZT');
		cityList.options[80] = new Option('Prince George, BC', 'YXS');
		cityList.options[81] = new Option('Prince Rupert, BC', 'YPR');
		cityList.options[82] = new Option('Quaqtaq, PQ', 'YQC');
		cityList.options[83] = new Option('Quebec City, PQ', 'YQB');
		cityList.options[84] = new Option('Quesnel, BC', 'YQZ');
		cityList.options[85] = new Option('Rainbow Lake, AB', 'YOP');
		cityList.options[86] = new Option('Red Lake, ON', 'YRL');
		cityList.options[87] = new Option('Regina, SK', 'YQR');
		cityList.options[88] = new Option('Resolute, NU', 'YRB');
		cityList.options[89] = new Option('Saint John, NB', 'YSJ');
		cityList.options[90] = new Option('Salmon Arm, BC', 'YSN');
		cityList.options[91] = new Option('Saskatoon, SK', 'YXE');
		cityList.options[92] = new Option('Sault Ste Marie, ON', 'YAM');
		cityList.options[93] = new Option('Schefferville, PQ', 'YKL');
		cityList.options[94] = new Option('Sept-Iles, PQ', 'YZV');
		cityList.options[95] = new Option('Sioux Lookout, ON', 'YXL');
		cityList.options[96] = new Option('Smith Falls, ON', 'YSH');
		cityList.options[97] = new Option('Smithers, BC', 'YYD');
		cityList.options[98] = new Option('St Catharines, ON', 'YCM');
		cityList.options[99] = new Option('St Leonard, NB', 'YSL');
		cityList.options[100] = new Option('St Johns, NF', 'YYT');
		cityList.options[101] = new Option('Stephenville, NF', 'YJT');
		cityList.options[102] = new Option('Stony Rapids, SK', 'YSF');
		cityList.options[103] = new Option('Sudbury, ON', 'YSB');
		cityList.options[104] = new Option('Sydney, NS', 'YQY');
		cityList.options[105] = new Option('Terrace, BC', 'YXT');
		cityList.options[106] = new Option('The Pas, MB', 'YQD');
		cityList.options[107] = new Option('Thicket Portage, MB', 'YTD');
		cityList.options[108] = new Option('Thompson, MB', 'YTH');
		cityList.options[109] = new Option('Thunder Bay, ON', 'YQT');
		cityList.options[110] = new Option('Timmins, ON', 'YTS');
		cityList.options[111] = new Option('Tofino, BC', 'YAZ');
		cityList.options[112] = new Option('Toronto, ON', 'YYZ');
		cityList.options[113] = new Option('Vancouver, BC', 'YVR');
		cityList.options[114] = new Option('Victoria, BC', 'YYJ');
		cityList.options[115] = new Option('Wabush, NF', 'YWK');
		cityList.options[116] = new Option('Watson Lake, YT', 'YQH');
		cityList.options[117] = new Option('Waskaganish, PQ', 'YKQ');
		cityList.options[118] = new Option('Wawa, ON', 'YXZ');
		cityList.options[119] = new Option('Whitehorse, YT', 'YXY');
		cityList.options[120] = new Option('White River, ON', 'YWR');
		cityList.options[121] = new Option('Williams Lake, BC', 'YWL');
		cityList.options[122] = new Option('Windsor, ON', 'YQG');
		cityList.options[123] = new Option('Winnipeg, MB', 'YWG');
		cityList.options[124] = new Option('Yarmouth, NS', 'YQI');
		cityList.options[125] = new Option('Yellowknife, NT', 'YZF');
		
	}
}

function getLocationAirportCode(cityName)
{	
	var location =
	[
		['Toronto','YYZ'],  
		['Vancouver','YVR'],  
		['Whistler','YWS'],  
		['Niagara Falls','XLV'],  
		['Calgary','YYC'],  
		['Victoria','YYJ'],  
		['Ottawa','YOW'],  
		['Edmonton','YEG'],  
		['Halifax','YHZ'],  
		['Montreal','YMQ'],  
		['Banff','YBA'],  
		['Mont Tremblant','Mont Tremblant'],  
		
		['Las Vegas','LAS'],  
		['Chicago','CHI'],  
		['New York','NYC'],  
		['San Francisco','SFO'],  
		['Boston','BOS'],  
		['Ft. Lauderdale','FLL'],  
		['Orlando','ORL'],  
		['Phoenix','PHX'],  
		['Los Angeles','LAX'],  
		['Miami','MIA'],  
		['Maui','OGG'],  
		['Kauai','LIH'],  
		
		['Cancun','CUN'],  
		['Puerto Vallarta','PVR'],  
		['Acapulco','ACA'],  
		['Mayan Riviera','CUN'],  
		['Cozumel','CZM'],  
		['Los Cabos','SJD'],  
		['Mexico City','MEX'],  
		['Ixtapa','ZIH'],  
		['Guadalajara','GDL'],  
		['Mazatlan','MZT'],  
		['Manzanillo','ZLO'],  
		['Huatulco','HUX'],  		
		
		['Havana','HAV'],  
		['Varadero','VRA'],  
		['St. Martin','SFG'],  
		['Puerto Plata','POP'],  
		['Nassau','NAS'],  
		['Freeport','FPO'],  
		['Aruba','AUA'],  
		['Guadeloupe','Guadeloupe'],  
		['Grand Cayman','GCM'],  
		['Punta Cana','PUJ'],  
		['St. Croix','STX'],  

		['London','LON'],  
		['Amsterdam','AMS'],  
		['Rome','ROM'],  
		['Frankfurt','FRA'],  
		['Belfast','BFS'],  
		['Paris','CDG'],  
		['Prague','PRG'],  
		['Zurich','ZRH'],  
		['Athens','ATH'],  
		['Lisbon','LIS'],  
		['Madrid','MAD'],  
		['Istanbul','IST'],  		

		['Cape Town','CPT'],  
		['Hong Kong','HKG'],  
		['Johannesburg','JNB'],  
		['Beijing','BJS'],  
		['Sydney','SYD'],  
		['Dubai','DXB'],  
		['Auckland','AKL'],  
		['Singapore','SIN'],  
		['Nairobi','NBO'],  
		['Tokyo','TYO'],  
		['Bangkok','BKK'],  
		['Sri Lanka','Sri Lanka'],  		
		['Bombay','BOM'],  
		['Kuala Lumpur','KUL'],  
		['New Delhi','DEL']  		
	] ;
	
	for(i=0 ; i < location.length ;i++)
	{
		if(location[i][0]==cityName)
		{
			return location[i][1];
		}
	}
	return cityName;
		
}

function ValidPhone(number)
{
	/*
	if (isNaN(number))
	{
		return false;
	}
	else
	*/
	
	if( number.length >= 10 && number.length <= 14)
	{
		var regex = /^\(?\d{3}\)?\.?-?\s*\d{3}\s*-?\.?\d{4}$/;	//	/^[0-9 \.\(\)-]+$/;
		return regex.test(number);
	}
	else
		return false;
}

function emailCheck(emailStr)
{
	if (emailStr=="")
	{
		return true;
	}
	
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) 
	{
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) 
	{
		if (user.charCodeAt(i)>127) 
		{
			return false;
		}
	}

	for (i=0; i<domain.length; i++) 
	{
		if (domain.charCodeAt(i)>127) 
		{
			return false;
		}
	}

	if (user.match(userPat)==null)
	{
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
				return false;
			}
		}
		return true;
	}

	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;

	for (i=0;i<len;i++) 
	{
		if (domArr[i].search(atomPat)==-1) 
		{
			return false;
		}
	}

	if (len<2) 
	{
		return false;
	}

	return true;
}

// Checks if gateway is a west gateway. By default gateway considered to be east.
function isWestGateway(gateway)
{
	return (
		gateway == 'Vancouver' || gateway == 'Edmonton' ||  gateway == 'Victoria' ||
		gateway == 'Winnipeg' || gateway == 'Regina' || gateway == 'Calgary');
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BanManPro banners

// Common function to show BanManPro banner. Can be used in any project.
function bannerShowCommon(siteId, zoneId)
{
	if (navigator.appName == 'Netscape')
		document.write('<s' + 'cript language="javascript" src="http://' + banManProServer + '/a.aspx?ZoneID=' + zoneId + '&amp;Task=Get&amp;IFR=False&amp;Browser=NETSCAPE4&amp;PageID=11297&amp;SiteID=' + siteId + '&amp;Random=(new Date()).getTime()">');
	else
		document.write('<s' + 'cript language="javascript" src="http://' + banManProServer + '/a.aspx?ZoneID=' + zoneId + '&amp;Task=Get&amp;IFR=False&amp;PageID=11297&amp;SiteID=' + siteId + '&amp;Random=(new Date()).getTime()">');
	
	document.write('</s' + 'cript>');	
}

function getSiteId(siteNameParam)
{
	switch (siteNameParam)
	{
		case 'iTravel2000Main': return 3;
		default: return 3; // 'iTravel2000Main' by default
	}
		
}

// Site specific functionality
function getZoneId(zoneName)
{
	var siteId = getSiteId(siteName);
	var gateway = commonForm.tm_gateway.value;
	var westGateway = isWestGateway(gateway);
		
	if (siteId == 5)
	{
	}
	if (siteId == 6)
	{
	}
	else
	{
		// Make iTravel2000 main website (siteId = 3) as default.
		switch (zoneName)
		{
			case 'Cars.aspx Footer': return westGateway ? 40 : 36;			
			case 'Cars.aspx Promo': return westGateway ? 41 : 7;
			case 'Cruises.aspx Footer': return westGateway ? 42 : 37;
			case 'Cruises.aspx Promo': return westGateway ? 43 : 8;
			case 'CustomerService.aspx Banner 1': return westGateway ? 44 : 23;
			case 'CustomerService.aspx Banner 2': return westGateway ? 45 : 24;
			case 'CustomerService.aspx Banner 3': return westGateway ? 46 : 25;
			case 'Deals.aspx Cars Promo': return westGateway ? 47 : 16;
			case 'Deals.aspx Cruises Promo': return westGateway ? 48 : 17;
			case 'Deals.aspx Flights Promo': return westGateway ? 49 : 14;
			case 'Deals.aspx Hotels Promo': return westGateway ? 50 : 15;
			case 'Deals.aspx Packages Promo': return westGateway ? 52 : 18;
			case 'Deals.aspx Banner 1': return westGateway ? 53 : 11;
			case 'Deals.aspx Banner 2': return westGateway ? 54 : 12;
			case 'Deals.aspx Banner 3': return westGateway ? 55 : 13;
			case 'Deals.aspx Promo': 
				switch (gateway)
				{
					case 'Calgary' : return 107;
					case 'Edmonton' : return 108;
					case 'Halifax' : return 99;
					case 'Montreal' : return 100;
					case 'Ottawa' : return 101;
					case 'Regina' : return 112;
					case 'Toronto' : return 103;
					case 'Vancouver' : return 114;
					case 'Victoria' : return 115;
					case 'Winnipeg' : return 116;					
					default : return;
				}			
			case 'Flights.aspx Promo': 
				switch (gateway)
				{
					case 'Calgary' : return 127;
					case 'Edmonton' : return 128;
					case 'Halifax' : return 119;
					case 'Montreal' : return 120;
					case 'Ottawa' : return 121;
					case 'Regina' : return 132;
					case 'Toronto' : return 123;
					case 'Vancouver' : return 134;
					case 'Victoria' : return 135;
					case 'Winnipeg' : return 136;					
					default : return;
				}
			case 'Flights.aspx Footer': return westGateway ? 57 : 34;
			case 'HomePage.aspx Promo':
				switch (gateway)
				{
					case 'Calgary' : return 87;
					case 'Edmonton' : return 88;
					case 'Halifax' : return 79;
					case 'Montreal' : return 80;
					case 'Ottawa' : return 81;
					case 'Regina' : return 92;
					case 'Toronto' : return 83;
					case 'Vancouver' : return 94;
					case 'Victoria' : return 95;
					case 'Winnipeg' : return 96;					
					default : return;
				}
			case 'HomePage.aspx Floating Banner': return westGateway ? 39 : 39; //Same.
			case 'Hotels.aspx Promo': return westGateway ? 59 : 6;
			case 'Hotels.aspx Footer': return westGateway ? 58 : 35;
			case 'Packages.aspx Footer': return westGateway ? 60 : 38;
			case 'Packages.aspx Promo': 
				switch (gateway)
				{
					case 'Calgary' : return 147;
					case 'Edmonton' : return 148;
					case 'Halifax' : return 139;
					case 'Montreal' : return 140;
					case 'Ottawa' : return 141;
					case 'Regina' : return 152;
					case 'Toronto' : return 143;
					case 'Vancouver' : return 154;
					case 'Victoria' : return 155;
					case 'Winnipeg' : return 156;					
					default : return;
				}
			case 'ToolsFeatures.aspx Banner 1': return westGateway ? 65 : 20;
			case 'ToolsFeatures.aspx Banner 2': return westGateway ? 66 : 21;
			case 'ToolsFeatures.aspx Banner 3': return westGateway ? 67 : 22;			
			default: return;
		}
	}
}

function bannerShow(zoneName)
{
	bannerShowCommon(getSiteId(siteName), getZoneId(zoneName));
}

///////////////////////////////////////////////
// Show floating banner
var floatban_ie = document.all;
var floatban_dom = document.getElementById;
var floatban_ns4 = document.layers;
var floatban_bounceLimit = 32; //(divisible by 8)
var floatban_bounceStart = 0;
var floatban_crossobj, floatban_scroll_top, floatban_dropstart;

function floatingBannerInit(pageName, horzCenterOffset, numberOfShows)
{
	var cookieName = pageName + "FloatBanShown";
	var floatban_leftPos = Math.floor((floatban_ie ? document.body.clientWidth : window.innerWidth) * 0.5 +
	 	(floatban_ie ? 0 : -7) + horzCenterOffset);
	var shownNum = readCookie(cookieName);

	if (shownNum == null || parseInt(shownNum) < numberOfShows)
	{
		if (!floatban_dom && !floatban_ie && !floatban_ns4)
			return;
		floatban_crossobj = (floatban_dom) ? document.getElementById("floatingBanner").style : floatban_ie ? document.all.floatingBanner : document.floatingBanner;
		floatban_scroll_top = (floatban_ie) ? document.body.scrollTop : window.pageYOffset;
		floatban_crossobj.left = floatban_leftPos;
		floatban_crossobj.top = floatban_scroll_top - 250;
		floatban_crossobj.visibility = (floatban_dom || floatban_ie) ? "visible" : "show";
		floatban_dropstart = setInterval("floatingBannerFloatIt()", 50);
		var curDate = new Date();
		var expiryDate = new Date();
		expiryDate.setTime( curDate.getTime() + (1000 * 3600 * 24) );
		
		writeCookie(cookieName, parseInt((shownNum != null) ? shownNum : 0) + 1 , expiryDate);
	}
}

function floatingBannerFloatIt()
{
	floatban_scroll_top = (floatban_ie)? document.body.scrollTop : window.pageYOffset;

	if (parseInt(floatban_crossobj.top) < 150 + floatban_scroll_top)
		floatban_crossobj.top = parseInt(floatban_crossobj.top) + 40;
	else
	{
		clearInterval(floatban_dropstart);
		floatban_bounceStart = setInterval("floatingBannerBounceIn()", 50);
	}
}

function floatingBannerBounceIn()
{
	floatban_crossobj.top = parseInt(floatban_crossobj.top) - floatban_bounceLimit;
	
	if (floatban_bounceLimit < 0)
		floatban_bounceLimit += 8;

	floatban_bounceLimit = floatban_bounceLimit * -1;
	if (floatban_bounceLimit == 0)
	{
		clearInterval(floatban_bounceStart);
	}
}

function CloseFloatingBanner(name)
{
	floatban_crossobj.visibility = "hidden";
}

//function bannerShowFloating(bannerHtml)
//{
// Trick with document write doesn't work with BanManPro
//}

///////////////////////////////////////
// Functions to work with cookies
function writeCookie(name, value, expiryDate)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	var newItem;
	
	if (aCookie.length >= 20)
		return false;

	newItem = name + "=" + escape(value) + "; ";
	
	if (expiryDate == null)
	{
		//expires in 6 months
		var curDate = new Date();
		expiryDate = new Date();
		expiryDate.setTime( curDate.getTime() + (1000 * 3600 * 24 * 180) );
		newItem += "expires=" + expiryDate.toGMTString() + "; ";
		//newItem += "expires=Sat, 31 Dec 2050 23:59:59 GMT; ";
	}
	else
		newItem += "expires=" + expiryDate.toGMTString() + "; ";
		
	document.cookie = newItem + document.cookie;

	return true;
}

function readCookie(name)
{
	// From MSDN article: "cookie Property"
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");

	for (var i = 0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (name == aCrumb[0]) 
			return unescape(aCrumb[1]);
	}

	// a cookie with the requested name does not exist
	return null;
}


///////////////////////////////////////
function BookHotelDeal(dealID, productActionID)
{
	var params = 'dealID=' + dealID;
	if (productActionID != null)
		params += '&prevProductListActionId=' + productActionID;
		
	NavigateTo('h_ListProducts', null, params);
}

function BookHotelFlightDeal(dealID, productActionID)
{
	var params = 'dealID=' + dealID;
	if (productActionID != null)
		params += '&prevProductListActionId=' + productActionID;
		
	NavigateTo('fh_ListProducts', null, params);
}

function BookPackageDeal(dealID, productActionID)
{
	var params = 'dealID=' + dealID;
	if (productActionID != null)
		params += '&prevProductListActionId=' + productActionID;

//	commonForm.tm_productType.value = "Packages";
	NavigateTo('p_SearchResults', null, params);
}

function BookFlightDeal(dealID, productActionID)
{
	var params = 'dealID=' + dealID;
	if (productActionID != null)
		params += '&prevProductListActionId=' + productActionID;

//	commonForm.tm_productType.value = "Flights";
	NavigateTo('GatewaySearch', null, params);
}

//Function to show hide divs
//-----------------------------
function ToggleDivs(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)           //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)    //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.display = iState ? "inline" : "none";
    }
    else if(document.all)      // IE 4
    {
        document.all[szDivID].style.display = iState ? "inline" : "none";
    }
}
//-------------------------------//