var id_enquete;

function Acessar(){
    $.post(
        '/site/acessar',
        {
            login: $('#login').val(),
            senha: $('#senha').val()
        },
        function(result){
            if(result == 1){
                window.location.href = $('#url').val();
            }
            
            if(result == 2){
                $('#erro').html('dados incorreto!');
            }
            
            if(result == 3){
                $('#erro').html('preencha todos os campos!');
            }
        }
    );
}

function Autor(){
    $('#autor').css('display', 'inline');
    $('#gmail').css('display', 'none');
}

function Gmail(){
    $('#autor').css('display', 'none');
    $('#gmail').css('display', 'inline');   
}

function Botao(){
    $('#enquete #botao').removeAttr('disabled');
}

function Resposta(valor){
    $('#enquete #' + valor).attr('checked', true);
    id_enquete = valor;
}

function Votar(){
    $.post(
        '/site/votar_enquete',
        {
            id: id_enquete
        },
        function(result){
            Resultado();
        }
    )
}

function Voto(){
    $('#resposta').css('display', 'inline');
    $('#resultado_enquete').css('display', 'none');
}

function Resultado(){
    $.post(
        '/site/resultado_enquete',
        {},
        function(result){
            $('#resultado_enquete').html(result);
            $('#resposta').css('display', 'none');
            $('#resultado_enquete').css('display', 'inline');      
        }
    );
}

function Online(){
    var id = '#posicao';
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    var winH = $(window).height();
    var winW = $(window).width();    
    var left = winW/2-$(id).width()/2;
    var top = winH/2-$(id).height()/2;
    
    newwindow=window.open('/site/online','name','height=265,width=400,left='+left+',top='+top);
    if (window.focus){newwindow.focus()}
}
