// JavaScript Document

function cambiar_cabecera(opcion){
	switch(opcion){
	  case 0:
	    imagen = "http://www.ronda-hoteles.com/img/cabecera0.jpg";
		document.getElementById("foto_cabecera").src = imagen;
	  break;
	  case 1:
	    imagen = "http://www.ronda-hoteles.com/img/cabecera_1.jpg";
		document.getElementById("foto_cabecera").src = imagen;
	  break;
	  case 2:
	    imagen = "http://www.ronda-hoteles.com/img/cabecera_2.jpg";
		document.getElementById("foto_cabecera").src = imagen;
	  break;
	  case 3:
	    imagen = "http://www.ronda-hoteles.com/img/cabecera_3.jpg"
		document.getElementById("foto_cabecera").src = imagen;
	  break;
	  default:
	    imagen = "http://www.ronda-hoteles.com/img/cabecera_1.jpg";
		document.getElementById("foto_cabecera").src = imagen;
	  
	}
	
}

function validar_newsletter(){

email = document.newsletter.email.value;

error = "";
	if(document.newsletter.aviso.checked != true){
	  error += "Debe marcar la casilla de Aviso Legal\n";
	}
	if(email == "" || email.indexOf("Escribe") != -1){
	
		error += "Introduzca una direcci\u00F3n de correo electr\u00F3nico.\n";
	}else{
	  if(email.indexOf('.')== -1 || email.indexOf('@')== -1){
		  error += "Introduzca un e-mail v\u00E1lido.\n";
	  }
	}
	
	if(error == ""){
	  document.newsletter.submit();	
	}else{
	  alert(error);
	}
}

function abrir_privacidad(){
	
	window.open('http://www.ronda-hoteles.com/php/politica_privacidad.php','_blank','top=0, left=0, width=500,height=450,resizable=no,scrollbars=no, ');
	
}




function validar_busqueda_casa(formulario){
	destino = formulario.c_destino.value;
	error = "";

	if(destino == ""){
	  error += "Debe elegir un destino.\n";  
	}
	
	fentrada = formulario.c_fentrada.value;
	fsalida = formulario.c_fsalida.value;
	
	var aux_fentrada = fentrada.split("/");
    var dia_ent = parseInt(aux_fentrada[0],10);
    var mes_ent = parseInt(aux_fentrada[1],10);
    var anio_ent = parseInt(aux_fentrada[2],10);
  
  	var hoy = new Date();
  	var diaHoy = hoy.getDate()+1;
	
  	var mesHoy = hoy.getMonth()+1;
  	var anioHoy = hoy.getYear();
  
	if(fentrada == ""){
		error += "Indique la fecha de ENTRADA AL ALOJAMIENTO RURAL.\n";
	}else{
	   
	   if(mes_ent == mesHoy && anio_ent == anioHoy){
		   
		   if(dia_ent < diaHoy ){
			  
					  error+= "Fecha de ENTRADA AL ALOJAMIENTO RURAL no v\u00E1lida \n";
		   } 
	   }
	}
	
	var aux_fsalida = fsalida.split("/");
    var dia_reg = parseInt(aux_fsalida[0],10);
    var mes_reg = parseInt(aux_fsalida[1],10);
    var anio_reg = parseInt(aux_fsalida[2],10);
	
	if(fsalida == ""){
	   error += "Indique la fecha de SALIDA DEL ALOJAMIENTO RURAL.\n";
	}else{
		if(mes_reg == mesHoy && anio_reg == anioHoy){
			 if(dia_reg < diaHoy || dia_reg == diaHoy){
			  error += "Fecha de SALIDA DEL ALOJAMIENTO RURAL no v\u00E1lida \n" ;
			 }  
		}
	}
	
	if(anio_ent > anio_reg){
		error += "Fechas no v\u00E1lidas.\n";
	}else{
	    if(anio_ent == anio_reg){
		  if(mes_ent > mes_reg){
			  error += "Fechas no v\u00E1lidas.\n";
		  }else{
		    if(mes_ent == mes_reg){
			  if(dia_ent > dia_reg){
				error += "Fechas no v\u00E1lidas.\n";  
			  }else{
				
			    if(dia_reg <= dia_ent || dia_reg < (dia_ent + 2)){
					error += "No se permiter reservas para menos de dos noches.\n"; 
				}
			  }
			}
		  }
		}
	}
	
	if(error == ""){
	  formulario.submit();
	}else{
	  alert(error);
	}
	
}

function validar_busqueda_casa2(formulario){
	
	error = "";

	
	fentrada = formulario.c_fentrada.value;
	fsalida = formulario.c_fsalida.value;
	noches =  formulario.noches.value;
	if(noches == ""){
	  error += "El rango de fechas no puede ser superior a 60 noches\n";
	}
	
	var aux_fentrada = fentrada.split("/");
    var dia_ent = parseInt(aux_fentrada[0],10);
    var mes_ent = parseInt(aux_fentrada[1],10);
    var anio_ent = parseInt(aux_fentrada[2],10);
  
  	var hoy = new Date();
  	var diaHoy = hoy.getDate()+1;
	
  	var mesHoy = hoy.getMonth()+1;
  	var anioHoy = hoy.getYear();
  
	if(fentrada == ""){
		error += "Indique la fecha de ENTRADA AL ALOJAMIENTO RURAL.\n";
	}else{
	   
	   if(mes_ent == mesHoy && anio_ent == anioHoy){
		   
		   if(dia_ent < diaHoy ){
			  
					  error+= "Fecha de ENTRADA AL ALOJAMIENTO RURAL no v\u00E1lida \n";
		   } 
	   }
	}
	
	var aux_fsalida = fsalida.split("/");
    var dia_reg = parseInt(aux_fsalida[0],10);
    var mes_reg = parseInt(aux_fsalida[1],10);
    var anio_reg = parseInt(aux_fsalida[2],10);
	
	if(fsalida == ""){
	   error += "Indique la fecha de SALIDA DEL ALOJAMIENTO RURAL.\n";
	}else{
		if(mes_reg == mesHoy && anio_reg == anioHoy){
			 if(dia_reg < diaHoy || dia_reg == diaHoy){
			  error += "Fecha de SALIDA DEL ALOJAMIENTO RURAL no v\u00E1lida \n" ;
			 }  
		}
	}
	
	if(anio_ent > anio_reg){
		error += "Fechas no v\u00E1lidas.\n";
	}else{
	    if(anio_ent == anio_reg){
		  if(mes_ent > mes_reg){
			  error += "Fechas no v\u00E1lidas.\n";
		  }else{
		    if(mes_ent == mes_reg){
			  if(dia_ent > dia_reg){
				error += "Fechas no v\u00E1lidas.\n";  
			  }else{
				
			    if(dia_reg <= dia_ent  || dia_reg < (dia_ent + 2)){
					error += "No se permiter reservas para menos de dos noches.\n"; 
				}
			  }
			}
		  }
		}
	}
	
	if(error == ""){
	  //formulario.submit();
	  ver_precio_casa();
	}else{
	  alert(error);
	}
	
}

function ver_caja_bedsonline(tipo){
  estado =document.getElementById('info_'+tipo).style.display;
  contenedor=document.getElementById('abrir_caja_detalles_'+tipo);
  if(estado == "none") {	
  	switch(tipo){
		case "casa":
	  	  	document.getElementById('info_casa').style.display='inline';
  			document.getElementById('room_casa').style.display='inline';
			contenedor.innerHTML="Cerrar";  	
		break;
		case "coche":
			document.getElementById('info_coche').style.display='inline';
			contenedor.innerHTML="Cerrar Detalles"; 
		break;
		case "hotel":
	  	  	document.getElementById('info_hotel').style.display='inline';
  			document.getElementById('room_hotel').style.display='inline';
			document.getElementById('titulo_tabla').style.display='inline';
            contenedor.innerHTML="Cerrar";  	
		break;
		
		
	}
  }else{
	  switch(tipo){
		 case "casa":
	  	  	document.getElementById('info_casa').style.display='none';
  			document.getElementById('room_casa').style.display='none';
			contenedor.innerHTML="Desglosar";  	
		break; 
		case "hotel":
	  		document.getElementById('info_hotel').style.display='none';
  			document.getElementById('room_hotel').style.display='none';
			document.getElementById('titulo_tabla').style.display='none';
			contenedor.innerHTML="Desglosar";  	
		break;
		case "coche":
			document.getElementById('info_coche').style.display='none';
			contenedor.innerHTML="ABRIR DETALLES"; 
		break;
		
	}
  }
}

function validar_venta_casa(){
	//datos de contacto
	nombre_contacto = document.formulario_venta.nombre_contacto.value;
	apellidos_contacto = document.formulario_venta.apellidos_contacto.value;
	telefono_contacto = document.formulario_venta.telefono_contacto.value;
	email_contacto = document.formulario_venta.email_contacto.value;
	
	
	error = "";
	if(nombre_contacto == ""){
	   error  += "Introduzca el nombre de la persona de contacto para la reserva.\n";
	}
	if(apellidos_contacto == ""){
	   error  += "Introduzca los apellidos de la persona de contacto para la reserva.\n";
	}
	if(telefono_contacto == ""){
	   error  += "Introduzca el teléfono de la persona de contacto para la reserva.\n";
	}
	if(email_contacto == ""){
	   error  += "Introduzca el email de la persona de contacto para la reserva.\n";
	}else{
	   if(email_contacto.indexOf(".")==-1 || email_contacto.indexOf("@") == -1){
		   error += "Formato de e-mail no v\u00E1lido\n";
	   }
	}
	
	if(document.formulario_venta.nombre_a1_1 != null && document.formulario_venta.nombre_a1_1.value==""){
		error  += "Introduzca el nombre de la persona al cargo de la habitacion 1.\n";
	}
	if(document.formulario_venta.apellidos_a1_1 != null && document.formulario_venta.apellidos_a1_1.value==""){
		error  += "Introduzca los apellidos de la persona al cargo de la habitacion 1.\n";
	}
	if(document.formulario_venta.nombre_a2_1 != null && document.formulario_venta.nombre_a2_1.value==""){
		error  += "Introduzca el nombre de la persona al cargo de la habitacion 2.\n";
	}
	if(document.formulario_venta.apellidos_a2_1 != null && document.formulario_venta.apellidos_a2_1.value==""){
		error  += "Introduzca los apellidos de la persona al cargo de la habitacion 2.\n";
	}
	if(document.formulario_venta.nombre_a3_1 != null && document.formulario_venta.nombre_a3_1.value==""){
		error  += "Introduzca el nombre de la persona al cargo de la habitacion 3.\n";
	}
	if(document.formulario_venta.apellidos_a3_1 != null && document.formulario_venta.apellidos_a3_1.value==""){
		error  += "Introduzca los apellidos de la persona al cargo de la habitacion 3.\n";
	}
	if(document.formulario_venta.nombre_a4_1 != null && document.formulario_venta.nombre_a4_1.value==""){
		error  += "Introduzca el nombre de la persona al cargo de la habitacion 4.\n";
	}
	if(document.formulario_venta.apellidos_a4_1 != null && document.formulario_venta.apellidos_a4_1.value==""){
		error  += "Introduzca los apellidos de la persona al cargo de la habitacion 4.\n";
	}

	
	
	//VALIDO EL NÚMERO DE CUENTA
	if(document.formulario_venta.numtotal.value==""){
	  error += "Debe introducir el n\u00FAmero de su tarjeta de cr\u00E9dito.\n";
	}else{
	  if( isCreditCard(document.formulario_venta.numtotal.value) == false){
	    error += "Número de tarjeta no v\u00E1lido.\n";
	  }else{
		  if(!es_numerico(document.formulario_venta.numtotal.value)){//vemos si es numérico 
				error += "Número de tarjeta no v\u00E1lido.\n";
		 }else{
			 if(document.formulario_venta.numtotal.length<16){//vemos si tiene 16 digitos 
					error += "Número de tarjeta no v\u00E1lido.\n";
			 }
		 }
	  }
	}
	 
	 
	//VALIDO EL CODIGO DE SEGURIDAD CVV
	if(document.formulario_venta.cvv.value==""){
	  error += "Debe indicar el código de seguridad de su tarjeta.\n";
	}
	var cod_cvv = document.formulario_venta.cvv.value;
	if(cod_cvv.length < 3){
	 error +="El código de segurida debe tener al menos 3 dígitos\n";
	} 
	if(!es_numerico(cod_cvv)){//vemos si es numérico el cvv
			error += "Código de seguridad no válido.\n";
	 }
	
	//VALIDO LA FECHA DE CADUCIDAD
	if (document.formulario_venta.mes.value=="vacio" || document.formulario_venta.ano.value=="vacio"){
		error += "No ha detallado la caducidad de la tarjeta\n";

	}
	
	//VALIDO EL NOMBRE QUE FIGURA EN LA TARJETA
	if(document.formulario_venta.nombretag.value==""){
	 error += "Campo Nombre que figura en la tarjeta vacio.";
	}
	else{
	 
	 if(!es_cadena(document.formulario_venta.nombretag.value)){
	  error += "El nombre que aparece en la tarjeta no es válido.";
	 }
	}
	
	//vemos si ha escogido factura y analizamos los datos
	//VALIDAMOS LOS DATOS DE LA FACTURA EN CASO DE SELECCIONAR FACTURA
	if(document.formulario_venta.sif[0].checked){
	 //VALIDAMOS LA RAZÓN SOCIAL
	 if(document.formulario_venta.razon.value==""){
	  error += "Debe indicar la razón social.\n";
	 }
	 //VALIDAMOS EL NIF/CIF
	 if(document.formulario_venta.nif.value==""){
	  error += "Debe indicar un CIF/NIF.\n";
	 }
	 //VALIDAMOS LA PERSONA DE CONTACTO
	 if(document.formulario_venta.contacto.value==""){
	  error += "Debe indicar una persona de contacto.\n";
	 }
	 //VALIDAMOS EL EMAIL
	 if ((document.formulario_venta.mail2.value.indexOf ('@') == -1)||(document.formulario_venta.mail2.value.indexOf ('.') == -1)) {
	  error += "Escriba una dirección de e-mail válida\n";
	 }
	 
	 //VALIDO LA DIRECCIÓN POSTAL
	 if(document.formulario_venta.dirpostal.value==""){
	  error += "Debe indicar una dirección postal\n";
	 }
	 
	 //VALIDO EL TELEFONO
	 if(document.formulario_venta.telefono.value==""){
	  error += "Debe indicar un número de teléfono.\n";
	 }
	 else{
	   document.formulario_venta.telefono.value = no_espacios(document.formulario_venta.telefono.value); 

	   if(!es_numerico(document.formulario_venta.telefono.value)){
		 error += "El número de telefono introducido no es válido.\n";
	   }
	  
	 }
	 
	 //VALIDO EL CÓDIGO POSTAL
	 if(document.formulario_venta.codigopostal.value==""){
	  error +="Debe indicar un codigo postal.\n";
	  }
	  else{
		document.formulario_venta.codigopostal.value = no_espacios(document.formulario_venta.codigopostal.value);
		if(!es_numerico(document.formulario_venta.codigopostal.value)){
			error += "El código postal introducido no es válido.\n";
		 }
	  
	  }
	//VALIDO LA LOCALIDAD
	if(document.formulario_venta.localidad.value==""){
	 error += "Debe indicar una localidad.\n";
	}
	//VALIDO LA PROVINCIA
	if(document.formulario_venta.provincia.value==""){
	 error += "Debe indicar una provincia.\n";
	}
	//VALIDO EL PAÍS
	if(document.formulario_venta.paisf.value==""){
	 error += "Debe indicar un país.\n";
	}
	/****************************************************/
	}
	
	if(error == ""){
	  document.formulario_venta.submit();	 
	}else{
	  alert(error);
	}
	
	
}

/*---------------------------------------------------------------*/
/*                                                               */
/* Function  : isCreditCard()                                           */
/* Purpose   : Check if cc is LUHN10      */
/*                                                                  */
/*                                                               */
/* Parameters:     cc - the cc number                                                       */
/*                                                               */
/* Returns   : boolean                                              */
/*                                                               */
/* Usage     : isCreditCard(cc)                                           */
/*---------------------------------------------------------------*/

     function isCreditCard( CC ) 
     {                         
          if (CC.length > 19)
               return (false);

          sum = 0; mul = 1; l = CC.length;
          for (i = 0; i < l; i++) 
          {
               digit = CC.substring(l-i-1,l-i);
               tproduct = parseInt(digit ,10)*mul;
               if (tproduct >= 10)
                    sum += (tproduct % 10) + 1;
               else
                    sum += tproduct;
               if (mul == 1)
                    mul++;
               else
                    mul--;
          }
          if ((sum % 10) == 0)
               return (true);
          else
               return (false);
     }



//función que controla que todos los caracteres de una cadena son números
function es_numerico(cadena){
var numeros = "0123456789";
var todo_valido = true;

for (i = 0; i < cadena.length; i++) 
{
 ch = cadena.charAt(i);

 for (j = 0; j < numeros.length; j++){
	
	if (ch == numeros.charAt(j))
	  break;
	  
	if (j == (numeros.length - 1) ) {
	 todo_valido = false;
	}
  }		
}


return todo_valido;
}//fin funcion es_numerico
//función no espacios
function no_espacios(cadena){
//pasamos a liminar primero el primer espacio en blanco introducido y el último
var primerBlanco = /^ /
var ultimoBlanco = / $/

cadena = cadena.replace (primerBlanco,"");
cadena = cadena.replace (ultimoBlanco,"");

return (cadena);
}
//función es cadena
//FUNCIÓN QUE CONTROLA QUE TODDOS LOS CARACTERES DE UNA CADENA NO SEAN NUMEROS
function es_cadena(cadena){
 var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú_ ";
 var checkStr = cadena;
 var allValid = true;
 for (i = 0; i < checkStr.length; i++) {
  ch = checkStr.charAt(i);
 
  for (j = 0; j < checkOK.length; j++){
	// alert(ch+"-->"+checkOK.charAt(j));
	if (ch == checkOK.charAt(j))
	 break;

	//alert(j)
	if (j == (checkOK.length - 1)) {
	 allValid = false;
	 
	}
  }
 }
   return (allValid);
 
}//FIN FUNCIÓN ES_CADENA

function nuevoAjax(){ 
  var xmlhttp=false; 
  try { 
   // Creación del objeto ajax para navegadores diferentes a Explorer 
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch (e) { 
   // o bien 
   try { 
	 // Creación del objet ajax para Explorer 
	 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { 
	 xmlhttp = false; 
   } 
  } 

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
   xmlhttp = new XMLHttpRequest(); 
  } 
  return xmlhttp; 
}

function mandar_bono(bono){
			var b = document.getElementById(bono);
			b.contentWindow.focus();
			var cuerpo='tipo='+bono+'&mensaje_bono='+escape(b.contentWindow.document.body.innerHTML);
			ajax=nuevoAjax(); 
			ajax.open("POST", "./enviar_bono.php",true);
			ajax.onreadystatechange=function() { 
			if (ajax.readyState==4) { 
			   alert("Bono enviado.");
			} 
			} 
			ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			ajax.send(cuerpo);
		
}

function mandar_bono2(bono){
			var b = document.getElementById(bono);
			b.contentWindow.focus();
			var cuerpo='tipo='+bono+'&email=bdiez&mensaje_bono='+escape(b.contentWindow.document.body.innerHTML);
			ajax=nuevoAjax(); 
			ajax.open("POST", "./enviar_bono.php",true);
			ajax.onreadystatechange=function() { 
			if (ajax.readyState==4) { 
			   //alert("Bono enviado.");
			} 
			} 
			ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			ajax.send(cuerpo);
		
}

function cargardiv_child_enlace(capa, aEvent,tipo, numero){
		var contenedor;
				var contenido='';
		contenedor = document.getElementById(capa);

		switch(tipo){
		  case "ninos_1":
		    //numero = document.buscador.indiv_childCount.options[document.buscador.indiv_childCount.selectedIndex].value;
			var edades=document.getElementById("edades_ninos_1").value;
			contenido += '<div style="background-color:#0B79ED; height:21px">';
   			contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 1</span></div>';
            contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
			contenido += '</div>';
		  break;
		  case "ninos_2":
		   //numero = document.buscador.doble_childCount.options[document.buscador.doble_childCount.selectedIndex].value;
		   var edades=document.getElementById("edades_ninos_2").value;
		   contenido += '<div style="background-color:#0B79ED; height:21px">';
   		   contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 2</span></div>';
           contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
			contenido += '</div>';
		  break;
		  case "ninos_3":
		   //numero = document.buscador.doble_twochildCount.options[document.buscador.doble_twochildCount.selectedIndex].value;
		   //numero = numero *2;
		   var edades=document.getElementById("edades_ninos_3").value;
		   contenido += '<div style="background-color:#0B79ED; height:21px">';
   		   contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 3</span></div>';
           contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
			contenido += '</div>';
		  break;
		  case "ninos_4":
		   //numero = document.buscador.triple_childCount.options[document.buscador.triple_childCount.selectedIndex].value;		  
		   var edades=document.getElementById("edades_ninos_4").value;
		   contenido += '<div style="background-color:#0B79ED; height:21px">';
   		   contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 4</span></div>';
           contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
 			contenido += '</div>';
		  break;
		}
		
		
	    if(numero>0){
		    contenedor.style.display = "block";
			var tempY = window.event ? window.event.clientY + document.documentElement.scrollTop - 20 :  aEvent.pageY - 20 ;
			var tempX = window.event ? window.event.clientX + document.documentElement.scrollLeft - 50 :  aEvent.pageX - 50 ;
			contenedor.style.top = tempY + "px";
			contenedor.style.left = tempX + "px";

		    contenido+='<table border="0" width="195px">';
		    var edades_aux=edades.split(",");
		    var i=0;
		    var j=0;
		    for (i=1;i<=numero;i++){
		    	contenido+='<tr><td class="E-12-negro" width="45px">Niño '+i+':</td><td align="right"><select class="E-12-negro" name="child'+i+'" id="child'+i+'">';
		    	for(j=0;j<=11;j++){
		    		contenido+='<option value="'+j+'" ';
		    		if(j==parseInt(edades_aux[i-1]))
		    			contenido+='selected=true';
		    		contenido+='>'+j+' Años</option>';
		    	}
		    	contenido+='</select></td><td width="60px" align=center>';
		    	if(i==numero)
		    		contenido+='<a href="javascript:validar_ages(\''+tipo+'\');" class=E-12-azul >Aceptar</a>';
		    	contenido+='</td></tr>';
		    }
			//contenido += '<tr><td>&nbsp;</td><td align="right"><input type="button" name="validar_ninos" value="cerrar" onclick="validar_ages();" /></td></tr>';
		    contenido+='</table>';
		    contenedor.innerHTML=contenido;	
	    }else{
	    	contenedor.innerHTML="";
	    	contenedor.style.display = "none";
			
			
			switch(tipo){
			  case "ninos_1":
			    document.getElementById("edades_ninos_1").value = "";
			    contenedor=document.getElementById('div_ages_ninos_1');
			  break;
			  case "ninos_2":
			    document.getElementById("edades_ninos_2").value = "";
			    contenedor=document.getElementById('div_ages_ninos_2');		   
			  break;
			  case "ninos_3":
	 		    document.getElementById("edades_ninos_3").value = "";	
	 		    contenedor=document.getElementById('div_ages_ninos_3');	   
			  break;
			  case "ninos_4":
			    document.getElementById("edades_ninos_4").value = "";
			    contenedor=document.getElementById('div_ages_ninos-4');			   
			  break;
			}
			contenedor.innerHTML="";
	    }
	}


function cargardiv_child(capa, aEvent,tipo){
		var contenedor;
				var contenido='';
		contenedor = document.getElementById(capa);

		switch(tipo){
		  case "ninos_1":
		    numero = document.form_buscador_hoteles.ninos_1.options[document.form_buscador_hoteles.ninos_1.selectedIndex].value;
			
			contenido += '<div style="background-color:#0B79ED; height:21px">';
   			contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 1</span></div>';
            contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
			contenido += '</div>';
		  break;
		  case "ninos_2":
		   numero = document.form_buscador_hoteles.ninos_2.options[document.form_buscador_hoteles.ninos_2.selectedIndex].value;
		   contenido += '<div style="background-color:#0B79ED; height:21px">';
   		   contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 2</span></div>';
           contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
			contenido += '</div>';
		  break;
		  case "ninos_3":
		   numero = document.form_buscador_hoteles.ninos_3.options[document.form_buscador_hoteles.ninos_3.selectedIndex].value;
		   contenido += '<div style="background-color:#0B79ED; height:21px">';
   		   contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 3</span></div>';
           contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
			contenido += '</div>';
		  break;
		  case "ninos_4":
		   numero = document.form_buscador_hoteles.ninos_4.options[document.form_buscador_hoteles.ninos_4.selectedIndex].value;		  
		   contenido += '<div style="background-color:#0B79ED; height:21px">';
   		   contenido += '<div style="float:left"><span class="E-12-blanco-bold">Edad ni&ntilde;os Habitaci&oacute;n 4</span></div>';
           contenido += ' <div style="float:right"><img src="http://www.ronda-hoteles.com/img/cerrar_ventana.gif" width="21px" height="21px" onclick="cerrar_ages();" onmouseover="this.style.cursor=\'pointer\'" /></div>';
 			contenido += '</div>';
		  break;
		}
		
		
	    if(numero>0){
		    contenedor.style.display = "block";
			var tempY = window.event ? window.event.clientY + document.documentElement.scrollTop - 20 :  aEvent.pageY - 20 ;
			var tempX = window.event ? window.event.clientX + document.documentElement.scrollLeft - 60 :  aEvent.pageX - 60 ;
			contenedor.style.top = tempY + "px";
			contenedor.style.left = tempX + "px";

		    contenido+='<table border="0" width="195px">';
		    var i=0;
		    var j=0;
		    for (i=1;i<=numero;i++){
		    	contenido+='<tr><td class="E-12-negro" width="45px">Niño '+i+':</td><td align="right"><select class="E-12-negro" name="child'+i+'" id="child'+i+'">';
		    	for(j=0;j<=11;j++){
		    		contenido+='<option value="'+j+'">'+j+' Años</option>';
		    	}
		    	contenido+='</select></td><td width="60px" align=center>';
		    	if(i==numero)
		    		contenido+='<a href="javascript:validar_ages(\''+tipo+'\');" class=E-12-azul >Aceptar</a>';
		    	contenido+='</td></tr>';
		    }
			//contenido += '<tr><td>&nbsp;</td><td align="right"><input type="button" name="validar_ninos" value="cerrar" onclick="validar_ages();" /></td></tr>';
		    contenido+='</table>';
		    contenedor.innerHTML=contenido;	
	    }else{
	    	contenedor.innerHTML="";
	    	contenedor.style.display = "none";
			
			
			switch(tipo){
			  case "ninos_1":
			    document.getElementById("edades_ninos_1").value = "";
			    contenedor=document.getElementById('div_ages_ninos_1');
			  break;
			  case "ninos_2":
			    document.getElementById("edades_ninos_2").value = "";
			    contenedor=document.getElementById('div_ages_ninos_2');		   
			  break;
			  case "ninos_3":
	 		    document.getElementById("edades_ninos_3").value = "";	
	 		    contenedor=document.getElementById('div_ages_ninos_3');	   
			  break;
			  case "ninos_4":
			    document.getElementById("edades_ninos_4").value = "";
			    contenedor=document.getElementById('div_ages_ninos_4');			   
			  break;
			}
			contenedor.innerHTML="";
	    }
	}

function validar_ages2(tipo){
	
			switch(tipo){
		  case "ninos_1":
		    num = document.form_buscador_hoteles.ninos_1.options[document.form_buscador_hoteles.ninos_1.selectedIndex].value;
			datos = document.getElementById('edades_ninos_1').value;
			var contenedor=document.getElementById('div_ages_ninos_1');
		  break;
		  case "ninos_2":
		   num = document.form_buscador_hoteles.ninos_2.options[document.form_buscador_hoteles.ninos_2.selectedIndex].value;
		   var contenedor=document.getElementById('div_ages_ninos_2');
		   datos = document.getElementById('edades_ninos_2').value;
		  break;
		  case "ninos_3":
		   num = document.form_buscador_hoteles.ninos_3.options[document.form_buscador_hoteles.ninos_3.selectedIndex].value;
		   var contenedor=document.getElementById('div_ages_ninos_3');
		   datos = document.getElementById('edades_ninos_3').value;
		  break;
		  case "ninos_4":
		   num = document.form_buscador_hoteles.ninos_4.options[document.form_buscador_hoteles.ninos_4.selectedIndex].value;		  
		   var contenedor=document.getElementById('div_ages_ninos_4');
		   datos = document.getElementById('edades_ninos_4').value;
		  break;
		}
		
		
		
		
		var i=0;
		var contenido='<a class=E-10-azul style="cursor=\'pointer\'" onmouseover="this.style.cursor=\'pointer\'" onclick="javascript:cargardiv_child_enlace(\'div_ninos\', event, \''+tipo+'\', '+num+');">Edades(';
		var aux_edad = "";
		contenido += datos;
		contenido+=')</a>';
		
		contenedor=document.getElementById('div_ninos');
		contenedor.style.display = "none";
		
		switch(tipo){
		  case "ninos_1":
		    
		    contenedor=document.getElementById('div_ages_ninos_1');
		  break;
		  case "ninos_2":
		    
		    contenedor=document.getElementById('div_ages_ninos_2');		   
		  break;
		  case "ninos_3":
 		    
 		    contenedor=document.getElementById('div_ages_ninos_3');	   	   
		  break;
		  case "ninos_4":
		   
		    contenedor=document.getElementById('div_ages_ninos_4');			   
		   
		  break;
		}
		contenedor.innerHTML=contenido;

	
}

function validar_ages(tipo){
		switch(tipo){
		  case "ninos_1":
		    num = document.form_buscador_hoteles.ninos_1.options[document.form_buscador_hoteles.ninos_1.selectedIndex].value;
			var contenedor=document.getElementById('div_ages_ninos_1');
		  break;
		  case "ninos_2":
		   num = document.form_buscador_hoteles.ninos_2.options[document.form_buscador_hoteles.ninos_2.selectedIndex].value;
		   var contenedor=document.getElementById('div_ages_ninos_2');
		  break;
		  case "ninos_3":
		   num = document.form_buscador_hoteles.ninos_3.options[document.form_buscador_hoteles.ninos_3.selectedIndex].value;
		   var contenedor=document.getElementById('div_ages_ninos_3');
		  break;
		  case "ninos_4":
		   num = document.form_buscador_hoteles.ninos_4.options[document.form_buscador_hoteles.ninos_4.selectedIndex].value;		  
		   var contenedor=document.getElementById('div_ages_ninos_4');
		  break;
		}
		
		
		
		
		var i=0;
		var contenido='<a class=E-10-azul style="cursor=\'pointer\'" onmouseover="this.style.cursor=\'pointer\'" onclick="javascript:cargardiv_child_enlace(\'div_ninos\', event, \''+tipo+'\', '+num+');">Edades(';
		var aux_edad = "";
		for(i=1;i<=num;i++){
			if(i==1){
				contenido += document.getElementById('child'+i).value;
				aux_edad += document.getElementById('child'+i).value;
			}else{
				if(i==2)
					contenido += ','+document.getElementById('child'+i).value;
				if(i==3)
					contenido +=',...';
				aux_edad += ','+document.getElementById('child'+i).value;
			}
		}
		contenido+=')</a>';
		
		contenedor=document.getElementById('div_ninos');
		contenedor.style.display = "none";
		
		switch(tipo){
		  case "ninos_1":
		    document.getElementById("edades_ninos_1").value = aux_edad;
		    contenedor=document.getElementById('div_ages_ninos_1');
		  break;
		  case "ninos_2":
		    document.getElementById("edades_ninos_2").value = aux_edad;	
		    contenedor=document.getElementById('div_ages_ninos_2');		   
		  break;
		  case "ninos_3":
 		    document.getElementById("edades_ninos_3").value = aux_edad;	
 		    contenedor=document.getElementById('div_ages_ninos_3');	   	   
		  break;
		  case "ninos_4":
		    document.getElementById("edades_ninos_4").value = aux_edad;
		    contenedor=document.getElementById('div_ages_ninos_4');			   
		   
		  break;
		}
		contenedor.innerHTML=contenido;
		
		
	}
	
function cerrar_ages(){
	contenedor=document.getElementById('div_ninos');
	contenedor.style.display = "none";
}
function validar_venta_hotel(){
	//datos de contacto
	nombre_contacto = document.formulario_venta.nombre_contacto.value;
	apellidos_contacto = document.formulario_venta.apellidos_contacto.value;
	telefono_contacto = document.formulario_venta.telefono_contacto.value;
	email_contacto = document.formulario_venta.email_contacto.value;
	adultos = document.formulario_venta.adultos.value;
	adultos = parseInt(adultos,10);
	menores = document.formulario_venta.menores.value;
	menores = parseInt(menores,10);
	habitaciones = document.formulario_venta.habitaciones.value;
	habitaciones = parseInt(habitaciones,10);
	
	error = "";
	if(nombre_contacto == ""){
	   error  += "Introduzca el nombre de la persona de contacto para la reserva.\n";
	}
	if(apellidos_contacto == ""){
	   error  += "Introduzca los apellidos de la persona de contacto para la reserva.\n";
	}
	if(telefono_contacto == ""){
	   error  += "Introduzca el teléfono de la persona de contacto para la reserva.\n";
	}
	if(email_contacto == ""){
	   error  += "Introduzca el email de la persona de contacto para la reserva.\n";
	}else{
	   if(email_contacto.indexOf(".")==-1 || email_contacto.indexOf("@") == -1){
		   error += "Formato de e-mail no v\u00E1lido\n";
	   }
	}
	
	for(i=1; i<= habitaciones; i++){
	   	
	   
	   
	   switch(i){
		   case 1:
		   var_adultos = document.formulario_venta.adultos_h1.value;
		   var_menores = document.formulario_venta.menores_h1.value;
		   break;
		   case 2:
		   var_adultos = document.formulario_venta.adultos_h2.value;
		   var_menores = document.formulario_venta.menores_h2.value;
		   break;
		   case 3:
		   var_adultos = document.formulario_venta.adultos_h3.value;
		   var_menores = document.formulario_venta.menores_h3.value;
		   break;
		   case 4:
		   var_adultos = document.formulario_venta.adultos_h4.value;
		   var_menores = document.formulario_venta.menores_h4.value;
		   break;
		 }
	   for(j=1; j<= var_adultos;j++){
		   nombre_adulto_aux = document.getElementById("nombre_a"+i+"_"+j).value;
	   	   apellidos_adulto_aux = document.getElementById("nombre_a"+i+"_"+j).value;
		   	   if(nombre_adulto_aux == ""){
				   error += "Introduzca el nombre del adulto "+j+" de la habitacion" + i + "\n";
			   }
			   if(apellidos_adulto_aux == ""){
				   error += "Introduzca los apellidos del adulto "+j+" de la habitacion" + i + "\n";
			   }

	   }
	   if(menores >=1){
		   for(k=1; k<= var_menores;k++){
		   nombre_menor_aux = document.getElementById("nombre_m"+i+"_"+k).value;
	   	   apellidos_menor_aux = document.getElementById("nombre_m"+i+"_"+k).value;
		   	   if(nombre_adulto_aux == ""){
				   error += "Introduzca el nombre del menor "+k+" de la habitacion" + i + "\n";
			   }
			   if(apellidos_adulto_aux == ""){
				   error += "Introduzca los apellidos del menor "+k+" de la habitacion" + i + "\n";
			   }

	   	  }
	   
	   }
	   
	}
	
	
	//VALIDO EL NÚMERO DE CUENTA
	if(document.formulario_venta.numtotal.value==""){
	  error += "Debe introducir el n\u00FAmero de su tarjeta de cr\u00E9dito.\n";
	}
	
	 if(!es_numerico(document.formulario_venta.numtotal.value)){//vemos si es numérico 
			error += "Número de tarjeta no v\u00E1lido.\n";
	 }
	 
	//VALIDO EL CODIGO DE SEGURIDAD CVV
	if(document.formulario_venta.cvv.value==""){
	  error += "Debe indicar el código de seguridad de su tarjeta.\n";
	}
	var cod_cvv = document.formulario_venta.cvv.value;
	if(cod_cvv.length < 3){
	 error +="El código de segurida debe tener al menos 3 dígitos\n";
	} 
	if(!es_numerico(cod_cvv)){//vemos si es numérico el cvv
			error += "Código de seguridad no válido.\n";
	 }
	
	//VALIDO LA FECHA DE CADUCIDAD
	if (document.formulario_venta.mes.value=="vacio" || document.formulario_venta.ano.value=="vacio"){
		error += "No ha detallado la caducidad de la tarjeta\n";

	}
	
	//VALIDO EL NOMBRE QUE FIGURA EN LA TARJETA
	if(document.formulario_venta.nombretag.value==""){
	 error += "Campo Nombre que figura en la tarjeta vacio.\n";
	}
	else{
	 
	 if(!es_cadena(document.formulario_venta.nombretag.value)){
	  error += "El nombre que aparece en la tarjeta no es válido.\n";
	 }
	}
	
	//vemos si ha escogido factura y analizamos los datos
	//VALIDAMOS LOS DATOS DE LA FACTURA EN CASO DE SELECCIONAR FACTURA
	if(document.formulario_venta.sif[0].checked){
	 //VALIDAMOS LA RAZÓN SOCIAL
	 if(document.formulario_venta.razon.value==""){
	  error += "Debe indicar la razón social.\n";
	 }
	 //VALIDAMOS EL NIF/CIF
	 if(document.formulario_venta.nif.value==""){
	  error += "Debe indicar un CIF/NIF.\n";
	 }
	 //VALIDAMOS LA PERSONA DE CONTACTO
	 if(document.formulario_venta.contacto.value==""){
	  error += "Debe indicar una persona de contacto.\n";
	 }
	 //VALIDAMOS EL EMAIL
	 if ((document.formulario_venta.mail2.value.indexOf ('@') == -1)||(document.formulario_venta.mail2.value.indexOf ('.') == -1)) {
	  error += "Escriba una dirección de e-mail válida\n";
	 }
	 
	 //VALIDO LA DIRECCIÓN POSTAL
	 if(document.formulario_venta.dirpostal.value==""){
	  error += "Debe indicar una dirección postal\n";
	 }
	 
	 //VALIDO EL TELEFONO
	 if(document.formulario_venta.telefono.value==""){
	  error += "Debe indicar un número de teléfono.\n";
	 }
	 else{
	   document.formulario_venta.telefono.value = no_espacios(document.formulario_venta.telefono.value); 

	   if(!es_numerico(document.formulario_venta.telefono.value)){
		 error += "El número de telefono introducido no es válido.\n";
	   }
	  
	 }
	 
	 //VALIDO EL CÓDIGO POSTAL
	 if(document.formulario_venta.codigopostal.value==""){
	  error +="Debe indicar un codigo postal.\n";
	  }
	  else{
		document.formulario_venta.codigopostal.value = no_espacios(document.formulario_venta.codigopostal.value);
		if(!es_numerico(document.formulario_venta.codigopostal.value)){
			error += "El código postal introducido no es válido.\n";
		 }
	  
	  }
	//VALIDO LA LOCALIDAD
	if(document.formulario_venta.localidad.value==""){
	 error += "Debe indicar una localidad.\n";
	}
	//VALIDO LA PROVINCIA
	if(document.formulario_venta.provincia.value==""){
	 error += "Debe indicar una provincia.\n";
	}
	//VALIDO EL PAÍS
	if(document.formulario_venta.paisf.value==""){
	 error += "Debe indicar un país.\n";
	}
	/****************************************************/
	}
	if(error == ""){
	  document.formulario_venta.submit();	 
	}else{
	  alert(error);
	}
	
	
}

function generar_habitaciones(numero){
	cadena = "";
	if(numero >=2){
	for(i=2; i<=numero;i++){
	     cadena += '<div style="float:left; margin-right:10px">';
         cadena += '<div style="padding-left:12px"><span class="E-12-negro">Adultos</span></div>';
         cadena += '<div style="clear:both"></div>';
         cadena += '<div style="padding: 14px 12px 6px 15px; display: block; width: 122px; height: 20px; position: relative;" class="caja152">';
         cadena += '<select name="adultos_'+i+'" style="width:122px;border:solid 0px; height:18px; font-family: \'Trebuchet MS\';';
		 cadena += 'font-size: 11px; color: rgb(51, 51, 51); background-color: transparent; cursor: pointer;" >';
         cadena += '<option value="1">1</option>';
         cadena += '<option value="2">2</option>';
         cadena += '<option value="3">3</option>';
         cadena += '<option value="4">4</option>';
         cadena += '<option value="5">5</option>';
         cadena += '</select>';
         cadena += '</div>';
         cadena += '</div>';
         cadena += '<div style="float:left">';
         cadena += '<div style="padding-left:12px"><span class="E-12-negro">Ni&ntilde;os</span></div>';
         cadena += '<div style="clear:both"></div>';
         cadena += '<div style="padding: 14px 12px 6px 15px; display: block; width: 122px; height: 20px; position: relative;" class="caja152">';
         cadena += '<select name="ninos_'+i+'" style="width:122px;border:solid 0px; height:18px; font-family: \'Trebuchet MS\';';
		 cadena += 'font-size: 11px; color: rgb(51, 51, 51); background-color: transparent; cursor: pointer;" onchange="if(this.value != \'0\'){cargardiv_child(\'div_ninos\', event,\'ninos_'+i+'\');}else{document.getElementById(\'div_ages_ninos_'+i+'\').innerHTML=\'\';document.getElementById(\'edades_ninos_'+i+'\').value=\'\'}">';
         cadena += '<option value="0">0</option>';
         cadena += '<option value="1">1</option>';
         cadena += '<option value="2">2</option>';
         cadena += '<option value="3">3</option>';
         cadena += '<option value="4">4</option>';
         cadena += '<option value="5">5</option>';
         cadena += '</select>';
         cadena += '</div>';
		 cadena += '<div style="padding-left:12px;" id="div_ages_ninos_'+i+'"></div>'
         cadena += '</div>';
		 cadena += '<div style="clear:both"></div>';
	}
	}
	document.getElementById("resto_habitaciones").innerHTML = cadena;
}


function validar_busqueda_hotel(formulario){
	destino = formulario.h_destino.value;
	error = "";

	if(destino == ""){
	  error += "Debe introducir un destino.\n";  
	}
	
	fentrada = formulario.h_fentrada.value;
	fsalida = formulario.h_fsalida.value;
	
	var aux_fentrada = fentrada.split("/");
    var dia_ent = parseInt(aux_fentrada[0],10);
    var mes_ent = parseInt(aux_fentrada[1],10);
    var anio_ent = parseInt(aux_fentrada[2],10);
  
  	var hoy = new Date();
  	var diaHoy = hoy.getDate();
	
  	var mesHoy = hoy.getMonth()+1;
  	var anioHoy = hoy.getYear();
  
	if(fentrada == ""){
		error += "Indique la fecha de ENTRADA AL HOTEL.\n";
	}else{
	   
	   if(mes_ent == mesHoy && anio_ent == anioHoy){
		   
		   if(dia_ent < diaHoy ){
			  
					  error+= "Fecha de ENTRADA AL HOTEL no v\u00E1lida \n";
		   } 
	   }
	}
	
	var aux_fsalida = fsalida.split("/");
    var dia_reg = parseInt(aux_fsalida[0],10);
    var mes_reg = parseInt(aux_fsalida[1],10);
    var anio_reg = parseInt(aux_fsalida[2],10);
	
	if(fsalida == ""){
	   error += "Indique la fecha de SALIDA DEL HOTEL.\n";
	}else{
		if(mes_reg == mesHoy && anio_reg == anioHoy){
			 if(dia_reg < diaHoy || dia_reg == diaHoy){
			  error += "Fecha de SALIDA DEL HOTEL no v\u00E1lida \n" ;
			 }  
		}
	}
	
	if(anio_ent > anio_reg){
		error += "Fechas no v\u00E1lidas.\n";
	}else{
	    if(anio_ent == anio_reg){
		  if(mes_ent > mes_reg){
			  error += "Fechas no v\u00E1lidas.\n";
		  }else{
		    if(mes_ent == mes_reg){
			  if(dia_ent > dia_reg){
				error += "Fechas no v\u00E1lidas.\n";  
			  }else{
			    if(dia_reg <= dia_ent ){
					error += "La fecha de SALIDA ha de ser mayor que la fecha de ENTRADA al hotel.\n"; 
				}
			  }
			}
		  }
		}
	}
	
	if(error == ""){
	  formulario.submit();
	}else{
	  alert(error);
	}
	
}



// Cookie handling 
    var Cookie =
    {
        read: function (name)
        {
            var arrCookies = document.cookie.split ('; ');
            for (var i=0; i<arrCookies.length; i++)
            {
                var arrCookie = arrCookies[i].split ('=');
                
                if (arrCookie[0] == name)
                {
                    return decodeURIComponent (arrCookie[1]);
                }
            }
            return false;
        },
    
        write: function (name, value, expires, path)
        {
            if (expires)
            {
                var date = new Date ();
                date.setTime (date.getTime () + (((((expires * 24) * 60) * 60) * 1000)));
                expires = '; expires=' + date.toGMTString ();
            }
            else expires = '';
    
            if (!path) path = '/';
    
            document.cookie = name+'='+encodeURIComponent (value)+expires+'; path='+path;
        },
    
        remove: function (name)
        {
            this.write (name, '', -1);
        }
    }
    
    // Detects if can set a cookie in the browser
    function browserSupportsCookies()
    {
        Cookie.write('cookiesEnabled', 1);
        var boolCookiesEnabled = Cookie.read('cookiesEnabled');
        Cookie.remove('cookiesEnabled');
        if (boolCookiesEnabled != 1)
        {
            return false;
        }
        return true;
    }
    
    // Detects if the browser supports Ajax 
    function browserSupportsAjax()
    {
        if (typeof XMLHttpRequest == "undefined" && typeof ActiveXObject == "undefined" && window.createRequest == "undefined")
        {
            return false;
        }
        return true
    }
    
    // Detects if the browser can use ActiveX if necessary
    function ActiveXEnabledOrUnnecessary ()
    {
        if (typeof ActiveXObject != "undefined")
        {
            var xhr = null;
            try{
                xhr=new ActiveXObject("Msxml2.XMLHTTP");
            }catch (e){
                try{
                    xhr=new ActiveXObject("Microsoft.XMLHTTP");
                }catch (e2){
                    try{
                        xhr=new ActiveXObject("Msxml2.XMLHTTP.4.0");
                    }catch (e3){
                        xhr=null;
                    }
                }
            }
            if (xhr == null)
            {
                return false
            }
        }
        
        return true;
    }

function abrir_ventana_gastos(tipo){
	Popup_gastos=window.open("http://www.ronda-hoteles.com/php/gastos_cancelacion.php?tipo="+tipo , "ventana_gastos" , "width=560,height=290,top=5, left=3,resizable=NO,directories=NO, location=NO, menubar=NO, status=NO,toolbar=NO,scrollbars=YES");
	
}
