$(document).ready(function()
{
    $(document).on('click', '#nextBtn', function()
    {
        var data = $('#ajaxForm').serialize();
        $.ajax(
        {
            contentType: 'application/x-www-form-urlencoded',
            type: "POST",
            data: data,
            url: $('#ajaxForm').attr('action'),
            dataType: 'json',
            success: function(response)
            {
                if(response.result == 'fail') return bootbox.alert(response.message);
                if(response.result == 'success' && response.trade == 'yes')
                {
                    $('.reimburseTable').parents('#ajaxModal').load(createLink('refund', 'createTrade', 'type=' + response.type + '&refundID=' + response.refundID), '', function()
                    {
                        $.zui.ajustModalPosition();
                        $('.chosen').chosen();
                    });
                    return false;
                }
                else
                {
                    location.reload();
                }
            }
        });
        return false;
    })

    $('input[name=trade]').click(function()
    {
        if($(this).val() == 'yes')
        {
            $('#submit').text(v.next);
        }
        else
        {
            $('#submit').text(v.save);
        }
    })
});
