/* BUSQUEDAS en  SNNIPETs
 * - fucncion para crear y enviar la url de busqueda y reserva
 * - la URL inclute el parametro rate e idpromo. Ambos opcionales
 *
 * REQUISITOS:
 *	- En el formulario pasado a la funcion ("f") los combos deben tener estos nombres:
 *		pais	--> "country"
 *		ciudad	--> "city"
 *		hotel	--> "hotel"
 *	- el formulario debe llamarse "reservaForm"
 *
 * UTILIZADO en: theorganizers
 * -------------------------------OLD VERSION------------------------
 */
 
function sendReservationForm(f) {
	if (f.country.options[f.country.selectedIndex].value == 0) {
		alert(countryErrorMessage);
		f.country.focus();
		return false;
	}
	if (f.city.options[f.city.selectedIndex].value == 0) {
		alert(cityErrorMessage);
		f.city.focus();
		return false;
	}
	if (f.hotel.options[f.hotel.selectedIndex].value == 0) {
		alert(hotelErrorMessage);
		f.hotel.focus();
		return false;
	}
	if (f.fent.value ==  '' || f.fsal.value == '') {
		alert(datesErrorMessage);
		return false;
	}

	var fentArr = document.reservaForm.fent.value.split("/");
	var fsalArr = document.reservaForm.fsal.value.split("/");
	if (fentArr.length != 3 || fsalArr.length != 3) {
		alert(datesErrorMessage);
		return false;
	}

	var domain = (window.location.host.indexOf('cppreas') != -1) ? 'cppreas.nh-hotels.com': 'www.nh-hotels.com';
	var url = 'http://' + domain + '/rol/Paso2WebExt.do?ln=' + language;
	url = url + "&idh=" + f.hotel.options[f.hotel.selectedIndex].value;
	url = url + "&idc=" + f.city.options[f.city.selectedIndex].value;
	url = url + "&idp=" + f.country.options[f.country.selectedIndex].value;
	url = url + "&nhab=" + document.reservaForm.nhab.value;
	url = url + "&nper=" + document.reservaForm.nper.value;
	url = url + "&nchild=" + document.reservaForm.nchild.value;
	url = url + "&fent=" + fentArr[0] + fentArr[1] + fentArr[2];
	url = url + "&fsal=" + fsalArr[0] + fsalArr[1] + fsalArr[2];
	if (rate != 0) url = url + "&rate=" + rate;
	if (idpromo != 0) url = url + "&idpromo=" + idpromo;
	parent.location.href=url;
}