$().ready(function() {
    $(".confirm").click(function() {
        return confirm("Are you sure you want to perform the requested action?");
    });

    $("#loading").ajaxStart(function() {
        $(this).show();
    });

    $("#loading").ajaxComplete(function() {
        $(this).hide();
    });

    $("#status").click(function() {
        $(this).fadeOut("slow");
    });

    setTimeout("updateActivity()", 60000);
});



function urlencode(str)
{
    str = escape(str);
    str = str.replace('+', '%2B');
    str = str.replace('%20', '+');
    str = str.replace('*', '%2A');
    str = str.replace('/', '%2F');
    str = str.replace('@', '%40');
    return str;
}



function updateActivity()
{
    $.get("user/index/activity/partial/layout", function(data) {
        $("#activity").html(data);
        setTimeout("updateActivity()", 60000);
    });
}



function moveUpOptions(id)
{
    $("#"+id+" option:selected").each(function() {
        $(this).insertBefore($(this).prev());
    });
}

function moveDownOptions(id)
{
    $.fn.reverse = [].reverse;
    $("#"+id+" option:selected").reverse().each(function() {
        $(this).insertAfter($(this).next());
    });
}

function removeOptions(id)
{
    $("#"+id+" option:selected").each(function() {
        $(this).remove();
    });
}

function moveOptions(fromId, toId)
{
    $("#"+fromId+" option:selected").each(function() {
        $(this).appendTo("#"+toId);
    });
}

function selectOptions(id)
{
    $("#"+id+" option").each(function() {
        $(this).attr("selected", "selected");
    });
}