// JavaScript Document

function GetXmlHttpObject()
{ 
	var objXMLHttp1=null

	if (window.XMLHttpRequest)
	{
		objXMLHttp1=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp1=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp1
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function limpaCampos()
{
document.formBusca.pais.value='';
document.formBusca.estado.value='';
document.formBusca.hotel.value='';
}

function exibeListaCompleta(tipo,pais)
{
	
	tipo=getCheckedValue(tipo);
	xmlHttp1Lista=GetXmlHttpObject()
	if (xmlHttp1Lista==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="ajax_listacompleta.php?tipo="+tipo+"&pais="+pais+"&rand="+new Date().getTime()+Math.random();
//	alert (url);
	xmlHttp1Lista.onreadystatechange=stateChangedLista
	xmlHttp1Lista.open("GET",url,true)
	xmlHttp1Lista.send(null)
}

function exibeTarifas(checkin,checkout,acompadultos,acompmenores12,acompmenores5,hotel)
{

	xmlHttp1Res=GetXmlHttpObject()
	if (xmlHttp1Res==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="checaReserva.php?checkin="+checkin+"&checkout="+checkout+"&acompadultos="+acompadultos+"&acompmentores12="+acompmenores12+"&acompmenores5="+acompmenores5+"&hotel="+hotel+"&rand="+new Date().getTime()+Math.random();
	xmlHttp1Res.onreadystatechange=stateChangedRes
	xmlHttp1Res.open("GET",url,true)
	xmlHttp1Res.send(null)
}


function stateChangedLista() 
{ 
	
    if (xmlHttp1Lista.readyState == 4) 
	{
      
        	if (xmlHttp1Lista.status == 200) 
			{
              	document.getElementById('ajdivlistacompleta').innerHTML = xmlHttp1Lista.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp1Lista.statusText);
       		}
    }
	else
	{
		//document.getElementById('foto').innerHTML='<p align="center"><br /><br /><br /><br /><br /><br /><img src="js/loader.gif"></p>';
	}		
}

function stateChangedRes() 
{ 
	
    if (xmlHttp1Res.readyState == 4) 
	{
      
        	if (xmlHttp1Res.status == 200) 
			{
              	document.getElementById('tarifas').innerHTML = xmlHttp1Res.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp1Res.statusText);
       		}
    }
	else
	{
		document.getElementById('tarifas').innerHTML='<p align="center"><img src="js/loader.gif"></p>';
	}		
}


function mudaFoto(img)
{
	
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="exibeFoto.php?img="+img+"&rand="+new Date().getTime()+Math.random();
	xmlHttp1.onreadystatechange=stateChangedft
	xmlHttp1.open("GET",url,true)
	xmlHttp1.send(null)
}

function stateChangedft() 
{ 
	
    if (xmlHttp1.readyState == 4) 
	{
      
        	if (xmlHttp1.status == 200) 
			{
              	document.getElementById('foto').innerHTML = xmlHttp1.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp1.statusText);
       		}
    }
	else
	{
		//document.getElementById('foto').innerHTML='<p align="center"><br /><br /><br /><br /><br /><br /><img src="js/loader.gif"></p>';
	}		
}

function exibeTexto(hotel,texto, trid, tipo, pacoteid)
{
	

	xmlHttp1txt=GetXmlHttpObject()
	if (xmlHttp1txt==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="exibeTexto.php?hotel="+hotel+"&texto="+texto+"&trid="+trid+"&tipo="+tipo+"&pacoteid="+pacoteid+"&rand="+new Date().getTime()+Math.random();
	xmlHttp1txt.onreadystatechange=stateChangedtxt
	xmlHttp1txt.open("GET",url,true)
	xmlHttp1txt.send(null)
}

function stateChangedtxt() 
{ 
	
    if (xmlHttp1txt.readyState == 4) 
	{
      
        	if (xmlHttp1txt.status == 200) 
			{
              	document.getElementById('conteudohotel').innerHTML = xmlHttp1txt.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp1txt.statusText);
       		}
    }
	else
	{
		document.getElementById('conteudohotel').innerHTML='<p align="center"><img src="js/loader.gif"></p>';
	}		
}

function exibeestado(pais,estado,tipo)
{
	tipo=getCheckedValue(tipo);
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	}  
	var url="ajax_estado.php"
	url=url+"?pais="+pais+"&estado="+estado+"&tipo="+tipo+"&rand="+new Date().getTime()+Math.random();
	xmlHttp1.onreadystatechange=stateChangedest
	xmlHttp1.open("GET",url,true)
	xmlHttp1.send(null)
}

function stateChangedest() 
{ 
	 
    if (xmlHttp1.readyState == 4) 
	{
      
        	if (xmlHttp1.status == 200) 
			{
              	document.getElementById('ajdivestado').innerHTML = xmlHttp1.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp1.statusText);
       		}
    }
	else
	{
		document.getElementById('ajdivestado').innerHTML='';
	}		
}

function exibehotel(pais,estado,hotel,tipo)
{
	tipo=getCheckedValue(tipo);

xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	}  
	var url="ajax_hotel.php"
	url=url+"?pais="+pais+"&estado="+estado+"&hotel="+hotel+"&tipo="+tipo+"&rand="+new Date().getTime()+Math.random();
	//alert(url);
	xmlHttp2.onreadystatechange=stateChangedhotel
	xmlHttp2.open("GET",url,true)
	xmlHttp2.send(null)
}

function stateChangedhotel() 
{ 
	 
    if (xmlHttp2.readyState == 4) 
	{
      
        	if (xmlHttp2.status == 200) 
			{
              	document.getElementById('ajdivhotel').innerHTML = xmlHttp2.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp2.statusText);
       		}
    }
	else
	{
		document.getElementById('ajdivhotel').innerHTML='';
	}		
}


//Parte de reservas

function exibeestado2(pais,estado)
{
	xmlHttp12=GetXmlHttpObject()
	if (xmlHttp12==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	}  
	var url="ajax_estado2.php"
	url=url+"?pais2="+pais+"&estado2="+estado+"&rand="+new Date().getTime()+Math.random();
	xmlHttp12.onreadystatechange=stateChangedest2
	xmlHttp12.open("GET",url,true)
	xmlHttp12.send(null)
}

function stateChangedest2() 
{ 
	 
    if (xmlHttp12.readyState == 4) 
	{
      
        	if (xmlHttp12.status == 200) 
			{
              	document.getElementById('ajdivestado2').innerHTML = xmlHttp12.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp12.statusText);
       		}
    }
	else
	{
		document.getElementById('ajdivestado2').innerHTML='';
	}		
}
function exibehotel2(pais,estado,hotel)
{
	xmlHttp23=GetXmlHttpObject()
	if (xmlHttp23==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	}  
	var url="ajax_hotelcmi.php"
	url=url+"?pais2="+pais+"&estado2="+estado+"&hotel2="+hotel+"&rand="+new Date().getTime()+Math.random();
	//alert(url);
	xmlHttp23.onreadystatechange=stateChangedhotel2
	xmlHttp23.open("GET",url,true)
	xmlHttp23.send(null)
}

function stateChangedhotel2() 
{ 
	 
    if (xmlHttp23.readyState == 4) 
	{
      
        	if (xmlHttp23.status == 200) 
			{
              	document.getElementById('ajdivhotel2').innerHTML = xmlHttp23.responseText;
			}
			
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp23.statusText);
       		}
    }
	else
	{
		document.getElementById('ajdivhotel2').innerHTML='';
	}		
}


function cadastro(str)
{

	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
		var url="ajax_cadastro.php"
		url=url+"?rand="+new Date().getTime()+"&pref="+str+"&"+Math.random(); 
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
}

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

function exibeParceriaExclusiva(str)
{
	document.getElementById("AcessoEspecial").style.visibility="visible";
	
	xmlHttp=GetXmlHttpObject()

		var url="ajax_login_especial.php";
		url=url+"?tp="+str+"&rand="+new Date().getTime()+"&"+Math.random(); 
		xmlHttp.onreadystatechange=stateChangedEspecial
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
}

function stateChangedEspecial() 
{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	    document.getElementById("AcessoEspecial").innerHTML=xmlHttp.responseText; 
	} 
} 
