$(document).ready(function()
{
    $('.container > .nav > li').removeClass('active');
    $('.container > .nav > li').find('a[href*=' + v.platform + ']').parent('li').addClass('active');

    $.setAjaxDeleter('.entry-deleter', function(response)
    {   
        if(response.result == 'success')
        {   
            if(response.entries) 
            {   
                v.entries = JSON.parse(response.entries);
                $.refreshDesktop(v.entries, true);
            }   
        }   
    }); 

    $('#entryList').sortable(
    {
        selector: 'li',
        dragCssClass: 'drag-row',
        trigger: '.sort-handler-1',
        finish: function(e)
        {
            var orders = {};
            var orderNext = 1;
            e.list.each(function(index, data)
            {
                orders[data.item.data('entryid')] = orderNext++;
            });
            $.post(createLink('entry', 'customSort'), orders);
        }
    });
    $('#entryList .ulGrade2').sortable(
    {
        selector: 'li',
        dragCssClass: 'drag-row',
        trigger: '.sort-handler-2',
        finish: function(e)
        {
            var orders = {};
            var orderNext = 1;
            e.list.each(function(index, data)
            {
                orders[data.item.data('entryid')] = orderNext++;
            });
            $.post(createLink('entry', 'customSort'), orders);
            window.parent.location.reload();
        }
    });
});
