
function exchange(id, action) {
    if (action == 'remove') {
        document.getElementById('ref_id').value = id;
        document.getElementById('ref_act').value = action;
        document.getElementById('ref_price').value = 0;
        return document.getElementById('ref_form').submit();
    }
    var price = document.getElementById('price_' + id).value;
    if ( price != price*1 || price == 0 || price == '' || price < 0) {
        return alert('Цена должна быть указана числом, большим 0');
    }
    document.getElementById('ref_id').value = id;
    document.getElementById('ref_act').value = action;
    document.getElementById('ref_price').value = price;
    document.getElementById('ref_form').submit();
}

function checkBalance(balans, price) {
    if (balans < price) {
        alert('Пополните Ваш баланс');
        return false;
    }
}
$(document).ready(function()
    {
        $("#exchange").tablesorter();
    }
);
