// JavaScript Document
function trocou_forma_pg( valor )
{

	if(valor == 'Boleto_Bancario') // boleto
	{
		document.getElementById('informar_cartao').style.display = 'none';
	}
	else // cartao
	{
		document.getElementById('informar_cartao').style.display = 'block';
	}
}

function GetXmlHttpObject()
{ 
	var objXMLHttp1=null

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

function calcula_pontos( valor, pontos_do_cliente, pontos_do_produto, url2 )
{
	//tipo=getCheckedValue(tipo);
	xmlHttpPontos=GetXmlHttpObject()
	if (xmlHttpPontos==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	}
	if(parseFloat(valor) <= parseFloat(pontos_do_produto))
	{
		//alert(valor);
		//alert(pontos_do_produto);
		var qtde_que_falta = parseFloat(pontos_do_produto) - parseFloat(valor);
		var valor_que_falta = qtde_que_falta*0.02;
		document.getElementById('valor_que_falta').value = valor_que_falta;
		//alert(document.getElementById('valor_que_falta').value)
	}
	else
	{
		document.getElementById('valor_que_falta').value = 0;
		document.getElementById('qtde_pontos_gastos').value = pontos_do_produto;
	}
	var url = url2+"ajax_calcula_pontos.php?valor="+valor+"&pontos_do_cliente="+pontos_do_cliente+"&pontos_do_produto="+pontos_do_produto+"&rand="+new Date().getTime()+Math.random();
	//alert (url);
	xmlHttpPontos.onreadystatechange=stateChangedPontos
	xmlHttpPontos.open("GET",url,true)
	xmlHttpPontos.send(null)
}

function stateChangedPontos() 
{
    if (xmlHttpPontos.readyState == 4) 
	{
        	if (xmlHttpPontos.status == 200) 
			{
              	document.getElementById('div_ajax_calcula_pontos').innerHTML = xmlHttpPontos.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 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 exibeTarifas(checkin,checkout,acompadultos,acompmenores12,acompmenores5,hotel,idade1,idade2,idade3,idade4,idade5,cminet)
{


	xmlHttp1Res=GetXmlHttpObject()
	if (xmlHttp1Res==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	
	if(cminet=="S")
	{
	var url="checaReserva.php?checkin="+checkin+"&checkout="+checkout+"&acompadultos="+acompadultos+"&acompmentores12="+acompmenores12+"&acompmenores5="+acompmenores5+"&hotel="+hotel+"&idade1="+idade1+"&idade2="+idade2+"&idade3="+idade3+"&idade4="+idade4+"&idade5="+idade5+"&rand="+new Date().getTime()+Math.random();
	}
	else
	{
	var url="checaReservaBD.php?checkin="+checkin+"&checkout="+checkout+"&acompadultos="+acompadultos+"&acompmentores12="+acompmenores12+"&acompmenores5="+acompmenores5+"&hotel="+hotel+"&idade1="+idade1+"&idade2="+idade2+"&idade3="+idade3+"&idade4="+idade4+"&idade5="+idade5+"&rand="+new Date().getTime()+Math.random();
	}

	xmlHttp1Res.onreadystatechange=stateChangedRes
	xmlHttp1Res.open("GET",url,true)
	xmlHttp1Res.send(null)
}


function checaForm(checkin,checkout,acompadultos,acompmenores12,acompmenores5,hotel,cminet)
{
	if (document.frmReserva.acompmenores12.value == 1)
	{
		var idade1 = document.getElementById("idade1").value;
		if (idade1 == "")
		{
			alert ("Preencha todas as idades.");
			return false;
		}
	}
	
	if (document.frmReserva.acompmenores12.value == 2)
	{
		var idade1 = document.getElementById("idade1").value;
		var idade2 = document.getElementById("idade2").value;
		
		if (idade1 == "" || idade2 == "")
		{
			alert ("Preencha todas as idades.");
			return false;			
		}
	}
	
	if (document.frmReserva.acompmenores12.value == 3)
	{
		var idade1 = document.getElementById("idade1").value;
		var idade2 = document.getElementById("idade2").value;
		var idade3 = document.getElementById("idade3").value;
		
		if (idade1 == "" || idade2 == "" || idade3 == "")
		{
			alert ("Preencha todas as idades.");
			return false;			
		}
		
	}
	
	if (document.frmReserva.acompmenores12.value == 4)
	{
		var idade1 = document.getElementById("idade1").value;
		var idade2 = document.getElementById("idade2").value;
		var idade3 = document.getElementById("idade3").value;
		var idade4 = document.getElementById("idade4").value;
		
		if (idade1 == "" || idade2 == "" || idade3 == "" || idade4 == "")
		{
			alert ("Preencha todas as idades.");
			return false;			
		}
		
	}
	
	if (document.frmReserva.acompmenores12.value == 5)
	{
		var idade1 = document.getElementById("idade1").value;
		var idade2 = document.getElementById("idade2").value;
		var idade3 = document.getElementById("idade3").value;
		var idade4 = document.getElementById("idade4").value;
		var idade5 = document.getElementById("idade5").value;
		
		if (idade1 == "" || idade2 == "" || idade3 == "" || idade4 == "" || idade5 == "")
		{
			alert ("Preencha todas as idades.");
			return false;			
		}
	}
	
	exibeTarifas(checkin,checkout,acompadultos,acompmenores12,acompmenores5,hotel,idade1,idade2,idade3,idade4,idade5,cminet);
	
	
}

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

function stateChangedLista() 
{ 
	
    if (xmlHttp1Lista.readyState == 4) 
	{
      
        	if (xmlHttp1Lista.status == 200) 
			{
              	document.getElementById('ajdivhotel').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 mudaFoto2(img)
{
	xmlHttpFoto2=GetXmlHttpObject()
	if (xmlHttpFoto2==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="exibeFoto2.php?img="+img+"&rand="+new Date().getTime()+Math.random();
	xmlHttpFoto2.onreadystatechange=stateChangedFoto2
	xmlHttpFoto2.open("GET",url,true)
	xmlHttpFoto2.send(null)
}

function stateChangedFoto2() 
{
    if (xmlHttpFoto2.readyState == 4) 
	{
        	if (xmlHttpFoto2.status == 200) 
			{
              	document.getElementById('foto').innerHTML = xmlHttpFoto2.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, lang, tipo, pacoteid)
{
	xmlHttp1txt=GetXmlHttpObject()
	if (xmlHttp1txt==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="http://www.circuitoelegante.com.br/exibeTexto.php?hotel="+hotel+"&texto="+texto+"&lang="+lang+"&tipo="+tipo+"&pacoteid="+pacoteid+"&rand="+new Date().getTime()+Math.random();

	//alert(url); 
	xmlHttp1txt.onreadystatechange=stateChangedtxt
	xmlHttp1txt.open("GET",url,true)
	xmlHttp1txt.send(null)
}

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

function exibeestado(pais,estado,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();
	//alert (url);
	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 exibeSegmento(tipo)
{
	xmlHttpSegmento=GetXmlHttpObject()
	if (xmlHttpSegmento==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	}  
	var url="ajax_segmento.php"
	url=url+"?tipo="+tipo+"&rand="+new Date().getTime()+Math.random();
	xmlHttpSegmento.onreadystatechange=stateChangedSegmento
	xmlHttpSegmento.open("GET",url,true)
	xmlHttpSegmento.send(null)
}

function stateChangedSegmento() 
{
    if (xmlHttpSegmento.readyState == 4) 
	{
        	if (xmlHttpSegmento.status == 200) 
			{
              	document.getElementById('ajdivsegmento').innerHTML = xmlHttpSegmento.responseText;
			}
			else 
			{
            	//alert("Houve um problema ao obter os dados:\n" + xmlHttp1.statusText);
       		}
    }
	else
	{
		document.getElementById('ajdivsegmento').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 cadastro2(str)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
		var url="ajax_cadastro_novo.php"
		url=url+"?rand="+new Date().getTime()+"&lev="+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; 
	} 
} 


function exibeCamposIdade(qtd,idade1,idade2,idade3,idade4,idade5)
{
		xmlHttpCamposIdade=GetXmlHttpObject()

		var url="ajax_campos_idade.php";
		url=url+"?qtd="+qtd+"&idade1="+idade1+"&idade2="+idade2+"&idade3="+idade3+"&idade4="+idade4+"&idade5="+idade5+"&rand="+new Date().getTime()+"&"+Math.random(); 
		
		//alert(url);
		
		xmlHttpCamposIdade.onreadystatechange=stateChangedCamposIdade
		xmlHttpCamposIdade.open("GET",url,true)
		xmlHttpCamposIdade.send(null)
}

function stateChangedCamposIdade() 
{
	if (xmlHttpCamposIdade.readyState==4 || xmlHttpCamposIdade.readyState=="complete")
	{ 
	    document.getElementById("divCamposIdade").innerHTML=xmlHttpCamposIdade.responseText; 
	} 
	
	else
	{
		document.getElementById('divCamposIdade').innerHTML='<div align="left"><img src="js/load-peq.gif"></div>';
	}	
} 


function exibeVideo(video)
{
		xmlHttpVideo=GetXmlHttpObject()

		var url="ajax_video.php";
		url=url+"?video="+video+"&rand="+new Date().getTime()+"&"+Math.random(); 
		
		//alert(url);
		
		xmlHttpVideo.onreadystatechange=stateChangedVideo
		xmlHttpVideo.open("GET",url,true)
		xmlHttpVideo.send(null)
}

function stateChangedVideo() 
{
	if (xmlHttpVideo.readyState==4 || xmlHttpVideo.readyState=="complete")
	{ 
	    document.getElementById("ajaxVideo").innerHTML=xmlHttpVideo.responseText; 
	}
	else
	{
		document.getElementById('ajaxVideo').innerHTML='<div align="left"><img src="js/load-peq.gif"></div>';
	}	
} 


function casado(resp)
{
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	{
		alert ("Sem suporte a HTTP Request")
		return
	} 
	var url="ajax_casado.php?resp="+resp+"&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('casado').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>';
	}		
}
