/**
* Function to string search hotels + all geo locations
* Used by the data source for the autocomplete
*/
var searchNames = function(query){
	query=decodeURIComponent(query);
	query_cleaned = query.replace(/%20/g, ' ');
	var anywhereRE = new RegExp(query_cleaned, "i");
	var beginningRE = new RegExp("( |^)"+query_cleaned, "i");
	var results = [];
	//Search World Areas:
	for (areaId in areaNames)
		if(areaNames[areaId].match(beginningRE))
			results.push([areaNames[areaId], areaId, trForJs.WORLD_AREA]);
	//Search countries:
	for (countryId in countryNames)
		if(countryNames[countryId].match(beginningRE))
			results.push([countryNames[countryId], countryId, trForJs.COUNTRY]);
	//Search regions (states and UK subdivisions)
	for (regionId in regionNames)
		if(regionNames[regionId].match(beginningRE))
			results.push([regionNames[regionId], regionId, trForJs.REGION]);
	//Search cities:
	for (cityId in cityNames)
		if(cityNames[cityId].match(beginningRE))
			results.push([cityNames[cityId], cityId, trForJs.CITY]);
	//Search hotels:
	for (hotelId in hotelsDict)
		if(hotelsDict[hotelId].match(beginningRE))
			results.push([hotelsDict[hotelId], hotelId, trForJs.HOTEL]);
	return results;
	}
var hotelDataSource = new YAHOO.widget.DS_JSFunction(searchNames);
hotelDataSource.queryMatchContains = true;
hotelDataSource.queryMatchCase = false;
//Function to call on form submit to verify that it is not empty
function verifySubmit(){
	if($('hotelsSelected').value == "" && $('citiesSelected').value == "" && $('regionsSelected').value == "" && $('countriesSelected').value == "" && $('areasSelected').value == "") return false;
	return true;
	}
/**
* Function to toggle the left column preview, called by changing
*/
function toggleThumbnail(layout){
	layoutReadableNames = {'full':trForJs.FULL_EBROCHURE,'quickref':trForJs.QUICK_REFERENCE,'summary':trForJs.DIRECTORY_LISTING};
	$('preview').style.display = 'block';
	$('previewLayoutType').innerHTML = layoutReadableNames[layout];
	var l = document.getElementsByName('layout');
	for(var i = 0; i < 3; i++){
		var image = $(l[i].value + '_thumbnail');
		if(l[i].value == layout)
			image.style.display = 'block';
		else
			image.style.display = 'none';
		}
	}
function closeThumbnail(){
	$('preview').style.display='none'
	}
