// JavaScript Document
function loadclientTo() {
    var clientidfrom = document.getElementById("clientidfrom").value;

    if (clientidfrom != "-1") {
        //get clientto Data
        $('#clientTo').load('transferclientccountsController.php?do=loadClientExceptId&clientidfrom=' + clientidfrom + '', function (response, status, xhr) {
            $(".selectx1").select2();
            //get clientfrom value
            $.ajax({
                url: 'transferclientccountsController.php?do=getclientValue&clientidfrom=' + clientidfrom,
                success: function (x) {
                    x = Number(x);
                    document.getElementById("clientcurrentvalue").value = x;
                }
            });
        });
        return false;
    }
}


$('#clientTrnMnyBtn').live('click', function (e) {
    var clientfrom = $('#clientidfrom').val();
    var clientto = $('#clientidto').val();

    var value = $('#transfermoneyvalue').val();
    value = value.trim();
    if (clientfrom == '-1') {
        $('#fromError').show();
        $('#fromError').html("<p style='color: #CC3333;border: 1px solid #CC3333;width: 69px;'>*اختر عميل</p>");
    } else if (clientto == '-1') {
        $('#fromError').hide();
        $('#toError').show();
        $('#toError').html("<p style='color: #CC3333;border: 1px solid #CC3333;width: 69px;'>*اختر عميل</p>");
    } else if (value == '' || value <= 0) {
        $('#fromError').hide();
        $('#toError').hide();
        $('#valueError').show();
        $('#valueError').html("<p style='color: #CC3333;border: 1px solid #CC3333;width: 120px;'>*ادخل القيمة المحولة</p>");
    } else if (value.length > 0) {
        $('#fromError').hide();
        $('#toError').hide();
        $('#valueError').hide();
        $('#myTranMnyform').submit();
        $('#clientTrnMnyBtn').attr("disabled", true);
    }
});
