if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
	widthCheck = window.innerWidth;
	heightCheck = window.innerHeight;
	window.onResize = resizeFix;
}

function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href;
}

var isNew=0;
var isNS4=0;
var isIE4=0;
var brow= ((navigator.appName)+(parseInt(navigator.appVersion)));
if (parseInt(navigator.appVersion >=5)) {
isNew=1}
else if (brow=="Netscape4")
{isNS4 = 1;}
else if(brow=="Microsoft Internet Explorer4")
{isIE4=1;}

docObj=(isNS4)?'document' :'document.all';
styleObj= (isNS4)?'':'.style';

function lyroff(currElem){
	dom= eval(docObj+'.'+currElem+styleObj);
	state = dom.visibility;
	if(state=="visible" || state=="show"){dom.visibility="hidden";}
}

function lyron(currElem){
	dom=eval(docObj+'.'+currElem+styleObj);
	state=dom.visibility;
	if(state=="hide" || state=="hidden"){dom.visibility="visible"};
}

function alterNate(elm){
if (!elm.base) elm.base = elm.value
if (elm.value == elm.base) elm.value = "";
else if (elm.value == "") elm.value = elm.base;
}

function checkmail(str)
{
	var filter = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	if (filter.test(str))
	{
		return true;
	}
	else
	{
		alert("O e-mail digitado não é válido!")
		return false;
	}
}


function openpopup(url, width, height, scrollbars){
window.open(url,"","toolbar=no,status=no,menubar=no,scrollbars=" + scrollbars + "top=10,left=10,width=" + width + ",height=" + height)
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// <!-- função validação dos campos
function checkFields(radioObj) {
missinginfo = "";

	if(!radioObj)
		temp = "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			temp = radioObj.value;
		else
			temp = "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			temp = radioObj[i].value;
		}
	}
	
	switch(temp){
		case "pacotes":
		if (document.formulario.nac_int.value == "nacionais") {
			if ((document.formulario.uf.value == "") && (document.formulario.cidade.value == "")){
				if (document.formulario.rapida_nac.value == ""){
					missinginfo += "\n     -  Estado/Cidade ou Busca Rápida";
				}
			}
		}else {
			if((document.formulario.pais.value == "") && (document.formulario.internacional_cidade.value == "")) {
				if (document.formulario.rapida_int.value == ""){
					missinginfo += "\n     -  País/Cidade ou Busca Rápida";
				}
			}		
		}
		break;
		case "cruzeiros":
		if(document.formulario.cruzeiro_destino.value == "") {
			if (document.formulario.rapida_cru.value == ""){
				missinginfo += "\n     -  Destino ou Busca Rápida";
			}
		}
		break;	
		case "hoteis":
		if(document.formulario.hotel.value == "") {
			if (document.formulario.rapida_hot.value == ""){
				missinginfo += "\n     -  Nome do Hotel ou Busca Rápida";
			}
		}
		break;	
		case "carros":
		if(document.formulario.carro.value == "") {
			if (document.formulario.rapida_car.value == ""){
				missinginfo += "\n     -  Nome do Carro ou Busca Rápida";
			}
		}
		break;	
		case "trens":
		if(document.formulario.trem.value == "") {
			if (document.formulario.rapida_trem.value == ""){
				missinginfo += "\n     -  Nome do Trem ou Busca Rápida";
			}
		}
		break;	
		case "ingressos":
		if(document.formulario.ingresso.value == "") {
			if (document.formulario.rapida_ing.value == ""){
				missinginfo += "\n     -  Nome da Atração ou Busca Rápida";
			}
		}
		break;			
	}
	
	if (missinginfo != "") {
		missinginfo = "Por favor preencha os seguintes campos:\n" + missinginfo +
		"\n\n_____________________________\n";
		alert(missinginfo);
		return false;
	}
	else {
		return true;
	}
}
// --> 

// <!-- função validação dos campos
function checkAdm() {
missinginfo = "";
	if (document.form_admin.tp_pacote.value == "") {
		document.form_admin.tp_pacote.style.backgroundColor = "#FFBFBF";
		missinginfo += "\n     -  Tipo de Produto";	
	}else {
		document.form_admin.tp_pacote.style.backgroundColor = "#fff";	
	}
	
	if (document.form_admin.nm_pacote.value == "") {
		document.form_admin.nm_pacote.style.backgroundColor = "#FFBFBF";
		missinginfo += "\n     -  Nome do Produto";	
	}else {
		document.form_admin.nm_pacote.style.backgroundColor = "#fff";	
	}
	if (document.form_admin.nm_pais.value == "") {
		document.form_admin.nm_pais.style.backgroundColor = "#FFBFBF";		
		missinginfo += "\n     -  País(es)";		
	}else {
		document.form_admin.nm_pais.style.backgroundColor = "#fff";	
	}
	if (document.form_admin.url.value == "") {
		document.form_admin.url.style.backgroundColor = "#FFBFBF";			
		missinginfo += "\n     -  URL do produto";		
	}else {
		document.form_admin.url.style.backgroundColor = "#fff";	
	}
	
	if (missinginfo != "") {
		missinginfo = "Por favor preencha os seguintes campos:\n" + missinginfo +
		"\n\n_____________________________\n";	
		alert(missinginfo);	
		return false;
	}
	else {
			if ((document.form_admin.nm_pais.value.search(/ e /i) == -1) && (document.form_admin.nm_cidade.value.search(/ e /i) == -1))
			{
				return true;
			}
			else
			{
				if (confirm('Só é permitida a inserção de países e cidades separados por vírgulas simples (,). Se seu cadastramento for um  nome composto, clique em "OK" para confirmar ou "CANCELAR" para consertar.'))
					return true;	
				else
					return false;		
			}
		}
}
// --> 

function testPassword(passwd)
{
		var intScore   = 0
		var strVerdict = "weak"
		var strLog     = ""
		
		// PASSWORD LENGTH
		if (passwd.length<5)                         // length 4 or less
		{
			intScore = (intScore+3)
			strLog   = strLog + "3 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>4 && passwd.length<8) // length between 5 and 7
		{
			intScore = (intScore+6)
			strLog   = strLog + "6 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>7 && passwd.length<16)// length between 8 and 15
		{
			intScore = (intScore+12)
			strLog   = strLog + "12 points for length (" + passwd.length + ")\n"
		}
		else if (passwd.length>15)                    // length 16 or more
		{
			intScore = (intScore+18)
			strLog   = strLog + "18 point for length (" + passwd.length + ")\n"
		}
		
		
		// LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
		if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
		{
			intScore = (intScore+1)
			strLog   = strLog + "1 point for at least one lower case char\n"
		}
		
		if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one upper case char\n"
		}
		
		// NUMBERS
		if (passwd.match(/\d+/))                                 // [verified] at least one number
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one number\n"
		}
		
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least three numbers\n"
		}
		
		
		// SPECIAL CHAR
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least one special char\n"
		}
		
									 // [verified] at least two special characters
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{
			intScore = (intScore+5)
			strLog   = strLog + "5 points for at least two special chars\n"
		}
	
		
		// COMBOS
		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))        // [verified] both upper and lower case
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for upper and lower letters\n"
		}

		if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for letters and numbers\n"
		}
 
									// [verified] letters, numbers, and special characters
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{
			intScore = (intScore+2)
			strLog   = strLog + "2 combo points for letters, numbers and special chars\n"
		}
	
	
		if(intScore < 16)
		{
		   strVerdict = "very weak"
		}
		else if (intScore > 15 && intScore < 25)
		{
		   strVerdict = "weak"
		}
		else if (intScore > 24 && intScore < 35)
		{
		   strVerdict = "mediocre"
		}
		else if (intScore > 34 && intScore < 45)
		{
		   strVerdict = "strong"
		}
		else
		{
		   strVerdict = "stronger"
		}
		
	return intScore;
	/*
	document.forms.passwordForm.score.value = (intScore)
	document.forms.passwordForm.verdict.value = (strVerdict)
	document.forms.passwordForm.matchlog.value = (strLog)
	*/
}

function checaSenha(senha)
{
	var strVerdict = "muito fraco";
	var strLog     = "";
	var intScore = testPassword(senha);
	if(intScore < 5)
	{
	   strVerdict = "muito fraco";
	   document.getElementById('barra').className = 'pass_bar_base pass_bar_10 pass_bar_color_1';
	   document.getElementById('resultado').innerHTML = strVerdict;

	}
	else if(intScore > 5 && intScore < 16)
	{
	   strVerdict = "fraco";
	   document.getElementById('barra').className = 'pass_bar_base pass_bar_30 pass_bar_color_2';
	   document.getElementById('resultado').innerHTML = strVerdict;
	}
	else if (intScore > 15 && intScore < 25)
	{
	   strVerdict = "médio";
	   document.getElementById('barra').className = 'pass_bar_base pass_bar_40 pass_bar_color_2';
	   document.getElementById('resultado').innerHTML = strVerdict;
	}
	else if (intScore > 24 && intScore < 35)
	{
	   strVerdict = "médio";
	   document.getElementById('barra').className = 'pass_bar_base pass_bar_60 pass_bar_color_3';
	   document.getElementById('resultado').innerHTML = strVerdict;
	}
	else if (intScore > 34 && intScore < 45)
	{
		strVerdict = "forte";
		document.getElementById('barra').className = 'pass_bar_base pass_bar_80 pass_bar_color_3';
	   document.getElementById('resultado').innerHTML = strVerdict;
	}
	else
	{
	   strVerdict = "muito forte";
	   document.getElementById('barra').className = 'pass_bar_base pass_bar_100 pass_bar_color_3';
	   document.getElementById('resultado').innerHTML = strVerdict;
	}
	//alert(strVerdict);
}

//Função para alternar entre tipo de destinos
function ExibirDIV(div) {
	//--*-> Ocultar todas as DIV's...
	if ((div != "pac") && (div != "nacionais") && (div != "internacionais")){
		OcultarDIV("pac");
		OcultarDIV("nacionais");
		OcultarDIV("internacionais");		
		document.getElementById("nac_int").selectedIndex = 0;
	}
	if (div == "internacionais")
		OcultarDIV("nacionais");
	if (div == "nacionais")
		OcultarDIV("internacionais");
		
	OcultarDIV("cruzeiros");	
	OcultarDIV("trens");
	OcultarDIV("ingressos");
	OcultarDIV("carros");
	OcultarDIV("hoteis");
	//--*-> Exibir a DIV escolhida...
	if (div == "pac")
		document.getElementById("nacionais").style.display = "block";	
	document.getElementById(div).style.display = "block";
}

function OcultarDIV(aux)
{
	document.getElementById(aux).style.display = "none";
}

//Select pra busca
function qryDestino(destino)
{
	if (destino == 'nac_uf') document.getElementById("nac_cidade").disabled = false;
	if (destino == 'pais') document.getElementById("internacional_cidade").disabled = false;	
}

function organiza(qry){
	document.location.href = 'index2.php?url=resultado_busca&filtro='+qry;
}