$(document).ready(function()
{
    $.setAjaxJSONER('.review', function(response)
    {
        if(response.message)
        {
            bootbox.alert(response.message);
        }

        /* If the response has locate param, locate the browse. */
        if(response.locate == 'reload') return location.href = location.href;
        if(response.locate) return location.href = response.locate;
    });

    /* expand active tree. */
    $('.tree').tree('expandSelect', '.active');

    $(document).on('click', '.deleteTrip', function()
    {
        if(confirm(v.lang.confirmDelete))
        {
            $(this).text(v.lang.deleting);
            $.getJSON($(this).attr('href'), function(data)
            {
                if(data.result == 'success')
                {
                    if(data.locate) return location.href = data.locate;
                    return location.reload();
                }
                else
                {
                    alert(data.message);
                    if(selecter.parents('#ajaxModal').size()) return $.reloadAjaxModal(1200);
                    return location.reload();
                }
            });
        }
        return false;
    });

});
