var srch_list_wait='<img src="shop_image/ajxloading.gif" border="0" hspace="4" vspace="0" align="absmiddle"> Loading...';
var curorderid=0;
var curnotetype='';
var cartnotetype='';
function DoSaveNotes(orderid, snotetype) {
	curorderid=orderid;
	curnotetype=snotetype;

	x_DoSaveNotes(orderid, snotetype, document.getElementById('txt_'+snotetype+'_notes'+orderid).value, AfterDoSaveNotes);
}
function AfterDoSaveNotes(s) {
	if(s=='1') {
		document.getElementById(curnotetype+'save'+curorderid).style.display='';
		document.getElementById(curnotetype+'save'+curorderid).innerHTML='Notes were successfully saved';
	}
}
function DoSaveCartNotes(stype) {
	cartnotetype=stype;
	x_DoSaveCartNotes(stype, document.getElementById(stype+'_notes').value, AfterSaveCartNotes);
}
function AfterSaveCartNotes(s) {
	if(s=='1') {
		alert('Notes were successfully saved');
	}
}
function AjxLoadRegions() {
	var srch_country=document.getElementById("srch_country").value;
	var srch_region=document.getElementById("srch_region").value;
	document.getElementById('dvsrch_region').innerHTML=srch_list_wait;
	x_AjxGetRegionsList(srch_region, srch_country, AfterAjxGetRegionsList);
}
function AfterAjxGetRegionsList(s) {
	document.getElementById('dvsrch_region').innerHTML='<select class="input" name="srch_region" id="srch_region" style="width:147px" onChange="AjxLoadCities()">'+s+'</select>';
	AjxLoadCities();
}
function AjxLoadCities() {
	var srch_city=document.getElementById("srch_city").value;
	var srch_region=document.getElementById("srch_region").value;
	document.getElementById('dvsrch_city').innerHTML=srch_list_wait;
	x_AjxGetCitiesList(srch_city, srch_region, AfterAjxGetCitiesList);
}
function AfterAjxGetCitiesList(s) {
	document.getElementById('dvsrch_city').innerHTML='<select class="input" name="srch_city" id="srch_city" style="width:147px">'+s+'</select>';
}
function AjxLoadTourTypes() {
	var srch_tourtype=document.getElementById("srch_tourtype").value;
	var srch_tourcat=document.getElementById("srch_tourcat").value;
	document.getElementById('dvsrch_tourtype').innerHTML=srch_list_wait;
	x_AjxGetTourTypesList(srch_tourtype, srch_tourcat, AfterAjxLoadTourTypes);
}
function AfterAjxLoadTourTypes(s) {
	document.getElementById('dvsrch_tourtype').innerHTML='<select class="input" name="srch_tourtype" id="srch_tourtype" style="width:147px">'+s+'</select>';
}
function DisplaySearchForm(srchtype) {
	//*** var i=0;
	//*** 2008-10-21: transit instead of rental
	//*** var aalldivs=new Array('hotel', 'tour', 'transit');
	//*** var old_srchtype='';
	//*** for(i=0;i<aalldivs.length;i++) {
	//*** 	if(document.getElementById('dvsrch_'+aalldivs[i]).style.display!='none') {
	//*** 		old_srchtype=aalldivs[i];
	//*** 		break;
	//*** 	}
	//*** }
	//*** if(old_srchtype!='') {
	//*** 	new Effect.Fade('dvsrch_'+old_srchtype, {afterFinish:function() {new Effect.Appear('dvsrch_'+srchtype);}});
	//*** } else {
	//*** 	new Effect.Appear('dvsrch_'+srchtype);
	//*** }
	var i=0;
	var aalldivs=new Array('hotel', 'tour', 'transit');
	document.getElementById('dvsrch_' + srchtype).style.display = "block" ;
	for(i=0;i<aalldivs.length;i++) {
		if (srchtype!=aalldivs[i])
			document.getElementById('dvsrch_' + aalldivs[i]).style.display = "none" ;
	}
}
function AjxLoadHotelCities() {
	var srch_city=document.getElementById("srch_hotel_city").value;
	var srch_region=document.getElementById("srch_hotel_region").value;
	document.getElementById('dvsrch_hotel_city').innerHTML=srch_list_wait;
	x_AjxGetHotelsCitiesList(srch_city, srch_region, AfterAjxLoadHotelCities);
}
function AfterAjxLoadHotelCities(s) {
	document.getElementById('dvsrch_hotel_city').innerHTML='<select class="input" name="srch_hotel_city" id="srch_hotel_city" style="width:147px">'+s+'</select>';
}

// Rentals
var rental_regionid, rental_countryid, rental_cityid;
function AjxLoadRentalRegions(countryid, regionid, cityid) {

	rental_cityid=cityid;
	rental_regionid=regionid;
	rental_countryid=countryid;

	var srch_country=document.getElementById(countryid).value;
	var srch_region=document.getElementById(regionid).value;

	document.getElementById('dv'+regionid).innerHTML=srch_list_wait;

	x_AjxGetRentalRegionsList(srch_region, srch_country, AfterAjxLoadRentalRegions);
}
function AfterAjxLoadRentalRegions(s) {
	document.getElementById('dv'+rental_regionid).innerHTML='<select class="input" name="'+rental_regionid+'" id="'+rental_regionid+'" style="width:147px" onChange="AjxLoadRentalCities(\''+rental_countryid+'\', \''+rental_regionid+'\', \''+rental_cityid+'\')">'+s+'</select>';
	AjxLoadRentalCities(rental_countryid, rental_regionid, rental_cityid);
}
function AjxLoadRentalCities(countryid, regionid, cityid) {

	rental_cityid=cityid;
	rental_regionid=regionid;
	rental_countryid=countryid;

	var srch_region=document.getElementById(regionid).value;
	var srch_city=document.getElementById(cityid).value;

	document.getElementById('dv'+cityid).innerHTML=srch_list_wait;

	x_AjxGetRentalCitiesList(srch_city, srch_region, AfterAjxGetRentalCitiesList);
}
function AfterAjxGetRentalCitiesList(s) {
	document.getElementById('dv'+rental_cityid).innerHTML='<select class="input" name="'+rental_cityid+'" id="'+rental_cityid+'" style="width:147px">'+s+'</select>';
}

//*** 2008-12-26 (begin new code)
function AjxGetHotelRegions() {
	var dest_id=document.frmhotelssearch.location.value;
	var curval=document.getElementById("srch_hotel_region").value;
	document.getElementById('dvsrch_hotel_region').innerHTML=srch_list_wait;
	x_AjxGetHotelsRegionsList(curval, dest_id, AfterAjxGetHotelRegions);

}
