	var cadena	=	";";
	var nodosActivos = cadena.split(";");
	var maxNinhos		=	4;
	var maxHabitaciones	=	4;
	var	familias		=	false;
	var zona			=	"";
	
// ******** NEW PARAMETERS FOR BE V.2 *************
  function setParamsBookingEngineV2() {
		
		var en_aux = document.getElementById('en_mesano').value;
		en_aux = en_aux.split("-"); 
		document.getElementById('dia_en').value = document.getElementById('en_dia').value;
		document.getElementById('mes_en').value = en_aux[0];
		document.getElementById('anyo_en').value = en_aux[1];
		document.getElementById('dia').value = document.getElementById('en_dia').value;
		document.getElementById('mes').value = en_aux[0];
		document.getElementById('anio').value = en_aux[1];
		document.getElementById('date1').value = document.getElementById('en_dia').value + '/' + en_aux[0] + '/' + en_aux[1];

		var sa_aux = document.getElementById('sa_mesano').value;
		sa_aux = sa_aux.split("-"); 
		document.getElementById('dia_sa').value = document.getElementById('sa_dia').value;
		document.getElementById('mes_sa').value = sa_aux[0];
		document.getElementById('anyo_sa').value = sa_aux[1];
		document.getElementById('date2').value = document.getElementById('sa_dia').value + '/' + sa_aux[0] + '/' + sa_aux[1];
		
		document.getElementById('codHotel').value = document.getElementById('codigoHotel').value;
		document.getElementById('idPartner').value = 'MARCA_' + document.getElementById('codigoHotel').value;
	}
// ******** END NEW PARAMETERS FOR BE V.2 *************

	/*
	comprueba si se han de activar los combos de familias
	*/
	function activarComboFamilias(nodo, resetear){
		var numeroAdultosMaxCombo = 2;
		if (nodosActivos == ",") {
			// activarComboFamilias
			familias	=	true;
			document.getElementById('contComboPersonas1').style.display="block";
			numeroAdultosMaxCombo = 8;
		} else {
			if (buscarItem(nodosActivos, nodo)) {
				// activarComboFamilias
				familias	=	true;
				document.getElementById('contComboPersonas1').style.display="block";
				numeroAdultosMaxCombo = 8;
			} else {
				familias	=	false;
				document.getElementById('contComboPersonas1').style.display="none";
				numeroAdultosMaxCombo = 2;
			}
		}
		document.getElementById('adultsRoom1').innerHTML = '';
		for (var i = 1; i <= numeroAdultosMaxCombo; i++){
			var option = document.createElement('option');
			option.innerHTML = i;
			option.setAttribute('value', i);
			if (i == 2) option.setAttribute('selected', 'selected');
			document.getElementById('adultsRoom1').appendChild(option);
		}
		if (resetear) resetearCombos();
	}
	/*
	ponemos los combos en su estado inicial
	*/
	function resetearCombos(){
		document.getElementById('numHabitaciones').options[0].selected="selected";
		document.getElementById('txtHab1').style.display="none";
		for (var habitacion = 1; habitacion <= maxHabitaciones; habitacion++){
			document.getElementById('hab'+habitacion).style.display="none";
			document.getElementById('childrenRoom'+habitacion).options[0].selected="selected";
			document.getElementById('habChildren'+habitacion).style.display="none";
			for (var ninhos = 1; ninhos <= maxNinhos; ninhos++) {
				document.getElementById('child'+ninhos+'Room'+habitacion).options[0].selected="selected";
				document.getElementById('contEdadChild'+habitacion+''+ninhos).style.display="none";
			}
		}
	}
	/*
	busca dentro de una lista (lista) separada por ; el id valor
	*/
	function buscarItem(lista, valor){
		var ind, pos;
		for(ind=0; ind<lista.length; ind++) {
		    if (lista[ind] == valor) return true;
		}
		return false;
	}
	/*
	Expande los combos necesarios para que sea consistente la eleccion
	*/
	function expandir(){
		if (!familias) {
			document.getElementById('adultsRoom2').value=document.getElementById('adultsRoom1').value;
			document.getElementById('adultsRoom3').value=document.getElementById('adultsRoom1').value;
			document.getElementById('adultsRoom4').value=document.getElementById('adultsRoom1').value;
			document.getElementById('adultsRoom5').value=document.getElementById('adultsRoom1').value;
		}
		if (document.getElementById('numHabitaciones').value == "1" && familias){
			document.getElementById('txtHab1').style.display="none";
			document.getElementById('hab1').style.display="none";
			document.getElementById('hab2').style.display="none";
			document.getElementById('hab3').style.display="none";
			document.getElementById('hab4').style.display="none";
			display_children(2,0);
			display_children(3,0);
			display_children(4,0);
			display_children(5,0);
			document.getElementById('childrenRoom2').options[0].selected="selected";
			document.getElementById('childrenRoom3').options[0].selected="selected";
			document.getElementById('childrenRoom4').options[0].selected="selected";
			document.getElementById('childrenRoom5').options[0].selected="selected";
		}
		if (document.getElementById('numHabitaciones').value == "2" && familias){
			document.getElementById('txtHab1').style.display="block";
			document.getElementById('hab1').style.display="block";
			document.getElementById('hab2').style.display="none";
			document.getElementById('hab3').style.display="none";
			document.getElementById('hab4').style.display="none";
			display_children(3,0);
			display_children(4,0);
			display_children(5,0);
			document.getElementById('childrenRoom3').options[0].selected="selected";
			document.getElementById('childrenRoom4').options[0].selected="selected";
			document.getElementById('childrenRoom5').options[0].selected="selected";
		}
		if (document.getElementById('numHabitaciones').value == "3" && familias){
			document.getElementById('txtHab1').style.display="block";
			document.getElementById('hab1').style.display="block";
			document.getElementById('hab2').style.display="block";
			document.getElementById('hab3').style.display="none";
			document.getElementById('hab4').style.display="none";
			display_children(4,0);
			display_children(5,0);
			document.getElementById('childrenRoom4').options[0].selected="selected";
			document.getElementById('childrenRoom5').options[0].selected="selected";
		}
		if (document.getElementById('numHabitaciones').value == "4" && familias){
			document.getElementById('txtHab1').style.display="block";
			document.getElementById('hab1').style.display="block";
			document.getElementById('hab2').style.display="block";
			document.getElementById('hab3').style.display="block";
			document.getElementById('hab4').style.display="none";
			display_children(5,0);
			document.getElementById('childrenRoom5').options[0].selected="selected";
		}
		if (document.getElementById('numHabitaciones').value == "5" && familias){
			document.getElementById('txtHab1').style.display="block";
			document.getElementById('hab1').style.display="block";
			document.getElementById('hab2').style.display="block";
			document.getElementById('hab3').style.display="block";
			document.getElementById('hab4').style.display="block";
		}
	}
	
	/*
	Visualiza la cantidad de combos de niños seleccionados.
	*/
	function display_children(habitacion, ninos){
		if (ninos == "0" && familias){
			document.getElementById('child1Room'+habitacion).options[0].selected="selected";
			document.getElementById('child2Room'+habitacion).options[0].selected="selected";
			document.getElementById('child3Room'+habitacion).options[0].selected="selected";
			document.getElementById('child4Room'+habitacion).options[0].selected="selected";
			document.getElementById('habChildren'+habitacion).style.display="none";
			document.getElementById('contEdadChild'+habitacion+'1').style.display="none";
			document.getElementById('contEdadChild'+habitacion+'2').style.display="none";
			document.getElementById('contEdadChild'+habitacion+'3').style.display="none";
			document.getElementById('contEdadChild'+habitacion+'4').style.display="none";
		} else if (ninos == "1" && familias){
			document.getElementById('child2Room'+habitacion).options[0].selected="selected";
			document.getElementById('child3Room'+habitacion).options[0].selected="selected";
			document.getElementById('child4Room'+habitacion).options[0].selected="selected";
			document.getElementById('habChildren'+habitacion).style.display="block";
			document.getElementById('contEdadChild'+habitacion+'1').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'2').style.display="none";
			document.getElementById('contEdadChild'+habitacion+'3').style.display="none";
			document.getElementById('contEdadChild'+habitacion+'4').style.display="none";
		} else if (ninos == "2" && familias){
			document.getElementById('child3Room'+habitacion).options[0].selected="selected";
			document.getElementById('child4Room'+habitacion).options[0].selected="selected";
			document.getElementById('habChildren'+habitacion).style.display="block";
			document.getElementById('contEdadChild'+habitacion+'1').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'2').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'3').style.display="none";
			document.getElementById('contEdadChild'+habitacion+'4').style.display="none";
		} else if (ninos == "3" && familias){
			document.getElementById('child4Room'+habitacion).options[0].selected="selected";
			document.getElementById('habChildren'+habitacion).style.display="block";
			document.getElementById('contEdadChild'+habitacion+'1').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'2').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'3').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'4').style.display="none";
		} else if (ninos == "4" && familias){
			document.getElementById('habChildren'+habitacion).style.display="block";
			document.getElementById('contEdadChild'+habitacion+'1').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'2').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'3').style.display="block";
			document.getElementById('contEdadChild'+habitacion+'4').style.display="block";
		}
	}
	/*
	Valida que se rellenen los combos correctamente
	*/
	function validarNinosSeleccionados() {
		var iHabitaciones = Number(document.getElementById('numHabitaciones').selectedIndex);
		var nHabitaciones = Number(document.getElementById('numHabitaciones').options[iHabitaciones].value)
		var i = 1;
		// Recorremos las habitaciones seleccionadas
		// Desabilitamos los niños restantes
		for (i; i<=nHabitaciones; i++) {
			var iNinos = Number(document.getElementById('childrenRoom'+i).selectedIndex);
			var nNinos = Number(document.getElementById('childrenRoom'+i).options[iNinos].value);
			var j = 1;
			// Recorremos los combos de niños seleccionados y comprobamos que tengan
			// un valor assignado
			for (j; j<=nNinos; j++) {
				var iValor = Number(document.getElementById('child'+j+'Room'+i).selectedIndex);
				if (iValor == 0) {
					return false;
				}
			}
		}
		return true;
	}
	/*
	Desabilita los combos de las habitaciones sobrantes y de los niños tambien,
	para que no se envien con los formularios.
	*/
	function limpiarHabitacionesYNinosSobrantes() {
		var iHabitaciones = Number(document.getElementById('numHabitaciones').selectedIndex);
		var nHabitaciones = Number(document.getElementById('numHabitaciones').options[iHabitaciones].value);
		var tHabitaciones = Number(document.getElementById('numHabitaciones').length);
		var i = 1;
		// Recorremos las habitaciones seleccionadas
		// Desabilitamos los niños restantes
		for (i; i<=nHabitaciones; i++) {
			var iNinos = Number(document.getElementById('childrenRoom'+i).selectedIndex);
			var nNinos = Number(document.getElementById('childrenRoom'+i).options[iNinos].value);
			var tNinos = Number(document.getElementById('childrenRoom'+i).length);
			var j = nNinos+1;
			// Recorremos los combos de niños no seleccionados y los desabilitamos
			for (j; j<tNinos; j++) {
				document.getElementById('child'+j+'Room'+i).disabled=true;
			}
		}
		// Recorremos las habitaciones no seleccionadas
		// Desabilitamos las habitaciones restantes
		for (i; i<=tHabitaciones; i++) {
			document.getElementById('adultsRoom'+i).disabled=true;
			document.getElementById('childrenRoom'+i).disabled=true;
			document.getElementById('child1Room'+i).disabled=true;
			document.getElementById('child2Room'+i).disabled=true;
			document.getElementById('child3Room'+i).disabled=true;
			document.getElementById('child4Room'+i).disabled=true;
		}
	}

	function validarFormulario() {
		if (document.searchForm.codigoHotel.value=="") {
				var _sErrTxt=err_0;
				_alert(_sErrTxt);
				return;
		}
		if (validarNinosSeleccionados()) {
			limpiarHabitacionesYNinosSobrantes();
		} else {
			alert(err_1);
			return;
		}
		var diaentrada		= document.searchForm.en_dia.value;
		var mesanoentrada	= document.searchForm.en_mesano.value;
		var txtEntrada		= diaentrada+"-"+mesanoentrada;
		var spl_entrada		= txtEntrada.split("-");
		var fechaEntrada 	= new Date(new Number(spl_entrada[2]),new Number(spl_entrada[1])-1,new Number(spl_entrada[0]),0,0,0);
		var sdia 		= fechaEntrada.getDate();
		var smes 		= fechaEntrada.getMonth()+1;
		var sanyo 		= fechaEntrada.getFullYear();
		if(sdia<10) sdia= "0"+sdia;
		if(smes<10) smes="0"+smes;
		document.searchForm.dia.value  = sdia;
		document.searchForm.mes.value  = smes;
		document.searchForm.anio.value = fechaEntrada.getFullYear();

		_aux = document.getElementById('en_mesano').value;
		_aux = _aux.split("-"); 

		document.getElementById('booking_dia').value = document.getElementById('en_dia').value;
		document.getElementById('booking_mes').value = _aux[0];
		document.getElementById('booking_anyo').value = _aux[1];
		document.getElementById('booking_noches').value = document.getElementById('noches').value;
		document.getElementById('booking_codHotel').value = document.getElementById('codigoHotel').value;
				
		setParamsBookingEngineV2();
		
		validarFechasFormulario_NoSubmit();
	}
	
	function initPage() {
     	// Buscador Familias

		miFecha = new Date() ;
		dd = miFecha.getDate();
		mm = miFecha.getMonth();
		aa = miFecha.getFullYear();

		Calendar_initialize('searchForm','en_dia','en_mesano','sa_dia','sa_mesano');
		loadDate(DateAdd(dd,mm,aa,0,0,0),document.searchForm.en_dia,document.searchForm.en_mesano);
		loadDate(DateAdd(dd,mm,aa,1,0,0),document.searchForm.sa_dia,document.searchForm.sa_mesano);


		activarComboFamilias("", true);
		Calendar_initialize('searchForm','en_dia','en_mesano','sa_dia','sa_mesano');
		if (cargarFechasSesion()) {
			actualizar_noches('capanoches', 'searchForm', 'en_dia', 'en_mesano', 'sa_dia', 'sa_mesano', 'noches');
			printLayerWeekDay('entrada','searchForm','en_mesano', 'en_dia');
			printLayerWeekDay('salida','searchForm','sa_mesano', 'sa_dia');
		}
		selectDato(document.searchForm.personas,"");
		updateCombo1(document.searchForm.areaone);

		updateCombo2(document.searchForm.areaone,document.searchForm.codigoHotel);		

		var nino;
		selectDato(document.searchForm.habitaciones,'');
		
        expandir();
	}
	
	function parametrosGA(){
		document.searchForm.qGa_termino.value		=	document.searchForm.areaone.value+" "+document.searchForm.codigoHotel.value;
		if (document.searchForm.sa_mesano.value	!= "") {
			document.searchForm.qGa_categoria.value	=	document.searchForm.sa_mesano.value;
		} else {
			document.searchForm.qGa_categoria.value 	=	"no_fecha";
		}
	}

