goKeyword=0;
goAdvanced=0;
function goSearch(ga) {

	goAdvanced=ga;

	if (document.form001.iG2.selectedIndex==-1 && goKeyword==0) { alert("Please select a City / Region or enter Keywords before proceeding."); return false }

	if (document.form001.iG2.selectedIndex!=-1) {

		text1=document.form001.iG1.options[document.form001.iG1.selectedIndex].text.toLowerCase();
		text2=document.form001.iG2.options[document.form001.iG2.selectedIndex].text.toLowerCase();

		text1 = text1.replace(/ /g,"-");
		text2 = text2.replace(/ /g,"-");

		text1 = text1.replace(/'/g,"");
		text1 = text1.replace(/"/g,"");
		text1 = text1.replace(/&/g,"");
		text2 = text2.replace(/'/g,"");
		text2 = text2.replace(/"/g,"");
		text2 = text2.replace(/&/g,"");

		locs="";
		for (i=0; i!=document.form001.iG2.options.length; i++) {
			if (document.form001.iG2.options[i].selected) {
				locs += document.form001.iG2.options[i].value+"'";
			}
		}
		locs = locs.substr(0,locs.length-1);
		
		indexes=document.form001.iG1.options[document.form001.iG1.selectedIndex].value + "-" + locs + "-" + document.form001.iG3.options[document.form001.iG3.selectedIndex].value;

	}
	else {
		text1="for";
		text2="standbyrates";
		indexes="";
	}

	we=0;
	if (document.form001.days[1].checked) {
		we=1;
	}

//	text1=document.form001.iG1.options[document.form001.iG1.selectedndex].value.toLowerCase();

	if (goKeyword==0) {
		URL = "search/" + text1 + "/" + text2 + "/hotels/";
	}
	else {
		URL = "search/keywords/" + escape(document.form001.keywords.value.toLowerCase()) + "/hotels/";
	}

//alert(URL);
	if (window.location.href.indexOf('localhost')!=-1) {
		indexes = indexes.replace(/\//g,"-");
		URL = "index.cgi?search=";
	}
//alert(URL);

//	document.cookie="indexes=" + indexes + "; path=/";
	document.cookie="we=" + we + "; path=/";
	document.cookie="da=" + daysAhead + "; path=/";

	if (goAdvanced==1) {
		facilitiesS="";
		counter=0;
		for (i=0; i!=document.form001.elements.length; i++) {
			if (document.form001.elements[i].name.indexOf("f_")!=-1) {
				if (document.form001.elements[i].checked) {
					facilitiesS+=counter+"-";
				}
				counter++;
			}
		}

		attractionsS="";
		counter=0;
		for (i=0; i!=document.form001.elements.length; i++) {
			if (document.form001.elements[i].name.indexOf("a_")!=-1) {
				if (document.form001.elements[i].checked) {
					attractionsS+=counter+"-";
				}
				counter++;
			}
		}

		document.cookie="ga=" + document.form001.memberCategory.options[document.form001.memberCategory.selectedIndex].value + "^" + document.form001.memberStarRating.options[document.form001.memberStarRating.selectedIndex].value + "^" + document.form001.maxRate.value + "^" + facilitiesS + "^" + attractionsS + "; path=/";
	}

	if (goKeyword==1) {
		document.cookie="searchKeywords=" + document.form001.keywords.value.toLowerCase() + "; path=/";
	}
	else {
		document.cookie="searchKeywords=; path=/";
	}

URL+=indexes;

//alert(URL);return false;
	window.location.href=URL;
}

if (command!="search") {
	setTimeout("document.form001.keywords.value='eg. name of hotel or location'",250);
}

document.cookie="indexes=; path=/";
document.cookie="we=; path=/";
document.cookie="da=; path=/";
document.cookie="ga=; path=/";

//document.form001.onFormSubmit="yeh()";

//function yeh() {
//	alert(1);
//}

function changeLocations(x,start) {

	setLocation=x;

	if (document.form001.iG1.options.length!=0) {
		var changeCountry=document.form001.iG1.options[document.form001.iG1.selectedIndex].value;
		if (document.form001.iG2.options.length!=0 && setLocation>0) {
			var changeCity=document.form001.iG2.options[document.form001.iG2.selectedIndex].value;
		}
	}

	url2 = "change_locations.cgi?country="+changeCountry+"&city="+changeCity + "&start="+start+"&popup=1";
//alert(url2);
	var now = new Date(), txt, url = url2;

	if( url ) {
		xmlhttp.open( 'GET', url, true );
		xmlhttp.onreadystatechange = function() {


			for (var i=1; i!=4; i++) {
				if (setLocation==1 && i==2) { }
				else if (setLocation==1 && i==1) { }
				else {
					obj=eval("document.form001.iG"+i);
					obj.options.length=0;
					obj.options[0]=new Option();
					obj.options[0].value="X";
					obj.options[0].text="Loading...";
					obj.disabled=true;
				}
			}

			if ( xmlhttp.readyState===4 ) {
				txt = xmlhttp.responseText;
//alert(txt);
				all = new Array();
				all = txt.split("|");

				if (setLocation==0) {
					countries = new Array();
					countries = all[0].split("{");
					countries.splice(countries.length-1,1);
					for (var i=0; i!=countries.length; i++) {
						tmp=new Array();
						tmp=countries[i].split("}");
						document.form001.iG1[i]=new Option();
						document.form001.iG1[i].value=tmp[1];
						document.form001.iG1[i].text=tmp[0];
						if (tmp[2]=="1") { document.form001.iG1[i].selected="true" }
					}

					cities = new Array();
					cities = all[1].split("{");
					cities.splice(0,1);
					for (var i=0; i!=cities.length; i++) {
						if (cities[i] == "Z") {
							document.form001.iG2[i]=new Option();
							document.form001.iG2[i].value="X";
							document.form001.iG2[i].text="-------------------------";
						}
						else {
							tmp=new Array();
							tmp=cities[i].split("}");
							document.form001.iG2[i]=new Option();
							document.form001.iG2[i].value=tmp[1];
							document.form001.iG2[i].text=tmp[0];
							if (tmp[2]=="1") { document.form001.iG2[i].selected="true" }
						}
					}
					if (setLocation==0) { document.form001.iG2.selectedIndex=0 }
				}

				document.form001.iG3[0]=new Option();
				document.form001.iG3[0].value="X";
				document.form001.iG3[0].text="All Locations";
				locations = new Array();
				locations = all[2].split("{");
				locations.splice(0,1);
				for (var i=0; i!=locations.length; i++) {
					if (locations[i]!="|") {
						tmp=new Array();
						tmp=locations[i].split("}");
						document.form001.iG3[i+1]=new Option();
						document.form001.iG3[i+1].value=tmp[1];
						document.form001.iG3[i+1].text=tmp[0];
	//					if (tmp[2]=="1") { document.form001.iG3[i].selected="true" }
					}
				}

				for (var i=1; i!=4; i++) {
					obj=eval("document.form001.iG"+i);
					obj.disabled=false;
				}


			} 
		}
		xmlhttp.send( null );
	}
}






function changeLocationsSearch(c,t,l) {

	if (window.location.href.indexOf("localhost")!=-1) {
		url2 = "change_locations.cgi?country="+c+"&city="+t + "&location="+l+"&popup=1";
	}
	else {
		url2 = "/change_locations.cgi?country="+c+"&city="+t + "&location="+l+"&popup=1";
	}

	ccc=c;
	ttt=t;
	lll=l;

	var now = new Date(), txt, url = url2;

	if( url ) {
		xmlhttp.open( 'GET', url, true );
		xmlhttp.onreadystatechange = function() {


			for (var i=1; i!=4; i++) {
				obj=eval("document.form001.iG"+i);
				obj.options.length=0;
				obj.options[0]=new Option();
				obj.options[0].value="X";
				obj.options[0].text="Loading...";
				obj.disabled=true;
			}

			if ( xmlhttp.readyState===4 ) {
				txt = xmlhttp.responseText;
//alert(txt);
//document.form001.yeh.value=txt;
				all = new Array();
				all = txt.split("|");

				countries = new Array();
				countries = all[0].split("{");
				countries.splice(countries.length-1,1);
				for (var i=0; i!=countries.length; i++) {
					tmp=new Array();
					tmp=countries[i].split("}");
					document.form001.iG1[i]=new Option();
					document.form001.iG1[i].value=tmp[1];
					document.form001.iG1[i].text=tmp[0];
					if (tmp[2]=="1") { document.form001.iG1[i].selected=true }
				}

				cities = new Array();
				cities = all[1].split("{");
				cities.splice(0,1);
				for (var i=0; i!=cities.length; i++) {
					if (cities[i] == "Z") {
						document.form001.iG2[i]=new Option();
						document.form001.iG2[i].value="X";
						document.form001.iG2[i].text="-------------------------";
					}
					else {
						tmp=new Array();
						tmp=cities[i].split("}");
						document.form001.iG2[i]=new Option();
						document.form001.iG2[i].value=tmp[1];
						document.form001.iG2[i].text=tmp[0];
						if (tmp[2]=="1") { document.form001.iG2[i].selected=true }
					}
				}
//					if (setLocation==0) { document.form001.iG2.selectedIndex=0 }

				document.form001.iG3[0]=new Option();
				document.form001.iG3[0].value="X";
				document.form001.iG3[0].text="All Locations";
				locations = new Array();
				locations = all[2].split("{");
				locations.splice(0,1);
				for (var i=0; i!=locations.length; i++) {
					if (locations[i]!="|") {
						tmp=new Array();
						tmp=locations[i].split("}");
						document.form001.iG3[i+1]=new Option();
						document.form001.iG3[i+1].value=tmp[1];
						document.form001.iG3[i+1].text=tmp[0];
						if (tmp[2]=="1") { document.form001.iG3[i+1].selected=true }
					}
				}

				for (var i=1; i!=4; i++) {
					obj=eval("document.form001.iG"+i);
					obj.disabled=false;
				}

			} 
		}
		xmlhttp.send( null );
	}
}

function showSearchAgainOptions(mode) {
	if (mode==1) {
		document.getElementById('facilities').style.display='';
		document.getElementById('attractions').style.display='';
		document.getElementById('moreOptions').style.display='none';
		document.getElementById('lessOptions').style.display='';
	}
	else {
		document.getElementById('facilities').style.display='none';
		document.getElementById('attractions').style.display='none';
		document.getElementById('moreOptions').style.display='';
		document.getElementById('lessOptions').style.display='none';
	}
}