
	// Funcion para el control de las fechas
    function catcalc() {
          llegada = new Date(form.fecha0.value.split("/")[2], form.fecha0.value.split("/")[1] - 1, form.fecha0.value.split("/")[0]);
          salida = new Date(form.fecha1.value.split("/")[2],form.fecha1.value.split("/")[1] - 1, form.fecha1.value.split("/")[0]);
          if (salida.getTime() <= llegada.getTime())
                {
                    dia_salida = llegada.getDate()+ 2;
                    mes_salida = llegada.getMonth();
                    year_salida = llegada.getFullYear();
                    dia_max = 30;
                    // Controlamos si el dia se sale del mes
                    switch (mes_salida){
                        case 0: dia_max = 31; break;
                        case 1: dia_max = 28; break;
                        case 2: dia_max = 31; break;
                        case 3: dia_max = 30; break;
                        case 4: dia_max = 31; break;
                        case 5: dia_max = 30; break;
                        case 6: dia_max = 31; break;
                        case 7: dia_max = 31; break;
                        case 8: dia_max = 30; break;
                        case 9: dia_max = 31; break;
                        case 10: dia_max = 30; break;
                        case 11: dia_max = 31; break;
                     }
          if (dia_salida > dia_max) {
             dia_salida = 1;
             mes_salida ++;
             }
          if (mes_salida == 12) {
             mes_salida = 0;
             year_salida++;
              }
          mes_salida++;
          if (dia_salida < 10)  dia_salida = '0' + dia_salida;

          if (mes_salida<10)  mes_salida = '0' + mes_salida ;

          form.fecha1.value = dia_salida + '/' + mes_salida + '/' + year_salida;
          }
          llegadaFin = new Date(form.fecha0.value.split("/")[2], form.fecha0.value.split("/")[1] - 1, form.fecha0.value.split("/")[0]);
          salidaFin = new Date(form.fecha1.value.split("/")[2] ,form.fecha1.value.split("/")[1] - 1 , form.fecha1.value.split("/")[0]);

   }

		function changecontent(url, contenedor) {
			var pagina_requerida = false
			if (window.XMLHttpRequest) {
				pagina_requerida = new XMLHttpRequest();
			}
			else if (window.ActiveXObject) { 
				try {
					pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP");
				} 
				catch (e){ 
					try{
						pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch (e){
					}
				}
			} else {
				return false
			}
				
			pagina_requerida.onreadystatechange=function(){ 
				document.getElementById(contenedor).innerHTML='<img src="img/loader.gif" />';
				pintapagina(pagina_requerida, contenedor);
			}
		
			pagina_requerida.open('GET', url, true) ;
			pagina_requerida.send(null);
		}
		
		function pintapagina(pagina_requerida,contenedor){
			if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1)) {
				document.getElementById(contenedor).innerHTML=pagina_requerida.responseText;
				
				//if(document.getElementById("ses_value").innerHTML.replace(/\s+$/g,'')*1 > 0) 
				//document.getElementById("consulta_resultado").style.display="none";
			}
		}
		

	function display_array() {
		//alert(document.getElementById("return_array").style.display);
		if( document.getElementById("return_array").style.display == "none" || document.getElementById("return_array").style.display == "" ) {
			document.getElementById("return_array").style.display = "block";
			document.getElementById("display_array").innerHTML = "-";
		} else {
			document.getElementById("return_array").style.display = "none";
			document.getElementById("display_array").innerHTML = "+";
		}
	}


	function displayEdades(hotel,nrhab,nr_ninos) {
			//alert(nrhab+'-'+nr_ninos);
			if(nr_ninos>0) {
				document.getElementById('hot'+hotel+'hab'+nrhab+'div_edades_ninos_label').style.display = "block";
				document.getElementById('hot'+hotel+'hab'+nrhab+'div_edades_ninos').style.display = "block"; 
			} else {
				document.getElementById('hot'+hotel+'hab'+nrhab+'div_edades_ninos').style.display = "none";
				document.getElementById('hot'+hotel+'hab'+nrhab+'div_edades_ninos_label').style.display = "none";
			}
			for (e=0; e < 9 ; e++) {
				if(nr_ninos > e) {
					//alert('hab'+nrhab+''+'edadNino'+(e+1));
					document.getElementById('hot'+hotel+'hab'+nrhab+''+'edadNino'+(e+1)).style.display = "block";
					if(e>0) document.getElementById('hot'+hotel+'hab'+nrhab+''+'edadNinoSep'+e).style.display = "block"; 
				} else { 
					document.getElementById('hot'+hotel+'hab'+nrhab+'edadNino'+(e+1)).style.display = "none"; 
					document.getElementById('hot'+hotel+'hab'+nrhab+'edadNino'+(e+1)).options[0].selected = "true";
					if(e>0) document.getElementById('hot'+hotel+'hab'+nrhab+'edadNinoSep'+e).style.display = "none"; 
				}
			}			
		}

		function displayRooms(nrhab,hotel) {
			//alert(nrhab+'-'+hotel);
			for (e=0; e<9; e++) { 
				if(e < nrhab) {
					document.getElementById('hot'+hotel+'hab'+e).style.display = "block"; 
				} else {
					document.getElementById('hot'+hotel+'hab'+e).style.display = "none";
				}
			}
			document.getElementById('hot'+hotel+'hab'+nrhab+'adultos').options[0].selected = "true";
			document.getElementById('hot'+hotel+'hab'+nrhab+'ninos').options[0].selected = "true";
			displayEdades(hotel,nrhab,0);	
		}

		function sel_hab2(hotel,total_nrhab,nrhab,totalnrthabitacion,nrthabitacion,thabitacionnombre,thabitacion,regimen,precio,coste) {	
			document.getElementById('td'+hotel+''+nrhab+''+thabitacion+''+regimen).style.background = "#eaeef1";
			document.getElementById('td'+hotel+''+nrhab+''+thabitacion+''+regimen+'_sel').style.background = "#eaeef1";

			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_thabitacion').value = thabitacion;
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_thabitacion_nombre').value = thabitacionnombre;
			
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_regimen').value = regimen;
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_precio').value = precio;
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_coste').value = coste;
		}
		
		function precios_por(hotel,totalnrhabitaciones,totalnrthabitacion,n_regimen,dias,moneda_txt,dia_txt,persona_txt) {
			var regimen = n_regimen.split('_');
			//alert(document.getElementById('precios_por_dias').checked+"-"+hotel+"-"+totalnrhabitaciones+"-"+totalnrthabitacion+"-"+n_regimen);
			
			var precio = 0;
			var preciosinoferta = 0;
			var personas = 1;
			for(var cont_nrhab=0; cont_nrhab<totalnrhabitaciones;cont_nrhab++) {
				for(var cont_nrthab=0; cont_nrthab<totalnrthabitacion;cont_nrthab++) {
					for(var cont_regimen=0; cont_regimen<regimen.length;cont_regimen++) {
						
						personas = document.getElementById('p'+hotel+cont_nrhab+cont_nrthab+regimen[cont_regimen]+'_personas').value;
						precio = document.getElementById('p'+hotel+cont_nrhab+cont_nrthab+regimen[cont_regimen]+'_precio_total').value;
						moneda_dia_persona_txt = moneda_txt;
						
						precio = precio.replace(',','.');
						if(document.getElementById('precios_por_dias').checked) {
							precio = precio / dias;
							moneda_dia_persona_txt = moneda_dia_persona_txt + "/" + dia_txt;
						}	
						if(document.getElementById('precios_por_personas').checked) {
							precio = precio / personas;
							moneda_dia_persona_txt = moneda_dia_persona_txt + "/" + persona_txt;
						}	
						precio = (precio*1).toFixed(2);
						precio = precio.replace('.',',');
						
						document.getElementById('p'+hotel+cont_nrhab+cont_nrthab+regimen[cont_regimen]+'_precio').innerHTML = precio +""+" &euro";
						if(document.getElementById('p'+hotel+cont_nrhab+cont_nrthab+regimen[cont_regimen]+'_preciosinoferta')) {
							preciosinoferta = document.getElementById('p'+hotel+cont_nrhab+cont_nrthab+regimen[cont_regimen]+'_preciosinoferta_total').value;
							preciosinoferta = preciosinoferta.replace(',','.');
							if(document.getElementById('precios_por_dias').checked) {
								preciosinoferta = preciosinoferta / dias;
							}	
							if(document.getElementById('precios_por_personas').checked) {
								preciosinoferta = preciosinoferta / personas;
							}	
							preciosinoferta = (preciosinoferta*1).toFixed(2);
							preciosinoferta = preciosinoferta.replace('.',',');
							document.getElementById('p'+hotel+cont_nrhab+cont_nrthab+regimen[cont_regimen]+'_preciosinoferta').innerHTML = preciosinoferta +""+" &euro";
							
						}
						document.getElementById('moneda_dia_persona').innerHTML = moneda_dia_persona_txt;
					}
				}
			}
		}
		
		function sel_hab(hotel,total_nrhab,nrhab,totalnrthabitacion,nrthabitacion,thabitacionnombre,thabitacion,regimen,precio,preciosinoferta,coste,prepago,oferta) {
			//alert("".prepago);
			for(th=0; th<totalnrthabitacion;th++) {
				for(h=0; h< 12;h++) {
					if(document.getElementById('tr'+hotel+''+nrhab+''+th).getElementsByTagName('td')[h]) {
						document.getElementById('tr'+hotel+''+nrhab+''+th).getElementsByTagName('td')[h].style.background = "transparent";
					}
				}
			}
			for(h=0; h<12;h++) {
				if(document.getElementById('tr'+hotel+''+nrhab+''+nrthabitacion).getElementsByTagName('td')[h]) {
					document.getElementById('tr'+hotel+''+nrhab+''+nrthabitacion).getElementsByTagName('td')[h].style.background = "#f9f9f9";
				}
			}
			if(document.getElementById('td'+hotel+''+nrhab+''+thabitacion+''+regimen)) {	
				document.getElementById('td'+hotel+''+nrhab+''+thabitacion+''+regimen).style.background = "#eaeef1";
				document.getElementById('td'+hotel+''+nrhab+''+thabitacion+''+regimen+'_sel').style.background = "#eaeef1";
				document.getElementById('hot'+hotel+'selhab'+nrhab+'thab'+thabitacion+'reg'+regimen+'_check').checked = 'checked';
			}
			
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_thabitacion').value = thabitacion;
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_thabitacion_nombre').value = thabitacionnombre;
			
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_regimen').value = regimen;
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_precio').value = parseToFloat(precio);
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_preciosinoferta').value = parseToFloat(preciosinoferta);
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_coste').value = coste;
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_prepago').value = prepago;
			
			document.getElementById('selhot'+hotel+'sel_hab'+nrhab+'_ofertas').value = oferta;
			
			val_total = 0;
			for(h=0; h<total_nrhab ; h++) { 
				val_tmp = parseToFloat(document.getElementById('selhot'+hotel+'sel_hab'+h+'_precio').value);
				val_total = parseFloat(val_total)+parseFloat(val_tmp); 
			}
			
			val_total = val_total.toFixed(2);
			//val_total.replace('.',',');
			document.getElementById('hot'+hotel+'sel_precio_total').value = val_total;
		}
		
		function parseToFloat(val) {
			//val = val.replace('.','');
			val = val.replace(',','.');
			return val;
		}
		
		function displayreserva(hotel) {
			document.getElementById('peticion_reserva'+hotel).style.display='block';
			document.getElementById('peticion_reserva'+hotel+'_desde').style.display='none';
		}
		function showDetailHab(hotel,hab,thab) {
			//alert('hot'+hotel+'hab'+hab+'thab'+thab+'detail');
			if(document.getElementById('hot'+hotel+'hab'+hab+'thab'+thab+'detail').style.display == "none") {
				//Effect.BlindDown('hot'+hotel+'hab'+hab+'thab'+thab+'detail');
				document.getElementById('hot'+hotel+'hab'+hab+'thab'+thab+'detail').style.display = "";
			} else {
				//Effect.BlindUp('hot'+hotel+'hab'+hab+'thab'+thab+'detail');
				document.getElementById('hot'+hotel+'hab'+hab+'thab'+thab+'detail').style.display = "none";
			}
					
		}

		function setactmenu(menu,nr_hotel) {
			//alert(menu+' - '+nr_hotel);
			document.getElementById('hotelinfo'+nr_hotel).style.display = "block";
			document.getElementById('desc'+nr_hotel+'corto').style.display = "none";
			
			
			if(menu == 'preserva' || menu == 'creserva') {
					document.getElementById('hotelinfo'+nr_hotel).style.display = "none";
					document.getElementById('desc'+nr_hotel+'corto').style.display = "";
			}
			if(menu != 'creserva') {
				//document.getElementById('m_creserva'+nr_hotel).className="m_desc_hotel";
				document.getElementById('m_preserva'+nr_hotel).style.display = "block";
				document.getElementById('m_creserva'+nr_hotel).style.display = "none";
				if(menu == 'preserva') {
					document.getElementById('m_creserva'+nr_hotel).style.display = "block";
					document.getElementById('m_preserva'+nr_hotel).style.display = "none";
				}
				document.getElementById('creserva'+nr_hotel).style.display = "none";
			}
			if(menu != 'preserva') {
				//document.getElementById('m_preserva'+nr_hotel).className="m_desc_hotel";
				document.getElementById('m_preserva'+nr_hotel).style.display = "block";
				document.getElementById('m_creserva'+nr_hotel).style.display = "none";
				document.getElementById('preserva'+nr_hotel).style.display = "none";
			}
			
			if(menu != 'desc') {
				document.getElementById('m_desc'+nr_hotel).className="m_desc_hotel";
				document.getElementById('desc'+nr_hotel).style.display = "none";
			} 

			
			
			if(menu != 'desc2') {
				document.getElementById('m_desc2'+nr_hotel).className="m_desc_hotel";
				//Effect.BlindUp('desc2'+nr_hotel);
				document.getElementById('desc2'+nr_hotel).style.display = "none";
			}
			
			//document.getElementById('m_encanto'+nr_hotel).className="m_desc_hotel";
			//document.getElementById('encanto'+nr_hotel).style.display = "none";
			//document.getElementById('m_playa'+nr_hotel).className="m_desc_hotel";
			//document.getElementById('playa'+nr_hotel).style.display = "none";
			
			if(menu != 'otros') {
				if(document.getElementById('m_otros'+nr_hotel)!= null) document.getElementById('m_otros'+nr_hotel).className="m_desc_hotel";
				if(document.getElementById('otros'+nr_hotel)!= null) document.getElementById('otros'+nr_hotel).style.display = "none";
			}
			
			if(menu != 'galleria') {
				document.getElementById('m_galleria'+nr_hotel).className="m_desc_hotel";
				document.getElementById('galleria'+nr_hotel).style.display = "none";
			}
			if(menu != 'mapa') {
				document.getElementById('m_mapa'+nr_hotel).className="m_desc_hotel";
				document.getElementById('mapa'+nr_hotel).style.display = "none";
			}
			if(document.getElementById(menu+''+nr_hotel).style.display == "block") {
				document.getElementById(menu+''+nr_hotel).style.display = "none"; 
				if(menu != 'preserva' && menu != 'creserva') document.getElementById('m_'+menu+''+nr_hotel).className="m_desc_hotel";
				if(menu=='desc') {
					document.getElementById('hotelinfo'+nr_hotel).style.display = "none";
					document.getElementById('desc'+nr_hotel+'corto').style.display = "";
					Effect.BlindDown('creserva'+nr_hotel);
				}
			} else {
				if(menu=='preserva' || menu=='creserva' || menu=='hotelinfo' ) {
					Effect.BlindDown(menu+''+nr_hotel);
				}else {
					document.getElementById(menu+''+nr_hotel).style.display = "block";
				}
				if(menu != 'preserva' && menu != 'creserva') document.getElementById('m_'+menu+''+nr_hotel).className="m_desc_hotel_sel";	
			}
			
		}
		
		function animatedcollapse_show(seldiv) {
				//Effect.BlindDown(seldiv);
				//document.getElementById(seldiv).style.display = "block";
		}
		function statusbar() {
			self.status='e-booking7';
			return true;
		}
		
		function hidestatus(){
			window.status='';
			startclock();
			return true;
		}
		if (document.layers) {
			document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
			document.onmouseover=hidestatus;
			document.onmouseout=hidestatus;
			document.onmousedown=hidestatus;
			document.onmouseup=hidestatus;
			document.onmouseclick=hidestatus;
		}
		
		var timerID = null;
		var timerRunning = false;

		function stopclock (){
		        if(timerRunning)
		                clearTimeout(timerID);
		        timerRunning = false;
		}

		function showtime () {
		        var now = new Date();
		        var hours = now.getHours();
		        var minutes = now.getMinutes();
		        var seconds = now.getSeconds()
		        var timeValue = "" + ((hours >12) ? hours -12 :hours)
		        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
		        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
		        timeValue += (hours >= 12) ? " P.M." : " A.M."
		        window.status = timeValue;
		        timerID = setTimeout("showtime()",1000);
		        timerRunning = true;
		}
		function startclock () {
		        stopclock();
		        showtime();
		}

		
