$(document).ready(function(){
    $('#chamadas-esq-home').corner(); 
})


$(function(){	// shorthand for $(document).ready() BTW
	$('#chamadas-esq-home, #mais-buscadas-esq-home, #noticias-meio-home, #newsletter-dir-home, #taxas-cotacoes-dir-home, #conversor-dir-home, #conteudo-internas, #conteudo-internas-no-lateral, #newsletter-dir-home-obrigado').each(function() {
		// The text of the paragraphs in the rounded divs is also the
		// jQuery code needed to create that effect. Cosmic.
		 //eval($('span', this).text());
		 $("#chamadas-esq-home, #mais-buscadas-esq-home, #noticias-meio-home, #newsletter-dir-home, #taxas-cotacoes-dir-home, #conversor-dir-home, #conteudo-internas, #conteudo-internas-no-lateral, #newsletter-dir-home-obrigado").corner();
	});
});

$(function(){
	DD_belatedPNG.fix('#bg-pontos-turisticos');
})

$(document).ready(function(){

	$(".bandeiras a").append("<em></em>");
	
	$(".bandeiras a").hover(function(){
		$(this).find("em").animate({opacity: "show", top: "-75"}, "slow");
		var hoverText = $(this).attr("title");
	    $(this).find("em").text(hoverText);
	}, function() {
		$(this).find("em").animate({opacity: "hide", top: "-85"}, "fast");
	});


});

function bannerlateral()
{
        var ran = Math.random()
        var num =  7;
        if (num*ran <  1)
        {
                document.write("<a href=\"http://webagente.blessway.com.br/lojavirtual/default_cruzeiros.asp\" target=\"_blank\"><img src=\"img/banner-lateral-temporada-de-cruzeiros-2009-2010.jpg\"></a>");
                return;
        }
		if (num*ran <  2)
        {
                document.write("<a href=\"http://webagente.blessway.com.br/lojavirtual/detalhes_destinos_novo.asp?cd_agrupamento=7&cd_destino_base=1506\" target=\"_blank\"><img src=\"img/banner-lateral-praia-do-forte.jpg\"></a>");
                return;
        }
		if (num*ran <  3)
        {
                document.write("<a href=\"http://webagente.blessway.com.br/lojavirtual/detalhes_destinos_novo.asp?tp_log=D&id_systur=S&cd_destino_base=1183&cd_agrupamento=4\" target=\"_blank\"><img src=\"img/banner-lateral-buenos-aires.jpg\"></a>");
                return;
        }
		if (num*ran <  4)
        {
                document.write("<a href=\"http://webagente.blessway.com.br/lojavirtual/detalhes_destinos_novo.asp?cd_agrupamento=2&cd_destino_base=3933\" target=\"_blank\"><img src=\"img/banner-lateral-orlando-reino-e-magia.jpg\"></a>");
                return;
        }
		if (num*ran <  5)
        {
                document.write("<a href=\"http://webagente.blessway.com.br/lojavirtual/detalhes_destinos_novo.asp?cd_agrupamento=11&cd_destino_base=178\" target=\"_blank\"><img src=\"img/banner-lateral-fernando-de-noronha-e-recife.jpg\"></a>");
                return;
        }
		if (num*ran <  6)
        {
                document.write("<a href=\"http://webagente.blessway.com.br/lojavirtual/detalhes_destinos_novo.asp?cd_agrupamento=5&cd_destino_base=4477\" target=\"_blank\"><img src=\"img/banner-lateral-africa-do-sul.jpg\"></a>");
                return;
        }
		if (num*ran <  7)
        {
                document.write("<a href=\"http://www.disneywebcontent.com/portal/site/csa-wdw/?SiteID=9975\" target=\"_blank\"><img src=\"img/banner-lateral-walt-disney-world.jpg\"></a>");
                return;
        }
}


//MASCARA PARA INPUTS DO FORMULARIO
jQuery(function($){
   $("#telefone").mask("(99) 9999-9999");
   $("#dataCotacao").mask("99/99/9999");
});


$(document).ready(function(){
    
    //CADASTRO NEWSLETTER
    $("#form_newsletter").submit( function() {
    
         if ($("#nome").val() == ''){
            alert("Por favor, informe seu Nome");
            $("#nome").val('');
            $("#nome").focus();
            return false;
         }
         
		 if ($("#email").val() == ''){
            alert("Por favor, informe o E-mail");
            $("#email").val('');
            $("#email").focus();
            return false;
         }
         else{
			  var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
			  if(!regmail.test($("#email").val())){
				   alert("E-mail inválido");
                   $("#email").focus();
				   return false;
			  }
		 }
         
         $("#submit").val('ENVIANDO!...');
         $('#submit').attr("disabled", "disabled");
         
        $.post("includes/ajax/newsletter-cadastrar.php", {nome:  escape(  $('#nome').val() ) , 
                                                          email:  escape( $('#email').val() )
                                                         },
        function(data) {
            if(data == '1'){
                $("#newsletter-dir-home").hide();
                $("#newsletter-dir-home-obrigado").fadeIn('slow');
                $("#submit").val('CADASTRAR');
            }
            else{
                $("#newsletter-dir-home-obrigado").hide(); 
                $("#newsletter-dir-home").fadeIn('slow');
                $("#submit").val('CADASTRAR');
                alert(data);
            }
            $('#submit').removeAttr("disabled");
        });
        return false;
    
	});
    
    
    //FORMULARIO DE CONTATO
    $("form[name=form_contato]#contato").submit( function(){
    
         /*
         if($("#empresa").val() == ''){
            alert("Por favor, informe a Empresa");
            $("#empresa").focus();
            return false;
         }*/
         
         if($("#nome_contato").val() == ''){
            alert("Por favor, informe Seu Nome");
            $("#nome_contato").focus();
            return false;
         }
         
         if($("#telefone").val() == ''){
            alert("Por favor, informe o Telefone");
            $("#telefone").focus();
            return false;
         }
         
         if($("#email").val() == ''){
            alert("Por favor, informe o E-mail");
            $("#email").focus();
            return false;
         }
         else{
              var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
              if(!regmail.test($("#email").val())){
                   alert("E-mail inválido");
                   $("#email").focus();
                   return false;
              }
         }
         
         /*
         if($("#mensagem").val() == ''){
            alert("Por favor, informe a Mensagem");
            $("#mensagem").focus();
            return false;
         }*/
         
        $("#submit").val('Enviando!...');
        $('#submit').attr("disabled", "disabled");

        $.post("includes/ajax/contato_enviar.php", {empresa:  escape(  $('#empresa').val() ) , 
                                                    nome_contato:  escape(  $('#nome_contato').val() ) , 
                                                    telefone:  escape(  $('#telefone').val() ) , 
                                                    ramal:  escape(  $('#ramal').val() ) , 
                                                    email:  escape(  $('#email').val() ) , 
                                                    uf:  escape(  $('#uf').val() ) , 
                                                    cidade:  escape(  $('#cidade').val() ) , 
                                                    endereco:  escape(  $('#endereco').val() ) , 
                                                    obs:  escape(  $('#obs').val() ) , 
                                                    mensagem:  escape(  $('#mensagem').val() )
                                                    },
                                                    function(data) {
                                                        if(data == '1'){
                                                            $("form[name=contato]#formulario").hide();
                                                            $("#obrigado-forms").fadeIn('slow');
                                                            $("#submit").val('Enviar');
                                                            $('#submit').removeAttr("disabled");
                                                        }
                                                        else{
                                                            $("#obrigado-forms").hide(); 
                                                            $("form[name=contato]#formulario").show();
                                                            $("#submit").val('Enviar');
                                                            $('#submit').removeAttr("disabled");
                                                            alert(data);
                                                        }
                                                    });
          $('#submit').removeAttr("disabled");
          return false;
	});
    
    
    //FORMULARIO SEJA CLIENTE
    $("form[name=form_cliente]#cliente").submit( function(){
    
         /*
         if($("#empresa").val() == ''){
            alert("Por favor, informe a Empresa");
            $("#empresa").focus();
            return false;
         }*/
         
         if($("#nome_contato").val() == ''){
            alert("Por favor, informe Seu Nome");
            $("#nome_contato").focus();
            return false;
         }
         
         if($("#telefone").val() == ''){
            alert("Por favor, informe o Telefone");
            $("#telefone").focus();
            return false;
         }
         
         if($("#email").val() == ''){
            alert("Por favor, informe o E-mail");
            $("#email").focus();
            return false;
         }
         else{
              var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
              if(!regmail.test($("#email").val())){
                   alert("E-mail inválido");
                   $("#email").focus();
                   return false;
              }
         }
         
         /*
         if($("#mensagem").val() == ''){
            alert("Por favor, informe a Mensagem");
            $("#mensagem").focus();
            return false;
         }*/
         
        $("#submit").val('Enviando!...');
        $('#submit').attr("disabled", "disabled");

        $.post("includes/ajax/sejacliente_enviar.php", {empresa:  escape(  $('#empresa').val() ) , 
                                                        nome_contato:  escape(  $('#nome_contato').val() ) , 
                                                        telefone:  escape(  $('#telefone').val() ) , 
                                                        ramal:  escape(  $('#ramal').val() ) , 
                                                        email:  escape(  $('#email').val() ) , 
                                                        uf:  escape(  $('#uf').val() ) , 
                                                        cidade:  escape(  $('#cidade').val() ) , 
                                                        endereco:  escape(  $('#endereco').val() ) , 
                                                        obs:  escape(  $('#obs').val() ) , 
                                                        mensagem:  escape(  $('#mensagem').val() )
                                                    },
                                                    function(data) {
                                                        if(data == '1'){
                                                            $("form[name=form_cliente]#cliente").hide();
                                                            $("#obrigado-forms").fadeIn('slow');
                                                            $("#submit").val('Enviar');
                                                            $('#submit').removeAttr("disabled");
                                                        }
                                                        else{
                                                            $("#obrigado-forms").hide(); 
                                                            $("form[name=form_cliente]#cliente").show();
                                                            $("#submit").val('Enviar');
                                                            $('#submit').removeAttr("disabled");
                                                            alert(data);
                                                        }
                                                    });
          $('#submit').removeAttr("disabled");
          return false;
	});
    
    
    //FORMULARIO SOLICITE UMA VISITA
    $("form[name=form_visita]#solicitevisita").submit( function(){
    
         /*
         if($("#empresa").val() == ''){
            alert("Por favor, informe a Empresa");
            $("#empresa").focus();
            return false;
         }*/
         
         if($("#nome_contato").val() == ''){
            alert("Por favor, informe Seu Nome");
            $("#nome_contato").focus();
            return false;
         }
         
         if($("#telefone").val() == ''){
            alert("Por favor, informe o Telefone");
            $("#telefone").focus();
            return false;
         }
         
         if($("#email").val() == ''){
            alert("Por favor, informe o E-mail");
            $("#email").focus();
            return false;
         }
         else{
              var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
              if(!regmail.test($("#email").val())){
                   alert("E-mail inválido");
                   $("#email").focus();
                   return false;
              }
         }
         
         /*
         if($("#mensagem").val() == ''){
            alert("Por favor, informe a Mensagem");
            $("#mensagem").focus();
            return false;
         }*/
         
        $("#submit").val('Enviando!...');
        $('#submit').attr("disabled", "disabled");

        $.post("includes/ajax/solicitevisita_enviar.php", {empresa:  escape(  $('#empresa').val() ) , 
                                                            nome_contato:  escape(  $('#nome_contato').val() ) , 
                                                            telefone:  escape(  $('#telefone').val() ) , 
                                                            ramal:  escape(  $('#ramal').val() ) , 
                                                            email:  escape(  $('#email').val() ) , 
                                                            uf:  escape(  $('#uf').val() ) , 
                                                            cidade:  escape(  $('#cidade').val() ) , 
                                                            endereco:  escape(  $('#endereco').val() ) , 
                                                            obs:  escape(  $('#obs').val() ) , 
                                                            mensagem:  escape(  $('#mensagem').val() )
                                                            },
                                                            function(data) {
                                                                if(data == '1'){
                                                                    $("form[name=form_visita]#solicitevisita").hide();
                                                                    $("#obrigado-forms").fadeIn('slow');
                                                                    $("#submit").val('Enviar');
                                                                    $('#submit').removeAttr("disabled");
                                                                }
                                                                else{
                                                                    $("#obrigado-forms").hide(); 
                                                                    $("form[name=form_visita]#solicitevisita").show();
                                                                    $("#submit").val('Enviar');
                                                                    $('#submit').removeAttr("disabled");
                                                                    alert(data);
                                                                }
                                                            });
          $('#submit').removeAttr("disabled");
          return false;
	});
    
    
    //FORMULARIO INDIQUE
    $("form[name=form_indique]#indique").submit( function(){
    
         /*
         if($("#empresa").val() == ''){
            alert("Por favor, informe a Empresa");
            $("#empresa").focus();
            return false;
         }*/
         
         if($("#nome").val() == ''){
            alert("Por favor, informe Seu Nome");
            $("#nome").focus();
            return false;
         }
         
         if($("#email").val() == ''){
            alert("Por favor, informe seu E-mail");
            $("#email").focus();
            return false;
         }
         else{
              var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
              if(!regmail.test($("#email").val())){
                   alert("E-mail inválido");
                   $("#email").focus();
                   return false;
              }
         }
         
         if($("#nome-amigo").val() == ''){
            alert("Por favor, informe o Nome do Amigo");
            $("#nome-amigo").focus();
            return false;
         }
         
         if($("#email-amigo").val() == ''){
            alert("Por favor, informe E-mail do Amigo");
            $("#email-amigo").focus();
            return false;
         }
         else{
              var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
              if(!regmail.test($("#email-amigo").val())){
                   alert("E-mail inválido");
                   $("#email-amigo").focus();
                   return false;
              }
         }
         
        $("#submit").val('Enviando!...');
        $('#submit').attr("disabled", "disabled");

        $.post("includes/ajax/indique_enviar.php", {nome:  escape(  $('#nome').val() ) , 
                                                    email:  escape(  $('#email').val() ) , 
                                                    nome_amigo:  escape(  $('#nome-amigo').val() ) , 
                                                    email_amigo:  escape(  $('#emai-amigo').val() ) , 
                                                    mensagem:  escape(  $('#msg').val() )
                                                    },
                                                    function(data) {
                                                        if(data == '1'){
                                                            $("form[name=form_indique]#indique").hide();
                                                            $("#obrigado-forms").fadeIn('slow');
                                                            $("#submit").val('Enviar');
                                                            $('#submit').removeAttr("disabled");
                                                        }
                                                        else{
                                                            $("#obrigado-forms").hide(); 
                                                            $("form[name=form_indique]#indique").show();
                                                            $("#submit").val('Enviar');
                                                            $('#submit').removeAttr("disabled");
                                                            alert(data);
                                                        }
                                                    });
          $('#submit').removeAttr("disabled");
          return false;
	});
    
    
    
    //FORMULARIO CONVERTER MOEDA
    $("form[name=form_conversor]#form_conversor").submit( function(){
         
         /*
         if($("#empresa").val() == ''){
            alert("Por favor, informe a Empresa");
            $("#empresa").focus();
            return false;
         }*/
         
         if($("#valorConverter").val() == ''){
            alert("Por favor, informe o Valor");
            $("#valorConverter").focus();
            return false;
         }
         
         if($("#dataCotacao").val() == ''){
            alert("Por favor, informe a Data");
            $("#dataCotacao").focus();
            return false;
         }else{
            if(/^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/.test($("#dataCotacao").val()) == false){
                alert('Por favor, informe corretamente a Data da Cotação');
                $("#dataCotacao").focus();
                return false;
            }
         }
         
        $("#bConverte").val('CONVERTENDO!...');
        $('#bConverte').attr("disabled","disabled");
        $('form[name=form_conversor]#form_conversor').attr("disabled","disabled");
        $('form[name=form_conversor]#form_conversor input').attr("disabled","disabled");
        $('form[name=form_conversor]#form_conversor select').attr("disabled","disabled");

        $.post("includes/ajax/converter_moeda.php", {valorConverter:  escape(  $('#valorConverter').val() ) , 
                                                    dataCotacao:  escape(  $('#dataCotacao').val() ) , 
                                                    moedaOrigem:  escape(  $('#moedaOrigem').val() ) , 
                                                    moedaDestino:  escape(  $('#moedaDestino').val() )
                                                    },
                                                    function(data) {
                                                            if(parseFloat(data) >= 0.0)
                                                                $("#resultado-conversor-home").html(data);
                                                            else
                                                                alert(data);
                                                            $("#bConverte").val('CONVERTER');
                                                            $('#bConverte').removeAttr("disabled");
                                                            $('form[name=form_conversor]#form_conversor').removeAttr("disabled");
                                                            $('form[name=form_conversor]#form_conversor input').removeAttr("disabled");
                                                            $('form[name=form_conversor]#form_conversor select').removeAttr("disabled");
                                                    });
          $('#bConverte').removeAttr("disabled");
          return false;
	});
    
     
});


//Carregamento de conteudos da Home
$(document).ready(function(){
    
    //Carrega Noticias Home
    $.get('_noticias_home.php', function(data){ $('#noticias_home').prepend(data);});
    
    //Carrega Taxas e Cotações
    $.get('_taxas_cotacoes.php', function(data){ $('#taxas_cotacoes').prepend(data);});
    
    
});


$(document).ready(function(){
    
    $('#valorConverter').val('1,00');
    $('#valorConverter').priceFormat({
        prefix: '',
        centsSeparator: ',',
        thousandsSeparator: '.'
    });
    
});

$(document).ready(function(){
    $('#tempo_regioes, #tempo_brasil, #tempo_capitais, #tempo_capitais, #tempo_destaques, #tempo_aeroportos').css({"cursor":"pointer"});
    $('#tempo_regioes').click(function(){
        if($(this).next().html() != "")
            $(this).next().slideToggle("slow");
        else
            $(this).next().load('_informacoes_tempo.php?local=regioes').slideDown('slow');
    });
    
    $('#tempo_brasil').click(function(){
        if($(this).next().html() != "")
            $(this).next().slideToggle("slow");
        else
            $(this).next().load('_informacoes_tempo.php?local=brasil').slideDown('slow');
    });
    
    $('#tempo_capitais').click(function(){
        if($(this).next().html() != "")
            $(this).next().slideToggle("slow");
        else
            $(this).next().load('_informacoes_tempo.php?local=capitais').slideDown('slow');
    });
    
    $('#tempo_destaques').click(function(){
        if($(this).next().html() != "")
            $(this).next().slideToggle("slow");
        else
            $(this).next().load('_informacoes_tempo.php?local=destaque').slideDown('slow');
    });
    
    $('#tempo_aeroportos').click(function(){
        if($(this).next().html() != "")
            $(this).next().slideToggle("slow");
        else
            $(this).next().load('_informacoes_tempo.php?local=aeroportos').slideDown('slow');
    });
});

$(document).ready(function(){
    
    /* EFEITO DO CAMPO DE CEP - Todas as páginas */
    $("#cidade_cep, #cidade_cep_internacional").click(function(){
        $(this).val('');
        $(this).css({"backgroundColor":"#fcfef8", "border":"1px solid #afc583"});
     });
});