function checkall(clickchk, relChkbox) {

    var checker = $('#' + clickchk);
    var multichk = $('.' + relChkbox);


    checker.click(function () {
        multichk.prop('checked', $(this).prop('checked'));
    });
}


function multiCheck(tb_var) {
    tb_var.on("change", ".chk-parent", function () {
        var e = $(this).closest("table").find("td:first-child .child-chk"), a = $(this).is(":checked");
        $(e).each(function () {
            a ? ($(this).prop("checked", !0), $(this).closest("tr").addClass("active")) : ($(this).prop("checked", !1), $(this).closest("tr").removeClass("active"))
        })
    }),
        tb_var.on("change", "tbody tr .new-control", function () {
            $(this).parents("tr").toggleClass("active")
        })
}

function checkall(clickchk, relChkbox) {

    var checker = $('#' + clickchk);
    var multichk = $('.' + relChkbox);


    checker.click(function () {
        multichk.prop('checked', $(this).prop('checked'));
    });
}

function GetIEVersion() {
    var sAgent = window.navigator.userAgent;
    var Idx = sAgent.indexOf("MSIE");

    // If IE, return version number.
    if (Idx > 0)
        return parseInt(sAgent.substring(Idx + 5, sAgent.indexOf(".", Idx)));

    // If IE 11 then look for Updated user agent string.
    else if (!!navigator.userAgent.match(/Trident\/7\./))
        return 11;

    else
        return 0; //It is not IE
}


function AjaxUploadResponse(phpurl, phpdata) {

    path = localStorage.getItem("path");
    var return_val = '';
    $.ajax({
        cache: false,
        contentType: false,
        processData: false,
        type: "POST",
        async: false,
        url: path + phpurl,
        beforeSend: function () {
        },
        dataType: 'json',
        data: phpdata,
        success: function (data) {
            return_val = data;
        },
        error: function (xhr, status, text) {
            console.log('Failure! ' + text);
        }
    });
    return return_val;
}


function AjaxRequest(phpurl, phpdata, divid) {

    path = localStorage.getItem("path");
    //alert(phpurl+phpdata);
    $.ajax({
        cache: false,
        type: "POST",
        url: path + phpurl,
        beforeSend: function () {
            $("#" + divid).html('<div class="spinner-grow text-warning align-self-center" style="width: 50px;height: 50px;margin: 50px;"></div>');
            $("#" + divid).fadeIn('fast');
        },
        dataType: "html",
        data: phpdata,
        success: function (data) {
            $("#" + divid).html(data);
            $("#" + divid).fadeIn('slow');
        },
        error: function (xhr, status, text) {
            console.log('Failure! ' + text);
        }
    });
}

function AjaxResponse(phpurl, phpdata) {
    path = localStorage.getItem("path");
    var return_val = '';
    $.ajax({
        cache: false,
        type: "POST",
        async: false,
        url: path + phpurl,
        beforeSend: function () {
            console.log('beforeSend! ' + phpurl + "?" + phpdata);
        },
        dataType: "json",
        data: phpdata,
        success: function (data) {
            return_val = data;
        },
        error: function (xhr, status, text) {
            console.log('Failure! ' + phpurl + "?" + phpdata);
        }
    });
    return return_val;
}

function ClearForm(modalid) {
    $("#" + modalid + " form input").val('');
    $("#" + modalid + " form select").val('');
    $("#" + modalid + " form textarea").html('');
}
