jQuery(document).ready(function(){

    jQuery("#menu-login-usuario").hover(
        function () {
            jQuery(this).find("div.submenu-usuario").show();
        },
        function () {
            jQuery(this).find("div.submenu-usuario").hide();
        }
    );

    $("#btnVotar").live("click", function(){
        var destino = $("#votarEncuesta").attr('action');
        jQuery.ajax({
            url: destino,
            type: "POST",
            data: jQuery("#votarEncuesta").serialize(),
            cache: false,
            success: function(html){
                jQuery("#encuesta").html(html);
            },
            beforeSend: function(){
                jQuery("#cargador-encuesta").show();
            },
            complete: function(){
                jQuery("#cargador-encuesta").hide();
            }
        });
        return false;
    });
    
    $("a#linkResultados").live("click", function(){
        var destino = $("a#linkResultados").attr('href');
        jQuery.ajax({
            url: destino,
            type: "GET",
            cache: false,
            success: function(html){
                jQuery("#encuesta").html(html);
            },
            beforeSend: function(){
                jQuery("#cargador-encuesta").show();
            },
            complete: function(){
                jQuery("#cargador-encuesta").hide();
            }
        });
        return false;
    });
});

function limpiadorBuscador() {
    var campoBuscador = document.getElementById('cBuscador');
    if (campoBuscador.value == 'Buscar en Yo soy agricultor') campoBuscador.value = '';
}
