/*** CHAMA EM TODAS AS DEFAULTS ***********/
	var sUrl = "";
	/* metodo jquery que monta o carregando e tb a parte que fecha*/
	$().ajaxStart(function() {
		$.blockUI({ message: "Carregando...",
			css: { border: 'none', padding: '15px', backgroundColor: '#000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .8, color: '#fff' },
			overlayCSS: { backgroundColor: '' },
			baseZ: 999999
		});
	});
	$().ajaxStop(function() { $.unblockUI(); });// fecha o url com o carregando
/*****************************************/

function fRemoveRoteiro(reserva, site, plano, plano_corrente){
	$("#mostraCarrinho").load("../../func/roteiro/limpaRoteiro.asp?reserva="+ reserva +"&site="+site+"&plano="+plano,function(){
		if(plano == plano_corrente){
			location.replace("default.asp");
		}
	});
	carregaTela();
}

function EnviarEmail(titulo){
	$("#divEnviaEmail").load("../../func/portal/emailSite.asp?titulo="+encodeURIComponent(titulo), function(){
		$("#divEnviaEmail").show();																										
	});
}

function fOcultaTxtCampo(campo, evento, texto) {
	//alert('valor do campo: ' + campo.value);
	//alert('evento: ' + evento);
	//alert('texto: ' + texto);
	if (evento == 'focus') {
		campo.focus();
		if (campo.value == texto) {
			campo.value = "";
		}
	} else if (evento == 'blur') {
		if (campo.value == '') {
			campo.value = texto;
		}
	}
}
//Chama página retornaHtmlEmailRecomende.asp  que retorna da função de banco  [FN_RETORNA_HTML_RECOMENDE_SITE] o html
function EnviaEmailRecomende(divRetorno, nomeRem, emailRem) {
    var vURLEmail = "";
    vURLEmail = "../../func/portal/retornaHtmlEmailRecomende.asp?sDe="+encodeURIComponent(document.getElementById('recomendeNome').value);
    $.ajax({
        type: "GET",
        url: vURLEmail,
        success: function(html){
             $("#ChamaFuncao")
                .empty()
                .append(EmailPortalGenerico(nomeRem, document.getElementById('recomendeEmail').value, emailRem, document.getElementById('recomendeEmail').value, 'Indica&ccedil;&atilde;o de Site', html, divRetorno));
        },
        error: function(httpRequest, textStatus, errorThrown){    		
            $("#ChamaFuncao")
                .empty()
                .append(AlertarUsuario2('E-mail n&atilde;o pode ser enviado'))
        }
    });
}


//Envia email genérico através da procedure  stp_Tour_EnviaEmail_Generico.
function EmailPortalGenerico (sDeNome,sParaNome,sDeEmail,sParaEmail,sAssunto,sCorpo,sRetornoDiv){
    var vURLEmail = "";
    vURLEmail = "../../func/portal/EnviaEmailGenerico.asp?sNome="+encodeURIComponent(sDeNome)+"&sEmail="+encodeURIComponent(sParaNome);
    vURLEmail += "&sDeEmail="+encodeURIComponent(sDeEmail)+"&sParaEmail="+encodeURIComponent(sParaEmail);
    vURLEmail += "&sAssunto=" + encodeURIComponent(sAssunto) + "&sCorpo=" + encodeURIComponent(sCorpo);
    $.ajax({
        type: "POST",
        url: vURLEmail,
        success: function(html){
             $(sRetornoDiv)
                .empty()
                .append(AlertarUsuario2(html))
        },
        error: function(httpRequest, textStatus, errorThrown){    		
            $(sRetornoDiv)
                .empty()
                .append(AlertarUsuario2('E-mail n&atilde;o pode ser enviado'))
        }
    });	
}

function EnviaEmail_Imprime(titulo, tipo, semcabecalho) {
    if (semcabecalho == null) {
        semcabecalho = '';
    }
	$("#divEnviaEmail").load("../../func/portal/emailSite.asp?SEMCABECALHO="+semcabecalho+"&titulo="+encodeURIComponent(titulo)+"&tipo="+tipo, function(){
		$("#divEnviaEmail").show();																										
	});
}

// JavaScript Document
function f_Alert(campo, msgAlert){

	$("#mostraAlerta").load("../../func/portal/alert.asp?msgAlert="+encodeURIComponent(msgAlert), function(){
		$.unblockUI();// fecha o url com o carregando
		$("#mostraAlerta").show();
		if(campo != ""){
			campo.style.background = "#FFFF99";
			campo.style.fontWeight = "bold";
			campo.focus();
		}
	});
}

function f_AlertOK(msg, altura, largura, funcao) {
    var texto = '';
    texto +=  '<div id="alertaUsuario">';
    texto +=  '  <table border="0" width="100%" height="120px">';
    texto +=  '     <tr>';
    texto +=  '        <td rowspan="2" style="width:50px; text-align:center; vertical-align:middle">';
    texto +=  '           <img src="../../func/imagens/alert_icon.png" />';
    texto +=  '        </td>';
    texto +=  '        <td style="text-align:left; vertical-align:middle;height:80px">';
    texto +=  '           <BR>' + msg + '';
    texto +=  '        </td>';
    texto +=  '     </tr>';
    texto +=  '     <tr>';
    texto +=  '        <td style="text-align:right; vertical-align:bottom;height:10px">';
    texto +=  '           <a href=javascript:$.modal.close();' + funcao + '><img border="0" src="../../func/imagens/btn_ok.png" /></a>';
    //texto +=  '			  <a href=javascript:$.modal.close();' + funcao + ' class="modalCloseImg" title="Close"></a>';    
    texto +=  '        </td>';
    texto +=  '     </tr>';
    texto +=  '  </table>';
    texto += '</div>';
    
    if (altura == null || altura == '')
        altura = 120;
    if (largura == null || largura == '')
        largura = 370;
        
    document.getElementById("mostraAlerta").innerHTML = texto;
    $(texto).modal({
        overlayCss: {
            backgroundColor: '#222',
            cursor: 'wait'
        }
        ,containerCss: {
            height: altura,
            width: largura,
            backgroundColor: '#000',
            border: '1px solid #ccc',
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: .8,
            color: '#fff'
        }
		,closeHTML:'<a href="javascript:void(0)" onClick="$.modal.close();' + funcao + ';" class="modalCloseImg" title="FECHAR"></a>'
        ,autoResize: true
        ,zIndex: 999990
        ,escClose: false
		
    });

}

function f_AlertEXEC(msg, altura, largura, funcaoOk, funcaoCancel) {
    if (funcaoCancel == null)
        funcaoCancel = '';
        
		var texto = '';
		texto = texto + '<div id="alertaUsuario">';
		texto = texto + '	<table border="0" width="100%" height="120px">';
		texto = texto + '		<tr>';
		texto = texto + '			<td rowspan="2" style="width:50px; text-align:center; vertical-align:middle">';
		texto = texto + '				<img src="../../func/imagens/alert_icon.png" />';
		texto = texto + '			</td>';
		texto = texto + '			<td style="text-align:left; vertical-align:middle;height:80px">';
		texto = texto + '				<BR>'+msg+'';
		texto = texto + '			</td>';
		texto = texto + '		</tr>';
		texto = texto + '		<tr>';
		texto = texto + '			<td style="text-align:right; vertical-align:bottom;height:10px">';
		texto = texto + '				<a href=javascript:$.modal.close();' + funcaoOk + '><img border="0" src="../../func/imagens/btn_ok.png" /></a>';
		texto = texto + '				<a href=javascript:$.modal.close();' + funcaoCancel + '><img border="0" src="../../func/imagens/btn_cancelar.gif" /></a>';
		//texto = texto + '				<a href=javascript:$.modal.close();' + funcaoCancel + ' class="modalCloseImg" title="Close"></a>';
		texto = texto + '			</td>';
		texto = texto + '		</tr>';
		texto = texto + '	</table>';
		texto = texto + '</div>';
		
		if (altura==null)
			altura = 120;
		if (largura==null)
			largura = 370;
		
		
		document.getElementById("mostraAlerta").innerHTML = texto;
		$('#alertaUsuario').modal({			
			overlayCss: {
				backgroundColor: '#222',
				cursor: 'wait'
			}
			,containerCss: {
				height: altura,
				width: largura,
				backgroundColor: '#000',
				border: '1px solid #ccc',
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .8, 
				color: '#fff'
			}
			,closeHTML:'<a href="javascript:void(0)" onClick="$.modal.close();' + funcaoCancel + ';" class="modalCloseImg" title="FECHAR"></a>'
			,autoResize:true
			,zIndex: 999990
			,escClose: false
		});
}

function AlertarUsuario2(msg, altura, largura, funcao) {
	
    if (funcao == null)
        funcao = '';        
        
		var texto = '';
		texto = texto + '<div id="alertaUsuario">';
		texto = texto + '	<table border="0" width="100%" height="120px">';
		texto = texto + '		<tr>';
		texto = texto + '			<td rowspan="2" style="width:50px; text-align:center; vertical-align:middle">';
		texto = texto + '				<img src="../../portal/res07/imagens/alert_icon.png" />';
		texto = texto + '			</td>';
		texto = texto + '			<td style="text-align:left; vertical-align:middle;height:80px">';
		texto = texto + '				<BR>'+msg+'';
		texto = texto + '			</td>';
		texto = texto + '		</tr>';
		texto = texto + '		<tr>';
		texto = texto + '			<td style="text-align:right; vertical-align:bottom;height:10px">';
		texto = texto + '				<a href=javascript:$.modal.close();' + funcao + '><img border="0" src="../../func/imagens/btn_ok.png" />';
		//texto = texto + '				<a href=javascript:$.modal.close();' + funcao + ' class="modalCloseImg" title="Close"></a>';
		texto = texto + '			</td>';
		texto = texto + '		</tr>';
		texto = texto + '	</table>';
		texto = texto + '</div>';
		
		if (altura==null)
			altura = 120;
		if (largura==null)
		    largura = 370;
            
		document.getElementById("mostraAlerta").innerHTML = texto;
		$(texto).modal({			
			overlayCss: {
				backgroundColor: '#222',
				cursor: 'wait'
			}
			,containerCss: {
				height: altura,
				width: largura,
				backgroundColor: '#000',
				border: '1px solid #ccc',
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: .8, 
				color: '#fff'
			}
			,closeHTML:'<a href="javascript:void(0)" onClick="$.modal.close();' + funcao + ';" class="modalCloseImg" title="FECHAR"></a>'
			,autoResize:true
			,zIndex:999990
            ,escClose: false
		});
}

function eff_SlideFade(div, attr, speed){
	if(attr == "show"){
		$(div).slideDown(speed);
		$(div).fadeTo(speed, 1.0);
		$(div).css("display","inline");
	}else{
		$(div).fadeTo(speed, 0.1, function(){
		   $(div).html("");
		});
	}
}

function RegistroAgencia(site) {
    $("#divImprimir").load("../../func/portal/agencia/RegistreAgenciaMan.asp?sAcao=I&A003_ind_free_lancer=0&A048_cod_site=" + site, function () {
        $("#divImprimir").dialog("open");
        $("#divImprimir").dialog({ top: 50, closeOnEscape: false, bgiframe: true, modal: true, autoOpen: true, title: 'Registre sua Ag&ecirc;ncia', width: 730, height: 500 });
    });
}

function EnviaEmailContato(site) {
    //caso nao tenha sido setado o tamanho das tela setado manual do popup e do iframe
    // (alturaDiv == null)
        alturaDiv = 400;
   // if (larguraDiv == null)
        larguraDiv = 890;
  //  if (alturaIframe == null)
        alturaIframe = alturaDiv;
 //   if (larguraIframe == null)
        larguraIframe = larguraDiv;

   // if (zindex == null)
        zindex = 1004;

    //var urlpop = "http://pt.wikipedia.org/wiki/"+pais;//Canad%C3%A1		
    url = "../../func/portal/enviaEmailContato.asp?A048_cod_site=" + site + "&str=" + Date.parse(new Date()) + "&altura=" + alturaIframe + "&largura=" + larguraIframe;

    $("#divImprimir").load(url, function () {
        alturaDiv = alturaDiv + 100;												   
        $('#divImprimir').modal({
            overlayCss: {
                backgroundColor: '#222',
                cursor: 'wait'
            },
            containerCss: {
                height: alturaDiv,
                width: larguraDiv,
                border: '0px solid #ccc',
                backgroundColor: 'transparent',
                color: '#000'
            },
            closeHTML: '<a class="imgCloseDetalhes" style="top:2px; width:75px; height:70px; color:fff;" title="Fechar" onclick="$.modal.close();"><br><font color="#FFFFFF">&nbsp;</font></a>',
            //abaixo faz sumir o overflow do modal
            onShow: function (d) {
                d.wrap.css('overflow', 'hidden');
            },
            zIndex: zindex
        });
        //});			
    });

}

function esqueciMinhaSenha(site){
	$("#divEsqueciMinhaSenha").dialog({
		autoOpen: false,
		modal:true,
		height:180,
		resizable:false,
		open: function(event, ui) { 
			$("#divEsqueciMinhaSenha").load("../../func/portal/esqueci_senha.asp?A048_cod_site="+site); 
		},
		beforeclose: function(event, ui) { 
			$("#divEsqueciMinhaSenha").html(""); 
		}	
	});
	$("#divEsqueciMinhaSenha").dialog('open');
	

}

function formataValor(num,separadorMil,separadorDec) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3)) +separadorMil+ num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + separadorDec + cents);
}

/// função a qual abre o conteudo dentro de uma div que esta no arquivo divsOcultas.asp
/// é executado um load e logo apos um modal pra que fique um modal com os detalhes da tela.
function mostraPopDinamicoIframe(urlpopup, alturaDiv, larguraDiv, alturaIframe, larguraIframe, zindex)
{
	//caso nao tenha sido setado o tamanho das tela setado manual do popup e do iframe
	if(alturaDiv == null)
		alturaDiv = 400;
	if(larguraDiv == null)
		larguraDiv = 890;
	if(alturaIframe == null)
		alturaIframe = alturaDiv;
	if(larguraIframe == null)
	    larguraIframe = larguraDiv;

	if (zindex == null)
	    zindex = 1004;
		
	//var urlpop = "http://pt.wikipedia.org/wiki/"+pais;//Canad%C3%A1		
	url = "../../func/portal/popupDinamico.asp?str="+Date.parse(new Date())+"&url="+urlpopup+"&altura="+alturaIframe+"&largura="+larguraIframe;
	
	$("#popupDetalhesCorpo").load(url, function(){	
		alturaDiv = alturaDiv + 100;
				
		//este load abaixo estou fazendo testes pra mostrar o carregando enquanto carrega o site externo (fabricio)
		//$("#mostraAlerta").load(urlpopup, function(){														   
			$('#popupDetalhesGeral').modal({
				overlayCss: {
					backgroundColor: '#222',
					cursor: 'wait'
				},
				containerCss: {
					height: alturaDiv,
					width:larguraDiv,
					border:'0px solid #ccc',
					backgroundColor: 'transparent',
					//'-webkit-border-radius': '10px', 
					//'-moz-border-radius': '10px', 
					//opacity: .8, 
					color: '#000'
				},
				closeHTML:'<a class="imgCloseDetalhes" style="top:2px; width:75px; height:70px; color:fff;" title="Fechar" onclick="$.modal.close();"><br><font color="#FFFFFF">&nbsp;</font></a>',
				//abaixo faz sumir o overflow do modal
				onShow: function (d) {
					d.wrap.css('overflow','hidden');
				},
                zIndex:zindex
			});
		//});			
	});
	
}
	
function mostraPopDinamicoDiv(idDiv, alturaDiv, larguraDiv, mostraCabecalho)
{
	//caso nao tenha sido setado o tamanho das tela setado manual do popup e do iframe
	if(alturaDiv == null)
		alturaDiv = 360;
	if(larguraDiv == null)
		larguraDiv = 890;
	if(mostraCabecalho == null)
		mostraCabecalho = true;
	htmlClose =  '<a class="imgCloseDetalhes" style="top:2px; width:85px; height:50px; color:fff;" title="Fechar" onclick="$.modal.close();"><br><font color="#FFFFFF">&nbsp;</font></a>'	
		if (mostraCabecalho == false) 
		{ 
		 document.getElementById("popupDetalhesTopo").style.display = 'none'
		 document.getElementById("popupDetalhesCorpo").style.overflowY = 'none';
		 document.getElementById("popupDetalhesCorpo").style.backgroundColor="transparent";
		 htmlClose =  '<a class="imgCloseDetalhes" style="top:3px; width:190px; height:40px; color:fff;" title="Fechar" onclick="$.modal.close();"><br><font color="#FFFFFF">&nbsp;</font></a>'	

		}else{
		 document.getElementById("popupDetalhesCorpo").style.overflowY = "scroll";
		}
	
		//pegando o texto e colocando no corpo do popup
		document.getElementById("popupDetalhesCorpo").innerHTML = document.getElementById(idDiv).innerHTML;
		
		//fazendo atribuiçoes da div pra mostrar os dados.
		document.getElementById("popupDetalhesCorpo").style.height = alturaDiv + "px";
		document.getElementById("popupDetalhesCorpo").style.padding = "10px";
		
		
		alturaDiv = alturaDiv + 110;				
												   
		$('#popupDetalhesGeral').modal({
			overlayCss: {
				backgroundColor: '#222',
				cursor: 'wait'
			},
			containerCss: {
				height: alturaDiv,
				width:larguraDiv,
				border:'0px solid #ccc',
				backgroundColor: 'transparent',
				//'-webkit-border-radius': '10px', 
				//'-moz-border-radius': '10px', 
				//opacity: .8, 
				color: '#000'
			},
			closeHTML: htmlClose,
			//abaixo faz sumir o overflow do modal
			onShow: function (d) {
				d.wrap.css('overflow','hidden');
			}
		});

}

function fPesquisarVoucher(site,portal,idioma) {
         $().voucher({ senha: $("#numero_voucher").val(), site: site,idioma:idioma,portal:portal });
}

//function fchat() {
//	pop1 = window.open("http://touroperator.mysuite.com.br/clientvivo.php?param=sochat_chatdep&sl=btv&redirect=http://touroperator.mysuite.com.br/empresas/btv/atendimento.php", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
//}

//Função que abre o popup dos chats de atendimento. Cada site usa um link diferente. Passe o cod_site e cod_portal para chamar o link correspondente
function fchat(CodSiteCodPortal) {
	switch (CodSiteCodPortal) {
		case 11: //VitalCard
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoVitalCard.php?inf=VitalCard", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 31: //Vistos
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoVistos.php?inf=Vistos", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 41: //ByTravel
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoByTravel.php?inf=ByTravel", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 61: //Zurich
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoZurich.php?inf=Zurich", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 71: //Reservando
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoReservando.php?inf=Reservando", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 91: //Odyssey
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoOdyssey.php?inf=Odyssey", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 131: //ViajaPeregrino
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoViajaPeregrino.php?inf=ViajaPeregrino", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 161: //VitalFone
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoVitalFone.php?inf=VitalFone", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
		case 42:
			pop1 = window.open("http://touroperator.mysuite.com.br/empresas/btv/atendimentoEuropaMundo.php?inf=EuropaMundo", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
			break;
	}
	//pop1 = window.open("http://touroperator.mysuite.com.br/clientvivo.php?param=sochat_chatdep&sl=btv&redirect=http://touroperator.mysuite.com.br/empresas/btv/atendimento.php", "pop1", "width=500, height=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
}