function City(code, cities, nameUS, nameMX)
{
	this.code=code;
	this.cities=cities;
	this.nameUS=nameUS;
	this.nameMX=nameMX;
}

/*
function onWheelChairClick(chk)
{	
	display = chk.checked?"inline":"none";
	spn = document.getElementById("spanWheelChair");
	if(spn)
	{			
		spn.style.display = display;
	}
	
	ddWheelChair = findCtrl('ddWheelChairCount');
	clearSelect(ddWheelChair);
	totCount = 0;	
	
	if(chk.checked)
	{	
		ddAdt = findCtrl('ddAdt');
		ddChd = findCtrl('ddChd');
		
		adtCount = ddAdt.selectedIndex + 1;//starts with 1
		chdCount = ddChd.selectedIndex;
		totCount = adtCount+chdCount;
	}	
	
	var isExplorerFlag = isExplorer();
	for (var i = 0; i <= totCount; i++) 
	{	
		var oOption = document.createElement("OPTION");
		oOption.text = i;									
		oOption.value = i;
		
		if (isExplorerFlag)
			ddWheelChair.add(oOption);
		else
			ddWheelChair.add(oOption, null);
	}	
}
*/

function setDateFromFromCal(value)
{		
	ddMonthYear = findCtrl('ddMonthYearFrom');
	ddDay = findCtrl('ddDayFrom');
	
	setDate(ddMonthYear, ddDay, value);
	setDays(0);
}

function setDateToFromCal(value)
{	
	ddMonthYear = findCtrl('ddMonthYearTo');
	ddDay = findCtrl('ddDayTo');
	
	setDate(ddMonthYear, ddDay, value);
	setDays(1);
}

function setDate(ddMonthYear, ddDay, value)
{
	dts = value.split("-");
	yearMonth = dts[0] +"-" +dts[1];
	day = dts[2];
		
	for(i=0;i<ddMonthYear.length;i++)
	{	
		if(ddMonthYear[i].value==yearMonth)
		{
		ddMonthYear[i].selected=true;
		}
	}
			
	for(i=0;i<ddDay.length;i++)
	{
		if(ddDay[i].value==day || ('0' +ddDay[i].value==day))
		{
		ddDay[i].selected=true;
		}
	}
}

function PreSelectCities(fromCity, toCity,fromCityReturn,toCityReturn, lang)
{/*
	ddCityFrom = findCtrl('ddCityFrom');
	ddCityTo = findCtrl('ddCityTo');
	//ddCityFromReturn = findCtrl('ddCityFromReturn');
	//ddCityToReturn = findCtrl('ddCityToReturn');
	
	selectDDValue(ddCityFrom, fromCity);
	//selectDDValue(ddCityFromReturn, fromCityReturn);
	//swapDestination(ddCityFromReturn, 'ddCityToReturn', lang);
	swapDestination(ddCityFrom, 'ddCityTo', lang);
	
	setTimeout("selectDDValue(ddCityTo, '" +toCity +"')", 300);
	//setTimeout("selectDDValue(ddCityToReturn, '" +toCityReturn +"')", 300);
	*/
	/*alert('From:'+fromCity + ' To:' + toCity + '\nFrom:'+fromCityReturn+ ' To:'+toCityReturn);*/
	
}

function selectDDValue(dd, value)
{
	for(i=0;i<dd.length;i++)
	{		
		if(dd[i].value==value)
		{dd[i].selected=true;}
		else
		{dd[i].selected=false;}
	}
}
var from, to;
var curLang;
function CreateCities(lang, selectCity, fromOption, toOption)
{	
/*
	curLang = lang;	
	from = fromOption;
	to = toOption;
	ddCityFrom = findCtrl('ddCityFrom');		
		
	resambleCities();
		
	if(ddCityFrom)
	{		
		copyCitiesToSelect(cities, ddCityFrom, lang,selectCity);	
		swapDestination(ddCityFrom,'ddCityTo',lang);
	}
	*/
}

function resambleCities()
{

	cities.sort(sortCityComparer);
	tmpCities = new Array();
	
	//tmpCities[0] = findCityFromCode("CUL");	
	tmpCities[0] = findCityFromCode("MTY");				
	tmpCities[1] = new City("ZZZ", "", "---------------", "---------------");
	
	for(i = 0;i<cities.length;i++)
	{
		if(cities[i])
		{
			city = cities[i];
			if(city.code!="MTY")
			{
				tmpCities[tmpCities.length] = city;				
			}
		}
	}
	tmpCities[tmpCities.length] = new City("ZZZ", "", "", "");
	cities = tmpCities;

}


function isExplorer() {
	if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null)
		return true;
	else 
		return false;
}

function clearSelect(sel) {
	if (sel.options.lentgh < 1)
		return;
	for (var i=(sel.options.length-1); i>=0; i--) {
		sel.options[i] = null;
	}
}



function sortCityComparer(city1, city2)
{
	
	if(!city2 || !city1)
		return 0;



	city1Name = eval("city1.name" +curLang);
	city2Name = eval("city2.name" +curLang);


	if(!city1Name || !city2Name)
		return 0;


//	city1Name = city1Name.substring(0,1);
//	city2Name = city2Name.substring(0,1);

		
	if(city1Name<city2Name)
		return -1
		
	return 1;	
}

function copyCitiesToSelect(cities, target, lang, selectValue) 
{
/*	
	clearSelect(target);
	curLang = lang;
			
	var isExplorerFlag = isExplorer();
			
	var oOption = document.createElement("OPTION");
	if (target == findCtrl('ddCityTo')) {

		if (isExplorerFlag)
		 cities.sort(sortCityComparer);
		
		oOption.text = to;
		oOption.value = "TO";
	}
	else {
		oOption.text = from;
		oOption.value = "FROM";
	}
	if (isExplorerFlag)
		target.add(oOption);
	else
		target.add(oOption, null);
		
	
	for (var i = 0; i < cities.length-1; i++) {		
		if(cities[i])
		{	
			var oOption = document.createElement("OPTION");	
			
			oOption.text = eval("cities[i].name" +lang);					
				
			oOption.value = cities[i].code;
			
			if(selectValue && selectValue==oOption.value)
				oOption.selected=true;
			
			if (isExplorerFlag)
				target.add(oOption);
			else
				target.add(oOption, null);
		}
	}
	*/
}

function swapDestination(ddCityFrom, ddCityToName,lang)
{
/*
	ddCityTo = findCtrl(ddCityToName);
	cityFrom = ddCityFrom[ddCityFrom.selectedIndex].value;	
	
	if(!cityFrom || cityFrom=="")
		return;
		
	newDestinations = new Array();
	newDestCount = 0;
	
	for(i=0;i<cities.length-1;i++)
	{		
		if(cities[i])
		{
			if(cities[i].code!="" && cities[i].code==cityFrom)
			{
				destinations = cities[i].cities.split(",");
							
				for(iDest = 0;iDest<destinations.length;iDest++)
				{				
					city = findCityFromCode(destinations[iDest]);				
					if(city)
					{				
					newDestinations[newDestCount] = city;
					newDestCount++;
					}
				}											
			}
		}
	}		
		
	newDestinations[newDestinations.length] = null;
	copyCitiesToSelect(newDestinations, ddCityTo, lang);					
	*/
}
function swapReturnDestination(ddCityTo, lang)
{
	//ddCityFromReturn = findCtrl('ddCityFromReturn');
	//ddCityToReturn = findCtrl('ddCityToReturn');
	ddCityFrom = findCtrl('ddCityFrom');
	//cityFromReturn = ddCityTo[ddCityTo.selectedIndex].value;	
	//cityToReturn = ddCityFrom[ddCityFrom.selectedIndex].value;
	//selectDDValue(ddCityFromReturn,cityFromReturn);
	
	//swapDestination(ddCityFromReturn,'ddCityToReturn',lang);
	
	//selectDDValue(ddCityToReturn,cityToReturn);
	
			
}
function findCityFromCode(code)
{
	for(i=0;i<cities.length-1;i++)
	{
	if(cities[i] && cities[i].code==code)
		{return cities[i]};
	}
}


function setCriteriaType(isReturn)
{
    state = "hidden";
    if(isReturn)
	    state = "visible";
    	
    document.getElementById("divEndDateHeader").style.visibility=state;
    document.getElementById("trDateTo").style.visibility=state;

//document.getElementById("divCityFromReturn").style.visibility=state;
//document.getElementById("divCityToReturn").style.visibility=state;
//document.getElementById("divEndDate").style.visibility=state;
//document.getElementById("divEndDateControl").style.visibility=state;
}
