var lastvote, lastmore, voteStatus = 0, moreStatus = 0;

function toggle(id) {
    if (lastvote != id && voteStatus == 1)
        $("#" + lastvote).toggleClass("hide", 1000);
    $("#" + id).toggleClass("hide", 1000);
    if (lastvote != id)
        voteStatus = 1;
    else
        voteStatus = (voteStatus == 0) ? 1 : 0;
    if (moreStatus == 1) {
        $("#more_" + lastmore).toggleClass("hide", 1000);
        moreStatus = 0;
    }
    lastvote = id;
}

function autoHide(index) {
    var o = $("#more_" + index);
    if (o.attr("class") != "button hide") {
        setTimeout(function () {
            var x = $("#more_" + index);

            if (x.attr("class") != "button hide")
                togglemore(index);
        }, 2000);
    }
}

function togglemore(id) {

    if (lastmore != id && moreStatus == 1)
        $("#more_" + lastmore).toggleClass("hide", 1000);

    $("#more_" + id).toggleClass("hide", 1000);
    if (lastmore != id)
        moreStatus = 1;
    else
        moreStatus = (moreStatus == 0) ? 1 : 0;

    if (voteStatus == 1) {
        $("#" + lastvote).toggleClass("hide", 1000);
        voteStatus = 0;
    }

    lastmore = id;


}

function loadurl(url, panel, data, func) {    
    //function loads the markup from the url specified into the panel
    //allows you to set the post data and specify a function to call on success
    $.post(url, data, function (xml) {
        if (panel != null)
            panel.html(xml);
        if (func != null)
            func(xml);
    });
}


