function ajaxObject(){
    var ajOb = null;
    if (window.XMLHttpRequest) {
        ajOb = new XMLHttpRequest();
    }
    else {
        ajOb = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return ajOb;
}

function votarticulo(idarticulo,puntos,tipo){
    var ajaxReq = ajaxObject();
    ajaxReq.open("get", "/"+ tipo +"/votar/" + idarticulo + "/" + puntos);
    ajaxReq.onreadystatechange = function(){
        if (ajaxReq.readyState == 4) {
            if (ajaxReq.responseText) {
                gracias = ajaxReq.responseText;
                document.getElementById('numvotos-votos').innerHTML = gracias;
            }
        }
    };
    ajaxReq.send(null);
}

// Navegacion
$(function() {
    var document_width = document.width ? document.width : document.documentElement.offsetWidth;
    $('#menuh > ul > li')
        .each(function() {
            var offset = $(this).offset();
            if (document_width < offset.left + 456){
                $(this).addClass('d');
            }

        })
        .bind('mouseenter', function() {
            var li = this;
            li.over = true;
            window.setTimeout(function() {
                if (li.over) {
                    $(li).parent().find('.abierto').removeClass('abierto');
                    $(li).addClass('abierto');
                }
            }, 0);
        })
        .bind('mouseleave',function() {
            var li = this;
            li.over = false;
            window.setTimeout(function() {
                if (!li.over){
                    $(li).removeClass('abierto');
                }
            }, 0);
        });
});
