$(document).ready(function() {

    $('.input_data').numeric();
    $('.input_data_ano').numeric();
    $('.inputCepDigito').numeric();
    $('.inputCep').numeric();
    $('.inputConta').numeric();
    $('.codigoIndicacao').numeric();
    $('.inputMedio').numeric();
    $('.inputPequeno').numeric();
    $('.inputComissao').numeric(',');
    
    //Inputs - Efeito hover
    inicializaCamposHover();

    /* Menu Comprar */
    $(".lnkMenuOndeComprar").click(function() { mostraMenuComprar() });

    /* Campo Palavra-Chave */

    $("#buscaEmpresas .palavraChave").blur(function() {
        if (this.value == '')
            this.value = 'palavra-chave';
    });

    $("#buscaEmpresas .palavraChave").focus(function() {
        if (this.value == 'palavra-chave')
            this.value = '';
    });
    
    //Estiliza selects
    estilizaSelects();
    

});

function scrollChat() {
    $('.areaTexto').stop().scrollTo({ top: 800 }, 800);
}

function abrePopUp() {
    janela = window.open("chatTela.aspx", "windowchat", "location=1,status=0,scrollbars=1,width=572,height=640");
}

function geraBoletoEspecial(e) {
    window.open('geraboletoespecial.aspx?e=' + e, '', 'status=yes,location=no,toolbar=no,menubar=no,scrollbar=yes');
}

 /* Exibe Boleto e redireciona para a página de confirmação */
function imprimeBoletoPessoaFisica(pesid, conPagTipo, conPagTipoCustosDeAdesao, redirecionaParaConfirmacao)
{
    if (conPagTipoCustosDeAdesao != 0)
        window.open('geraboleto.aspx?extOrdemBoleto=1&conPagTipo=' + conPagTipoCustosDeAdesao + '&pesid=' + pesid ,'conPagTipoCustosDeAdesao','top=50,left=200,heigth=400,width=720,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');

	if (conPagTipo != 0)
        window.open('geraboleto.aspx?extOrdemBoleto=1&conPagTipo=' + conPagTipo + '&pesid=' + pesid ,'conPagTipo','top=10,left=10,heigth=400,width=720,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
    
 
    if (redirecionaParaConfirmacao)
       window.location.href='CadastroConfirmado.aspx?pesid=' + pesid + '&conPagTipo=' + conPagTipo;
}

/* Exibe Boleto e redireciona para a página de confirmação */
function imprimeBoletoPessoaJuridica(pesid, conPagTipo, conPagTipoPlanoAdesao, redirecionaParaConfirmacao)
{
    if (conPagTipoPlanoAdesao != 0)
        window.open('geraboleto.aspx?extOrdemBoleto=1&conPagTipo=' + conPagTipoPlanoAdesao + '&pesid=' + pesid ,'conPagTipoCustosDeAdesao','top=50,left=200,heigth=400,width=720,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
    
    if (conPagTipo != 0)
        window.open('geraboleto.aspx?extOrdemBoleto=1&conPagTipo=' + conPagTipo + '&pesid=' + pesid ,'conPagTipo','top=10,left=10,heigth=400,width=720,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
        
    if (redirecionaParaConfirmacao)
       window.location.href='CadastroConfirmadoJuridico.aspx?pesid=' + pesid + '&conPagTipo=' + conPagTipo+ '&conPagTipoPlanoAdesao=' + conPagTipoPlanoAdesao;
       
}

/* Inicia Vídeo - Comercial */
function iniciaComercialTv() {

    /* Campanha TV */
    var player = $f("controlesPlayerTv", "http://releases.flowplayer.org/swf/flowplayer-3.1.5.swf",  {
    	
        clip: {
            //url: 'videos/comercial_03_2010.flv?',
            url: 'http://www.uniaocompras.com.br/videos/comercial_03_2010.flv',
            autoPlay: true, 
            autoBuffering: true
        },
    	
        plugins:  {
    	
            // default controls with the same background color as the page background
            controls:  {
	            backgroundColor: '#254558',
	            backgroundGradient: 'none',			
	            all:false,
	            scrubber:true,
	            mute:false,
	            height:15,
	            progressColor: '#6d9e6b',
	            bufferColor: '#333333'
            }
    		
        },
    	
        // canvas coloring and custom gradient setting
        canvas: {
            backgroundColor:'#254558',
            backgroundGradient: [0.1, 0]
        }
    	
    });
    
     //Clique - Botão fechar
    $('.boxComercialTv .box .btFechar').click(function() {
        player.stop();
        $('.boxComercialTv').hide();
    });

}
