﻿$(document).ready(function () {

    //inicialização de uniform
    $("input, textarea, select, button").uniform();

    //inicialização de easeyslider banner
    $("#slider").easySlider({
        auto: true,
        continuous: true,
        numeric: true
    });

    //Fechar Dialog
    $("#dialog:ui-dialog").dialog("destroy");

    //INICIA DIALOG
    $("#dialog-message").dialog({
        modal: true,
        buttons: {
            Ok: function () {
                $(this).dialog("close");
            }
        }
    });

    //SESSION SEXOS
    $("#homens").live('click', function () {
        a = $(this);
        $.ajax({
            method: 'GET',
            url: "Session.aspx",
            data: { Sexo: '2' },
            success: function () {
                $(location).attr('href', "Site/Default.aspx");

                //$(a).load(a.href)
            }
        });
        return false;
    });

    $("#bonecas").live('click', function () {
        a = $(this);
        $.ajax({
            method: 'GET',
            url: "Session.aspx",
            data: { Sexo: '3' },
            success: function () {
                $(location).attr('href', "Site/Default.aspx");
                // $(a).load(a.href);
            }
        });
        return false;
    });

    $(".Expandir").live('click', function () {
        id_registro = $("#TxtIdEnsaio").val();
        $.ajax({
            method: 'GET',
            url: "Site/Ajax/Expandidas.aspx",
            data: { id: id_registro },
            success: function (retorno) {
                $("#FotosAmpliadas").fadeIn(500);
                $("#ListaExpandidas").html(retorno);
            }
        });
        return false;
    });

    $(".fecharAmpliadas").live('click', function () {
        $("#FotosAmpliadas").fadeOut(500);
        return false;
    });



    //VOTAR ACOMPANHANTE
    $('a[id^="BtVotar"]').live('click', function () {
        var a = $(this)
        if ($(this).attr('Class') != 'Votou') {
            idAcompanhante = $(this).attr('href').replace('Site/#', '')
            $.ajax({
                method: 'GET',
                url: "Site/Ajax/Voto.aspx",
                data: { id: idAcompanhante },
                success: function (retorno) {
                    $("#QtdVotos").html(retorno);
                    $(a).addClass('Votou');
                }
            });
        }
        return false;
    });


    //EXIBIÇÃO DE ENSAIO
    $('a[id^="Ensaio_"]').live('click', function () {
        var li = $(this).closest('li')
        if ($(li).attr('Class') != 'Ativo') {
            id_registro = $(this).attr('id').replace('Ensaio_', '')
            $("#Galeria").html("<div>Carregando</div><img src='Site/Static/Images/ajax-loader.gif'/>");
            //$('#Loading').fadeIn(500)
            $.ajax({
                method: 'GET',
                url: "Site/Ajax/Galeria.aspx",
                data: { id: id_registro },
                success: function (retorno) {
                    $("#Galeria").html(retorno);
                    //Excluir Linha
                    //$('#Loading').fadeOut(500)
                    $('li').removeClass('Ativo');
                    $(li).addClass('Ativo');
                    $("#TxtIdEnsaio").val(id_registro);
                    $('a.highslide').each(function () {
                        this.onclick = function () {
                            return hs.expand(this, { slideshowGroup: 'galeria' });
                            return false;
                        };
                    });
                }
            });
        }
        return false;
    });

    //EXIBIÇÃO DE FORMULÁRIO DE INDICAÇÃO
    $('#IndicarAcompanhante').live('click', function () {
        $("#FormIndica").show(500);
        return false;
    });
    $('#Fechar').live('click', function () {
        $("#FormIndica").fadeOut(500);
        return false;
    });


    //Limpa inicializa Campo busca
    $("#TxtBusca").live('focus', function () {
        if ($(this).val() == 'Procurar...') {
            $(this).val('');
        }
    });

    $("#TxtBusca").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Procurar...');
        }
    });

    //Limpa inicializa Campo Newsletter Nome
    $("#TxtNomeNews").live('focus', function () {
        if ($(this).val() == 'Nome') {
            $(this).val('');
        }
    });

    $("#TxtNomeNews").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Nome');
        }
    });

    //Limpa inicializa Campo Newsletter Email
    $("#TxtEmailNews").live('focus', function () {
        if ($(this).val() == 'E-mail') {
            $(this).val('');
        }
    });

    $("#TxtEmailNews").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('E-mail');
        }
    });

    //Limpa inicializa Campo Nome Indicação
    $("#TxtNomeIndicador").live('focus', function () {
        if ($(this).val() == 'Seu Nome') {
            $(this).val('');
        }
    });

    $("#TxtNomeIndicador").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Seu Nome');
        }
    });

    //Limpa inicializa Campo Email Indicação
    $("#TxtEmailIndicador").live('focus', function () {
        if ($(this).val() == 'Seu E-mail') {
            $(this).val('');
        }
    });

    $("#TxtEmailIndicador").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Seu E-mail');
        }
    });

    //Limpa inicializa Campo Nome Amigo Indicação
    $("#TxtNomeAmigo").live('focus', function () {
        if ($(this).val() == 'Nome do seu amigo') {
            $(this).val('');
        }
    });

    $("#TxtNomeAmigo").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('Nome do seu amigo');
        }
    });

    //Limpa inicializa Campo Email Amigo Indicação
    $("#TxtEmailAmigo").live('focus', function () {
        if ($(this).val() == 'E-Mail do seu amigo') {
            $(this).val('');
        }
    });

    $("#TxtEmailAmigo").live('blur', function () {
        if ($(this).val() == '') {
            $(this).val('E-Mail do seu amigo');
        }
    });

});

function confirmaCadastro() {

}
