var xmlHttp


function resultado_ficha(pos){
	document.getElementById('controlador').value=0;
	document.getElementById('hs').value=pos;
	document.form2.submit();
}


function resultado_ficha2(pos){
	parent.document.getElementById('controlador').value=0;
	parent.document.getElementById('hs').value=pos;
	parent.document.form2.submit();
}


function atras_ficha_resultado(){	
	document.form1.action="resultado.php";
	document.form1.submit();
}




function atras_datos(pos){
if (document.getElementById('controlador').value==0){
document.form1.action="ficha.php";
document.form1.submit();
}else{
document.form1.action="resultado.php";
document.form1.submit();
}

}

function seguir_de_ficha_reservar(pos,reg){	
document.getElementById('jf').value=pos;
document.getElementById('rg').value=reg;
document.form1.action="/Hoteles//Reservar-Hotel/";
document.form1.submit();
}


function top_home(destino,fechain,fechaout){
document.getElementById('destino').value=destino;
document.getElementById('fechain').value=fechain;
document.getElementById('fechaout').value=fechaout;
document.getElementById('habitas').value=1;
document.getElementById('adultos_room_1').value=2;
document.getElementById('adultos_room_1').value=0;
document.form1.submit();
}


function sel_zona(valor){
document.getElementById('previo-loader').style.display="";	
document.getElementById('filtro_zona').value=valor;
filtrar();
}

function ir_reservar(pos,reg){
	//alert(reg);
	document.getElementById('jf').value=pos;
	document.getElementById('rg').value=reg;	
	document.getElementById('hs').value=pos;
	document.getElementById('controlador').value=1;
	//document.form2.action="/Hoteles/Reservar-Hotel/";			
	document.form2.submit();
}




function filtrar(){
//document.getElementById('previo-loader').style.display="";	
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"
	var nor=1;
	url=url+"?filtrar_zona="+document.getElementById('filtro_zona').value+"&ahora="+nor+"&filtro_categoria="+document.getElementById('filtro_categoria').value
	url=url+"&filtro_regimen="+document.getElementById('filtro_regimen').value+"&filtro_servicio="+document.getElementById('filtro_servicio').value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('filtros'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)			
}

function sel_categoria(pos){

document.getElementById('previo-loader').style.display="";	
var nor=0;
if (document.getElementById(pos).checked){
	nor=1;
}else{
	nor=0;
} 
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }		 
	var url="/hoteles/hoteles.php"	 
	url=url+"?act_hidden_cate="+pos+"&tipo_act="+nor+"&hidden="+document.getElementById('filtro_categoria').value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('actu'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)	
}


function sel_regimen(pos){
document.getElementById('previo-loader').style.display="";	
var nor=0;
if (document.getElementById(pos).checked){
	nor=1;
}else{
	nor=0;
} 
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"	 
	url=url+"?act_hidden_regi="+pos+"&tipo_act="+nor+"&hidden="+document.getElementById('filtro_regimen').value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('actu'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)	
}


function sel_servicio(pos){
document.getElementById('previo-loader').style.display="";	
var nor=0;
if (document.getElementById(pos).checked){
	nor=1;
}else{
	nor=0;
} 
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"	 
	url=url+"?act_hidden_serv="+pos+"&tipo_act="+nor+"&hidden="+document.getElementById('filtro_servicio').value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('actu'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)	
}



function mostrarDatosOcupacion(id_casa){
             
document.getElementById('hd-efecto'+id_casa).style.display = 'block';
}

function ocultarDatosOcupacion(id_casa){           
document.getElementById('hd-efecto'+id_casa).style.display = 'none';             
}

		 
function pintar_servicios(){
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"
	var nor=1;
	url=url+"?pintarservicios="+nor
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('pintando_serv'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
}


function pintar_regimen(){
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"
	var nor=1;
	url=url+"?pintarregimen="+nor
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('pintando_reg'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
}

function pintar_zonas(){
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"
	url=url+"?pintarzonas=1"
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('pintando_zona'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
}


function pintar_categorias(){
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"
	var nor=1;
	url=url+"?pintarcategorias="+nor
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('pintando_cat'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
}
function abrirPopUp_Mapa(lat,lon,pos){
  $("#popup_mapa").fadeIn("slow");  
  xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }	
	var url="/hoteles/hoteles.php"
	url=url+"?gmapaslat="+lat+"&gmapaslon="+lon+"&pos="+pos
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('mostrarMapahotelPopUp'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)	
}

function cerrarPopUp_Mapa(){
          $("#popup_mapa").fadeOut("slow");
}


function muestra_precios(pos){
  var temp="otros-precios"+pos;   
  var open="abrir-precios"+pos;  
  if(document.getElementById('muestras').value==0){  
	document.getElementById(temp).style.display="";
	document.getElementById('muestras').value=temp;	 
	document.getElementById(open).className="cerrar-precios";  	 
	document.getElementById('abril_cerral').value=open;
  }else{
   var tt=document.getElementById('muestras').value;   
   var tete=document.getElementById('abril_cerral').value;   
    if (tt!=temp){		
			//document.getElementById(tete).className="abrir-precios";  	
			document.getElementById('abril_cerral').value=open;			
			document.getElementById(temp).style.display="";
			document.getElementById(open).className="cerrar-precios";  
			var tt=document.getElementById('muestras').value;
			//document.getElementById(tt).style.display="none";   
			document.getElementById('muestras').value=temp; 		
	 }else{	 	
		if 	 (document.getElementById(temp).style.display==""){		
			document.getElementById(temp).style.display="none";
			document.getElementById('muestras').value=temp; 
			document.getElementById(open).className="abrir-precios";  			
		}else{	
			document.getElementById(temp).style.display="";
			document.getElementById('muestras').value=temp; 
			document.getElementById(open).className="cerrar-precios";  			
		}
			  	
	 }
  }	    
 
}

function situar_gmaps(){
 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	document.getElementById('previo-loader').style.display="";
	document.getElementById('mapa-listado').style.display="none";
	document.getElementById('listado-listado').style.display="";
	var url="/hoteles/hoteles.php"
	url=url+"?gmaps=1"
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('meter_gmaps'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
}

function sel_noches(noches){
	if ((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){	
		var noches=document.getElementById('fechaout2').value;
		xmlHttp=GetXmlHttpObject()  
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="/hoteles/hoteles.php"
		url=url+"?noches="+noches+"&fecha="+document.getElementById('fechain2').value
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=function(){ stateChanged_div('ajax_fecha_salida'); };
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)		
	}
}

function sel_ninos(ninos){
//if(ninos>0){


	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	
	document.getElementById('edades_ninos').innerHTML="<img src='cargando-precios.gif' /> ";
	var url="/hoteles/hoteles.php"
	url=url+"?ninos="+ninos+"&tothabitaciones="+document.getElementById('habitas2').value+"&confihabitas="+document.getElementById('confihabitas').value+"&bul="+document.getElementById('bulfirst').value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('edades_ninos'); };
	//alert("aa");
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)		
	document.getElementById('bulfirst').value=2;
//}
}


function sel_ninos_home(ninos){
//alert("aa");
//if(ninos>0){
	
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
		
	//document.getElementById('edades_ninos').innerHTML="<img src='ajax-loader.gif' /> ";
	var url="/hoteles/hoteles.php"
	//var url="/hoteles/hoteles.php"
	url=url+"?ninoshome="+ninos+"&tothabitaciones="+document.getElementById('habitas').value
	url=url+"&sid="+Math.random()
	//alert(ninos);
	//alert(document.getElementById('habitas').value);
	//alert(url);
	xmlHttp.onreadystatechange=function(){ stateChanged_div('edades_ninos'); };
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)	

//}
}


function sel_num_hab(){

//if(ninos>0){
	
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
		
	//document.getElementById('edades_ninos').innerHTML="<img src='ajax-loader.gif' /> ";
	var url="/hoteles/hoteles.php"
	//var url="/hoteles/hoteles.php"
	url=url+"?tothabitaciones="+document.getElementById('habitas').value+"&ninos1="+document.getElementById('ninos_room_1').value+"&ninos2="+document.getElementById('ninos_room_2').value+"&ninos3="+document.getElementById('ninos_room_3').value+"&ninos4="+document.getElementById('ninos_room_4').value+"&ninos5="+document.getElementById('ninos_room_5').value+"&adultos1="+document.getElementById('adultos_room_1').value+"&adultos2="+document.getElementById('adultos_room_2').value+"&adultos3="+document.getElementById('adultos_room_3').value+"&adultos4="+document.getElementById('adultos_room_4').value+"&adultos5="+document.getElementById('adultos_room_5').value
	url=url+"&sid="+Math.random()
	//alert(ninos);
	//alert(document.getElementById('habitas').value);
	//alert(url);
	xmlHttp.onreadystatechange=function(){ stateChanged_div('ocupacion-habitaciones'); };
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)	
//alert("aa");
//}
}


function sel_edad_1(){

//if(ninos>0){
	
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
		
	//document.getElementById('edades_ninos').innerHTML="<img src='ajax-loader.gif' /> ";
	var url="/hoteles/hoteles.php"
	//var url="/hoteles/hoteles.php"
	url=url+"?tothabitaciones="+document.getElementById('habitas').value+"&ninos1="+document.getElementById('ninos_room_1').value+"&ninos2="+document.getElementById('ninos_room_2').value+"&ninos3="+document.getElementById('ninos_room_3').value+"&ninos4="+document.getElementById('ninos_room_4').value+"&ninos5="+document.getElementById('ninos_room_5').value+"&adultos1="+document.getElementById('adultos_room_1').value+"&adultos2="+document.getElementById('adultos_room_2').value+"&adultos3="+document.getElementById('adultos_room_3').value+"&adultos4="+document.getElementById('adultos_room_4').value+"&adultos5="+document.getElementById('adultos_room_5').value
	url=url+"&sid="+Math.random()
	//alert(ninos);
	//alert(document.getElementById('habitas').value);
	//alert(url);
	xmlHttp.onreadystatechange=function(){ stateChanged_div('ocupacion-habitaciones'); };
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)	
//alert("aa");
//}
}



function sel_ninos_home2(ninos){
//alert("aa");
//if(ninos>0){
	
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
		
	//document.getElementById('edades_ninos').innerHTML="<img src='ajax-loader.gif' /> ";
	//var url="hoteles/hoteles.php"
	var url="/hoteles/hoteles.php"
	url=url+"?ninoshome="+ninos+"&tothabitaciones="+document.getElementById('habitas').value
	url=url+"&sid="+Math.random()
	//alert(ninos);
	//alert(document.getElementById('habitas').value);
	//alert(url);
	xmlHttp.onreadystatechange=function(){ stateChanged_div('edades_ninos'); };
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)	

//}
}

/**BUSCADOR DEL GESTOR**/
function buscar_gestor_hoteles(){
if ((document.getElementById('fechain').value!="")&&(document.getElementById('fechaout').value!="")&&(document.getElementById('hotel_oferta').value!="")&&(document.getElementById('hotel_destino').value!="")){
  alert("ok");
}else{
alert("Debe seleccionar todos los datos, gracias");
}
	
}


function buscador_hoteles(){
if ((document.getElementById('nombre_hotel').value=="")){

	alert("Debe introducir el nombre de un hotel");
}else{
  document.buscador_hoteles.submit();
  }

	
}


/**BUSCADOR DE LA HOME**/
function buscar_home(){
if ((document.getElementById('fechain').value!="")&&(document.getElementById('fechaout').value!="")){
if ((document.getElementById('fechain').value==document.getElementById('fechaout').value)){
	alert("Las fechas deben ser distintas, gracias");
}else{
  document.form1.submit();
  }
}else{
alert("Debe seleccionar fechas, gracias");
}
	
}

/**BUSCADOR DE RESULTADO.PHP**/
function buscar_resultados(){
if ((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){
if ((document.getElementById('fechain2').value==document.getElementById('fechaout2').value)){
	alert("Las fechas deben ser distintas, gracias");
}else{
	//	document.getElementById('ninos').value=document.getElementById('ninos2').value;
	//document.getElementById('destino').value=document.getElementById('destino2').value;
	//document.getElementById('fechain').value=document.getElementById('fechain2').value;
	//document.getElementById('fechaout').value=document.getElementById('fechaout2').value;
	//document.getElementById('habitas').value=document.getElementById('habitas2').value;
//	document.getElementById('adultos').value=document.getElementById('adultos2').value;
//	document.getElementById('ninos').value=document.getElementById('ninos2').value; 
	  
  document.form1.submit();
  }
}else{
alert("Debe seleccionar fechas, gracias");
}
	
}




function buscar_hotel_2(){
//alert('estoy aki');	
if (document.getElementById('fechain2').value!=document.getElementById('fechaout2').value){
if((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){
document.getElementById('filtro_categoria').value="";
document.getElementById('filtro_regimen').value="";
document.getElementById('filtro_servicio').value="";
/*busqueda para 1 hotel concreto*/
var solito="1";
document.getElementById('filtro_zona').value="-1";
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var destino=document.getElementById('destino2').value;	 	 	 
	 var entrada=document.getElementById('fechain2').value;
	 var noches=document.getElementById('fechaout2').value;	 
	 var habitas=document.getElementById('habitas2').value;
	 confihabitas=0;

 
	 
	  var confihabitas=document.getElementById('habitas2').value+'*';
	 	for (i=1; i<=document.getElementById('habitas2').value; i++){
			confihabitas=confihabitas+document.getElementById('adultos_room_'+i).value+';';
			if(document.getElementById('ninos_room_'+i).value){
			for (u=1; u<=document.getElementById('ninos_room_'+i).value; u++){
		 
		 		confihabitas=confihabitas+document.getElementById('edad_'+i+'_room_'+u).value+';';
			}
			}else{
				confihabitas=confihabitas+'0;';
			}
			confihabitas=confihabitas+'*';
		 }
/*	
	 var toted="";	  
	 if (document.getElementById('ninos2').value>0){
		for (i=1; i<=document.getElementById('habitas2').value; i++){		
			var ted="";
				for (u=1; u<=document.getElementById('ninos2').value; u++){
					var temp="edad"+i+u;				
					if (u==1){
						ted=document.getElementById(temp).value+'*';
					}else{
						ted=ted+document.getElementById(temp).value+'*';
					}
				}
				if (i==1){
					toted=ted+'|';
				}else{
					toted=toted+ted+'|';
				}
		}
		 tempconfhabitas=tempconfhabitas+'|'+toted;
	 }	*/
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;
	document.getElementById('destino').value=document.getElementById('destino2').value;
	document.getElementById('fechain').value=document.getElementById('fechain2').value;
	document.getElementById('fechaout').value=document.getElementById('fechaout2').value;
//	document.getElementById('habitas').value=document.getElementById('habitas2').value;
//	document.getElementById('adultos').value=document.getElementById('adultos2').value;
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;    
	
	alert(destino);
	alert(entrada);
	alert(confihabitas);
	alert(noches);
	
	
	
	var noches_loading=noches;	
		
	document.getElementById('loading_noches').innerHTML=noches_loading;
	document.getElementById('loading_salida').innerHTML=entrada;
	fragmentoTexto=document.getElementById('destino2').value.split('*');	 	
	document.getElementById('loading_destino').innerHTML=fragmentoTexto[3];
	document.getElementById('loading_destino2').innerHTML=fragmentoTexto[3];
	document.getElementById('previo-loader').style.display="";	
	var url="/hoteles/hoteles.php"	
	url=url+"?destinob="+destino+"&entradab="+entrada+"&nochesb="+noches+"&tempconfhabitas="+confihabitas+"&solito="+solito
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function(){ stateChanged_div('col-info'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
	

	
}else{
alert("Debe seleccionar fechas");
}
}else{
alert("Debe seleccionar fechas diferentes");
}
}

function buscar_hotel_rango(){
//alert('estoy aki');	
if (document.getElementById('fechain2').value!=document.getElementById('fechaout2').value){
if((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){
document.getElementById('filtro_categoria').value="";
document.getElementById('filtro_regimen').value="";
document.getElementById('filtro_servicio').value="";
/*busqueda para 1 hotel concreto*/
var solito="1";
document.getElementById('filtro_zona').value="-1";
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var destino=document.getElementById('destino2').value;	 	 	 
	 var entrada=document.getElementById('fechain2').value;
	 var noches=document.getElementById('fechaout2').value;	 
	 var confihabitas=document.getElementById('confihabitas').value;
	 var maximo=document.getElementById('precio_maximo').value;	 
	 var minimo=document.getElementById('precio_minimo').value;	 
	 	 	 
/*	 var tempconfhabitas=document.getElementById('habitas2').value+'*'+document.getElementById('adultos2').value+'*'+document.getElementById('ninos2').value+'*';
	 var toted="";	  
	 if (document.getElementById('ninos2').value>0){
		for (i=1; i<=document.getElementById('habitas2').value; i++){		
			var ted="";
				for (u=1; u<=document.getElementById('ninos2').value; u++){
					var temp="edad"+i+u;				
					if (u==1){
						ted=document.getElementById(temp).value+'*';
					}else{
						ted=ted+document.getElementById(temp).value+'*';
					}
				}
				if (i==1){
					toted=ted+'|';
				}else{
					toted=toted+ted+'|';
				}
		}
		 tempconfhabitas=tempconfhabitas+'|'+toted;
	 }	*/
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;
	document.getElementById('destino').value=document.getElementById('destino2').value;
	document.getElementById('fechain').value=document.getElementById('fechain2').value;
	document.getElementById('fechaout').value=document.getElementById('fechaout2').value;
//	document.getElementById('habitas').value=document.getElementById('habitas2').value;
//	document.getElementById('adultos').value=document.getElementById('adultos2').value;
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;    
	
	var noches_loading=noches;	
		
	document.getElementById('loading_noches').innerHTML=noches_loading;
	document.getElementById('loading_salida').innerHTML=entrada;
	fragmentoTexto=document.getElementById('destino2').value.split('*');	 	
	document.getElementById('loading_destino').innerHTML=fragmentoTexto[3];
	document.getElementById('loading_destino2').innerHTML=fragmentoTexto[3];
	document.getElementById('previo-loader').style.display="";	
	var url="/hoteles/hoteles.php"	
	url=url+"?destinob="+destino+"&entradab="+entrada+"&nochesb="+noches+"&tempconfhabitas="+confihabitas+"&solito="+solito+"&maximo="+maximo+"&minimo="+minimo
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function(){ stateChanged_div('col-info'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
	

	
}else{
alert("Debe seleccionar fechas");
}
}else{
alert("Debe seleccionar fechas diferentes");
}
}


function buscar_hotel(){
//alert('estoy aki');	
if (document.getElementById('fechain2').value!=document.getElementById('fechaout2').value){
if((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){
document.getElementById('filtro_categoria').value="";
document.getElementById('filtro_regimen').value="";
document.getElementById('filtro_servicio').value="";
/*busqueda para 1 hotel concreto*/
var solito="1";
document.getElementById('filtro_zona').value="-1";
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var destino=document.getElementById('destino2').value;	 	 	 
	 var entrada=document.getElementById('fechain2').value;
	 var noches=document.getElementById('fechaout2').value;	 
	 var confihabitas=document.getElementById('confihabitas').value;	 	 
/*	 var tempconfhabitas=document.getElementById('habitas2').value+'*'+document.getElementById('adultos2').value+'*'+document.getElementById('ninos2').value+'*';
	 var toted="";	  
	 if (document.getElementById('ninos2').value>0){
		for (i=1; i<=document.getElementById('habitas2').value; i++){		
			var ted="";
				for (u=1; u<=document.getElementById('ninos2').value; u++){
					var temp="edad"+i+u;				
					if (u==1){
						ted=document.getElementById(temp).value+'*';
					}else{
						ted=ted+document.getElementById(temp).value+'*';
					}
				}
				if (i==1){
					toted=ted+'|';
				}else{
					toted=toted+ted+'|';
				}
		}
		 tempconfhabitas=tempconfhabitas+'|'+toted;
	 }	*/
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;
	document.getElementById('destino').value=document.getElementById('destino2').value;
	document.getElementById('fechain').value=document.getElementById('fechain2').value;
	document.getElementById('fechaout').value=document.getElementById('fechaout2').value;
//	document.getElementById('habitas').value=document.getElementById('habitas2').value;
//	document.getElementById('adultos').value=document.getElementById('adultos2').value;
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;    
	
	var noches_loading=noches;	
		
	document.getElementById('loading_noches').innerHTML=noches_loading;
	document.getElementById('loading_salida').innerHTML=entrada;
	fragmentoTexto=document.getElementById('destino2').value.split('*');	 	
	document.getElementById('loading_destino').innerHTML=fragmentoTexto[3];
	document.getElementById('loading_destino2').innerHTML=fragmentoTexto[3];
	document.getElementById('previo-loader').style.display="";	
	var url="/hoteles/hoteles.php"	
	url=url+"?destinob="+destino+"&entradab="+entrada+"&nochesb="+noches+"&tempconfhabitas="+confihabitas+"&solito="+solito
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function(){ stateChanged_div('col-info'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
	

	
}else{
alert("Debe seleccionar fechas");
}
}else{
alert("Debe seleccionar fechas diferentes");
}
}


function buscar_un_hotel(){
//alert('estoy aki');	
if (document.getElementById('fechain2').value!=document.getElementById('fechaout2').value){
if((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){
document.getElementById('filtro_categoria').value="";
document.getElementById('filtro_regimen').value="";
document.getElementById('filtro_servicio').value="";
/*busqueda para 1 hotel concreto*/
var solito="1";
document.getElementById('filtro_zona').value="-1";
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var destino="1*IBZ*IBZ*Todo Ibiza";	 	 	 
	 var entrada=document.getElementById('fechain2').value;
	 var noches=document.getElementById('fechaout2').value;	 
	 var confihabitas=document.getElementById('confihabitas').value;	
	 var id=document.getElementById('id_hotel').value; 	 
/*	 var tempconfhabitas=document.getElementById('habitas2').value+'*'+document.getElementById('adultos2').value+'*'+document.getElementById('ninos2').value+'*';
	 var toted="";	  
	 if (document.getElementById('ninos2').value>0){
		for (i=1; i<=document.getElementById('habitas2').value; i++){		
			var ted="";
				for (u=1; u<=document.getElementById('ninos2').value; u++){
					var temp="edad"+i+u;				
					if (u==1){
						ted=document.getElementById(temp).value+'*';
					}else{
						ted=ted+document.getElementById(temp).value+'*';
					}
				}
				if (i==1){
					toted=ted+'|';
				}else{
					toted=toted+ted+'|';
				}
		}
		 tempconfhabitas=tempconfhabitas+'|'+toted;
	 }	*/
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;
	document.getElementById('destino').value=document.getElementById('destino2').value;
	document.getElementById('fechain').value=document.getElementById('fechain2').value;
	document.getElementById('fechaout').value=document.getElementById('fechaout2').value;
//	document.getElementById('habitas').value=document.getElementById('habitas2').value;
//	document.getElementById('adultos').value=document.getElementById('adultos2').value;
//	document.getElementById('ninos').value=document.getElementById('ninos2').value;    
	
	var noches_loading=noches;	
		
	document.getElementById('loading_noches').innerHTML=noches_loading;
	document.getElementById('loading_salida').innerHTML=entrada;
	fragmentoTexto=document.getElementById('destino2').value.split('*');	 	
	document.getElementById('loading_destino').innerHTML=fragmentoTexto[3];
	document.getElementById('loading_destino2').innerHTML=fragmentoTexto[3];
	document.getElementById('previo-loader').style.display="";	
	var url="/hoteles/hoteles.php"	
	url=url+"?destinob="+destino+"&entradab="+entrada+"&nochesb="+noches+"&tempconfhabitas="+confihabitas+"&id_hotel="+id
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function(){ stateChanged_div('col-info'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
	

	
}else{
alert("Debe seleccionar fechas");
}
}else{
alert("Debe seleccionar fechas diferentes");
}
}


function buscar_hotel_old(){
	
if (document.getElementById('fechain2').value!=document.getElementById('fechaout2').value){
if((document.getElementById('fechain2').value!="")&&(document.getElementById('fechaout2').value!="")){
document.getElementById('filtro_categoria').value="";
document.getElementById('filtro_regimen').value="";
document.getElementById('filtro_servicio').value="";
/*busqueda para 1 hotel concreto*/
var solito="1";
document.getElementById('filtro_zona').value="-1";
	 xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var destino=document.getElementById('destino2').value;	 	 	 
	 var entrada=document.getElementById('fechain2').value;
	 var noches=document.getElementById('fechaout2').value;	 	 
	 var tempconfhabitas=document.getElementById('habitas2').value+'*'+document.getElementById('adultos2').value+'*'+document.getElementById('ninos2').value+'*';
	 var toted="";	  
	 if (document.getElementById('ninos2').value>0){
		for (i=1; i<=document.getElementById('habitas2').value; i++){		
			var ted="";
				for (u=1; u<=document.getElementById('ninos2').value; u++){
					var temp="edad"+i+u;				
					if (u==1){
						ted=document.getElementById(temp).value+'*';
					}else{
						ted=ted+document.getElementById(temp).value+'*';
					}
				}
				if (i==1){
					toted=ted+'|';
				}else{
					toted=toted+ted+'|';
				}
		}
		 tempconfhabitas=tempconfhabitas+'|'+toted;
	 }	
	document.getElementById('ninos').value=document.getElementById('ninos2').value;
	document.getElementById('destino').value=document.getElementById('destino2').value;
	document.getElementById('fechain').value=document.getElementById('fechain2').value;
	document.getElementById('fechaout').value=document.getElementById('fechaout2').value;
	document.getElementById('habitas').value=document.getElementById('habitas2').value;
	document.getElementById('adultos').value=document.getElementById('adultos2').value;
	document.getElementById('ninos').value=document.getElementById('ninos2').value;    
	
	var noches_loading=noches;	
		
	document.getElementById('loading_noches').innerHTML=noches_loading;
	document.getElementById('loading_salida').innerHTML=entrada;
	fragmentoTexto=document.getElementById('destino2').value.split('*');	 	
	document.getElementById('loading_destino').innerHTML=fragmentoTexto[3];
	document.getElementById('loading_destino2').innerHTML=fragmentoTexto[3];
	document.getElementById('previo-loader').style.display="";	
	var url="/hoteles/hoteles.php"	
	url=url+"?destinob="+destino+"&entradab="+entrada+"&nochesb="+noches+"&tempconfhabitas="+tempconfhabitas+"&solito="+solito
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function(){ stateChanged_div('col-info'); };
	xmlHttp.open("GET",url,true)	
	xmlHttp.send(null)		
	

	
}else{
alert("Debe seleccionar fechas");
}
}else{
alert("Debe seleccionar fechas diferentes");
}
}

function busca_precios_ws(mes,dia,ano){
xmlHttp=GetXmlHttpObject() 
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var temp="";	
 var adult="";
 var fin="";
 var totadult=0;
	for (i=1; i<=document.getElementById('selecthabitas').value; i++){
		var temp="adulto"+i;				
		if (document.getElementById(temp).value==0){
			adult="";
		}
		if (document.getElementById(temp).value==1){
			adult="A";
			totadult=totadult+1;
		}
		if (document.getElementById(temp).value==2){
			adult="AA";
			totadult=totadult+2;
		}
		if (document.getElementById(temp).value==3){
			adult="AAA";
			totadult=totadult+3;
		}
		if (document.getElementById(temp).value==4){
			adult="AAAA";
			totadult=totadult+4;
		}
		if (i==1){
			fin=adult;
		}else{
			fin=fin+'*'+adult;
		}
	} 	
document.getElementById('calendario-precios').innerHTML="<br>";
document.getElementById('conf-alojamientos').innerHTML="<img src='cargando-precios.gif' /> ";
var url="swsviajes.php"
url=url+"?mesbuscador="+mes+"&dia="+dia+"&origen="+document.getElementById('ciudadsalida').value+"&destino="+document.getElementById('destinosw').value+"&ano="+ano+"&noches="+document.getElementById('noches').value+"&confhabitas="+fin+"&totadult="+totadult
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div('conf-alojamientos'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function blanco(imagen) {       
imagen.src="foto-plantilla.jpg";   
}  

function ges_calcular_precio_final(){
 			 var pbasecontrol="";
 			 var bases=0;
	 		 base=parseInt(bases);
  			  var temp="pfinalbase"+'0';
  			  var i=0;
	   			for (i=0; i<document.getElementById('total_hoteles').value; i++){
	   			     var temp="pfinalbase"+i;
					if(i==0){
						pbasecontrol=document.getElementById(temp).value+'*';
						base=base+parseInt(document.getElementById(temp).value);
					}else{
	   					pbasecontrol=pbasecontrol+document.getElementById(temp).value+'*';
	   					base=base+parseInt(document.getElementById(temp).value);
					}
	   		   }
	   		 /*opciones*/
	   		 	fragmentoTexto=document.getElementById('seguimiento_opt').value.split('|');
				var tama=fragmentoTexto.length;
				 tama--;
	   			 var popcioncontrol="";
	   			 	var temp="pfinalopcion"+1;
	   			for (i=1; i<=tama; i++){
		   				var u=i-1;
					if (fragmentoTexto[+u]!="-1"){
	   			     var temp="pfinalopcion"+i;
						if(i==1){
							popcioncontrol=document.getElementById(temp).value+'*';
							base=base+parseInt(document.getElementById(temp).value);
						}else{
		   					popcioncontrol=popcioncontrol+document.getElementById(temp).value+'*';
		   						base=base+parseInt(document.getElementById(temp).value);
						}
					}
	   		   	}
	   		   	
	   			/*suplementos*/
	   		 var psuplementocontrol="";
	   		for (i=1; i<=document.getElementById('seguimiento_totsup').value; i++){
	   			     var temp="pfinalsuple"+i;
					if(i==1){
						psuplementocontrol=document.getElementById(temp).value+'*';
							base=base+parseInt(document.getElementById(temp).value);
					}else{
	   					psuplementocontrol=psuplementocontrol+document.getElementById(temp).value+'*';
	   							base=base+parseInt(document.getElementById(temp).value);
					}
	   	   	}
	   	   	document.getElementById('pfinal').value=base;
	   	   	  xmlHttp=GetXmlHttpObject()
					 if (xmlHttp==null) {
					 	alert ("Browser does not support HTTP Request")
					 	return
					 }
					document.getElementById('pfinalmuestra').innerHTML="<img src='ajax-loader.gif' /> ";
					document.getElementById('onlylookimporte').value=base;
					var url="gestor.php"
					url=url+"?preciofinalcambiado="+base
					url=url+"&sid="+Math.random()
					xmlHttp.onreadystatechange=function(){ stateChanged_div('pfinalmuestra'); };
					xmlHttp.open("GET",url,true)
					xmlHttp.send(null)

}


function reserva_cambia_destino(destino,u){
 xmlHttp=GetXmlHttpObject()
 if (destino>0){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var divs="alojamientos_cambiados"+u;

document.getElementById(divs).innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?id_destino_nuevo="+destino+"&alojas="+u
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div(divs); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}

function reserva_actualiza_precio(pos,precio){
 xmlHttp=GetXmlHttpObject()
 if (destino>0){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var divs="alojamientos_cambiados"+u;

document.getElementById(divs).innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?id_destino_nuevo="+destino+"&alojas="+u
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div(divs); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}


function reserva_cambia_destino(destino,u){
 xmlHttp=GetXmlHttpObject()
 if (destino>0){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var divs="alojamientos_cambiados"+u;

document.getElementById(divs).innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?id_destino_nuevo="+destino+"&alojas="+u
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div(divs); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}


function ges_muestra_viajeros(viajeros,idpaquete,tothoteles,noches,fechain,salida){
	if (viajeros>0){
 xmlHttp2=GetXmlHttpObject()
 if (xmlHttp2==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('viajarosal').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?viajantes="+viajeros+"&elide="+document.getElementById('id_reserva_mod').value,
url=url+"&sid="+Math.random()
if (idpaquete>0){
reserva_nueva_manual_info(idpaquete,tothoteles,viajeros,noches,fechain,salida);
}
xmlHttp2.onreadystatechange=function(){ stateChanged_div2('viajarosal'); };
xmlHttp2.open("GET",url,true)
xmlHttp2.send(null)
}
}



function reserva_nueva_manual_info(idpaquete,tothoteles,personas,noches,fechain,salida){
 xmlHttp=GetXmlHttpObject()
 if (idpaquete>0){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
  	var idmod=document.getElementById('id_reserva_mod').value;
	document.getElementById('info_ajax_nueva').innerHTML="<img src='ajax-loader.gif' /> ";
	var url="gestor.php"
	url=url+"?idpaquete_nueva="+idpaquete+"&totalhoteles="+tothoteles+"&personas="+personas+"&nochesa="+noches+"&fechaina="+fechain+"&ciudadsalida="+salida+"&idmod="+idmod
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function(){ stateChanged_div('info_ajax_nueva'); };
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
 }else{
    fragmentoTexto = idpaquete.split('*');
    if (fragmentoTexto[0]=="-2"){//nieve
	    document.getElementById('info_ajax_nueva').innerHTML="<img src='ajax-loader.gif' /> ";
		var url="gestor.php"
		url=url+"?idpaquete_nueva="+fragmentoTexto[1]+"&totalhoteles="+tothoteles+"&personas="+personas+"&nochesa="+noches+"&fechaina="+fechain+"&ciudadsalida="+salida+"&esnieve="+1
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=function(){ stateChanged_div('info_ajax_nueva'); };
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
    }
	else{
		document.getElementById('info_ajax_nueva').innerHTML="<img src='ajax-loader.gif' /> ";
		var url="gestor.php"
		url=url+"?idpaquete_nueva="+idpaquete+"&totalhoteles="+tothoteles+"&personas="+personas+"&nochesa="+noches+"&fechaina="+fechain+"&ciudadsalida="+salida+"&noexiste="+1
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=function(){ stateChanged_div('info_ajax_nueva'); };
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
    }
 }
}


function enviar_confirmacion_reserva(str,str2){
 xmlHttp=GetXmlHttpObject()
 if (str>0){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('envi').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?ideconfirmas="+str
url=url+"&sid="+Math.random()+"&emilioconfirma="+str2
xmlHttp.onreadystatechange=function(){ stateChanged_div('envi'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}
function enviar_confirmacion(str,str2){
 xmlHttp=GetXmlHttpObject()
 if (str>0){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviando').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?ideconfirma="+str
url=url+"&sid="+Math.random()+"&testoconfirma="+str2
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviando'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}
function guada_time_ajax(str,str2){
 xmlHttp=GetXmlHttpObject()
 if ((str>0)&&(str2!="")){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('timeguardado').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?identreser="+str
url=url+"&sid="+Math.random()+"&testo="+str2
xmlHttp.onreadystatechange=function(){ stateChanged_div('timeguardado'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}

function enviar_bono(str){
xmlHttp=GetXmlHttpObject()
 if (str!=""){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviar-bono').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservabono="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviar-bono'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}

function enviar_bono_nieve(str){
 xmlHttp=GetXmlHttpObject()
 if (str!=""){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviar-bono').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservabononieve="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviar-bono'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}

function enviar_bono_escapada(str){
 xmlHttp=GetXmlHttpObject()
 if (str!=""){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviar-bono').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservabonoescapada="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviar-bono'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
 
}

function enviar_bono_soltour(str){
 xmlHttp=GetXmlHttpObject()
 if (str!=""){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviar-bono').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservabonosoltour="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviar-bono'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
 
}
function enviar_bono_playa(str){
 xmlHttp=GetXmlHttpObject()
 if (str!=""){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviar-bono').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservabonoplaya="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviar-bono'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
 
}
function guardar_localizador(str,str2){
 xmlHttp=GetXmlHttpObject()
 if ((str>0)&&(str2!="")){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('proveedor').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservasid="+str
url=url+"&sid="+Math.random()+"&loca_prov="+str2
xmlHttp.onreadystatechange=function(){ stateChanged_div('proveedor'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}

function cambiar_estado(str,str2,str3,str4){
 xmlHttp=GetXmlHttpObject()
 if (str3<12){
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('estados').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservas="+str
url=url+"&sid="+Math.random()+"&estado="+str2+"&estado_old="+str3
xmlHttp.onreadystatechange=function(){ stateChanged_div_url('estados',str2); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }else{
    
    if(document.getElementById('pvp_proveedor').value>0){
    if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('estados').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservas="+str
url=url+"&sid="+Math.random()+"&estado="+str2+"&estado_old="+str3+"&tiporeserva="+str4

xmlHttp.onreadystatechange=function(){ stateChanged_div_url('estados',str2); };

xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 	}else{
 	    alert("Debes introducir pvp proveedor");
 	}
 }
  
}

function enviar_recibo(str,str2,str3,str4,str5,str6){
 xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('enviar_email').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?localizador="+str
url=url+"&sid="+Math.random()+"&texto="+str2+"&fecha="+str3+"&hora="+str4+"&recibo="+str5+"&tipo="+str6
xmlHttp.onreadystatechange=function(){ stateChanged_div('enviar_email'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function sumar_pago(str,str2,str3,str4,str5,str6,str7,str8){

 	if((str!="")&&(str!="0")&&(str4>0)&&(str6>0)&&(str5!="")){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 var bul=0;
 if (str7<str4){
    bul=1;
    if (confirm("Cuidado,el importe es superior al pendiente")){
		bul=0
        }
 }
 if (bul==0){
document.getElementById('ajaxpago').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?idreserva="+str
url=url+"&sid="+Math.random()+"&idagente="+str2+"&notas="+str3+"&cantidad="+str4+"&fechain="+str5+"&mpago="+str6
xmlHttp.onreadystatechange=function(){ stateChanged_div_url('ajaxpago',str8); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
 }
}else{
	alert("Faltan datos");
}
}

function mod_pago(str,str2,str3,str4,str5,str6,str7,str8,str9){
	if((str!="")&&(str!="0")&&(str4>0)&&(str6>0)){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('ajaxpago').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?idreservamod="+str
url=url+"&sid="+Math.random()+"&idagentemod="+str2+"&notas="+str3+"&cantidadmod="+str4+"&fechain="+str5+"&mpago="+str6+"&recibo="+str7+"&msg="+str8+"&locata="+str9
xmlHttp.onreadystatechange=function(){ stateChanged_div('ajaxpago'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}else{
	alert("Faltan datos");
}
}

function alta(str,str2){
	if((str!="")&&(str!="0")){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('listado-agentes').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?nombre="+str
url=url+"&sid="+Math.random()+"&pass="+str2
xmlHttp.onreadystatechange=function(){ stateChanged_div('listado-agentes'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
}


function asignar(str){
	if((str!="")&&(str!="0")){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('ajax-asignar').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reserva="+69
url=url+"&sid="+Math.random()+"&agentes="+str
xmlHttp.onreadystatechange=function(){ stateChanged_div('ajax-asignar'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
}

function asignar2(str,str2,str3,str4){
	if((str!="")&&(str!="0")){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
document.getElementById('cambio-asigno').innerHTML="<img src='ajax-loader.gif' /> ";
var url="gestor.php"
url=url+"?reservame="+69
url=url+"&sid="+Math.random()+"&ides="+str+"&secretos="+str2+"&older="+str3+"&histo="+str4
xmlHttp.onreadystatechange=function(){ stateChanged_div('cambio-asigno'); };
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
}


function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("ajax").innerHTML=xmlHttp.responseText
 }
}


function stateChanged_div(div){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        document.getElementById(div).innerHTML=xmlHttp.responseText;

        //Si hi ha javascript a la resposta l'executem
        var searchElement = document.getElementById(div);
        searchElement.innerHTML=xmlHttp.responseText;
        var scripts = searchElement.getElementsByTagName('script');
        for (var i=0;i<scripts.length;i++) {
            eval(scripts[i].innerHTML);
        }
    }
}
function stateChanged_div_url(div,estado){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        document.getElementById(div).innerHTML=xmlHttp.responseText;

        //Si hi ha javascript a la resposta l'executem
        var searchElement = document.getElementById(div);
        searchElement.innerHTML=xmlHttp.responseText;
        var scripts = searchElement.getElementsByTagName('script');
        for (var i=0;i<scripts.length;i++) {
            eval(scripts[i].innerHTML);
        }
	      if (estado==1){
             document.location.href='asignar.php';
        }
          if ((estado>1)&&(estado<9)){
             document.location.href='asignadas.php';
        }
          if ((estado>=9)&&(estado<12)){
             document.location.href='aceptadas.php';
        }
          if ((estado>=12)&&(estado<14)){
             document.location.href='confirmadas.php';
        }
          if (estado==14){
             document.location.href='expediente.php';
        }
    }
}
function stateChanged_div_final(div){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        document.getElementById(div).innerHTML=xmlHttp.responseText;

        //Si hi ha javascript a la resposta l'executem
        var searchElement = document.getElementById(div);
        searchElement.innerHTML=xmlHttp.responseText;
        var scripts = searchElement.getElementsByTagName('script');
        for (var i=0;i<scripts.length;i++) {
            eval(scripts[i].innerHTML);
        }
       document.location.href='aceptadas.php';
    }
}
function stateChanged_div2(div){
    if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete"){
        document.getElementById(div).innerHTML=xmlHttp2.responseText;

        //Si hi ha javascript a la resposta l'executem
        var searchElement = document.getElementById(div);
        searchElement.innerHTML=xmlHttp2.responseText;
        var scripts = searchElement.getElementsByTagName('script');
        for (var i=0;i<scripts.length;i++) {
            eval(scripts[i].innerHTML);
        }
    }
}


function stateChanged_div3(div){
    if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete"){
        document.getElementById(div).innerHTML=xmlHttp3.responseText;

        //Si hi ha javascript a la resposta l'executem
        var searchElement = document.getElementById(div);
        searchElement.innerHTML=xmlHttp3.responseText;
        var scripts = searchElement.getElementsByTagName('script');
        for (var i=0;i<scripts.length;i++) {
            eval(scripts[i].innerHTML);
        }
    }
}



function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

