﻿$(document).ready(function () {
    $("#botaoTwitter").hide();
    $('#escolha1').click(function () {
        destaqueHome(1, this);
    });

    $('#escolha2').click(function () {
        destaqueHome(2, this);
    });

    $('#enqueteOptions input').click(function () {
        $.getScript("/ws/enquete.ajax.aspx?idenquete=" + $(this).attr('value').substring(3), function () {
            $('#enqueteOptions input').attr('disabled', 'disabled');
            $('#enqueteResultado').css('display', 'block');
            $('#enquete #resposta').html('Obrigado pela participa&ccedil;&atilde;o');
        });
    });

    var horarioHome = setInterval(function () {
        var data = new Date();
        var sds = (data.getHours() > 4 && data.getHours() < 12) ? "Bom dia" : (data.getHours() > 11 && data.getHours() < 19) ? "Boa tarde" : "Boa noite";
        $("#timeStamp > P").html("<b>&nbsp;" + sds + "</b> " + data.getDate() + "/" + (data.getMonth() + 1) + "/" + data.getFullYear() + " " + data.getHours() + ":" + data.getMinutes());
    },
    function () {
        var now = new Date();
        var delay = (60 - now.getSeconds()) * 1000;

        return delay;
    });
})

function enqueteAbre(idenquete, idresposta) {
    $.getScript("/ws/enquete.ajax.aspx?idenquete=" + idenquete + "&idresposta=" + idresposta, function () {
        $('#enqueteOptions input').attr('disabled', 'disabled');
        $('#enqueteResultado').css('display', 'block');
        $('#enquete #resposta').html('Você já votou. Obrigado pela participação!');
    });
}

function abreAba(id) {
    $('.conteudoAbas').hide();
    $('#' + id).show();
    $('#seuBilheteLinks').removeClass();
    $('#seuBilheteLinks').addClass(id + 'Atv');
}

function destaqueHome(id, elem) {
    var ativo;
    (id == 1) ? ativo = 2 : ativo = 1;

    $('#opcao' + id).show();
    $(elem).parent('li').addClass('ativo' + id);
    $('#opcao' + ativo).hide();
    $(elem).parent('li').removeClass('ativo' + ativo);
}

function abreTutorial() {
    window.open("/tutorial/index.html", "tutorial", "width=765, height=524, scrollbars=no");
}

