function fnValidate1() {
    var himsValidator = [
                             new hims_ctl_val("ctl00_CP_FromClassDropDownList", "From Class", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_FromDivisionDropDownList", "From Division", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToBatchDropDownList", "To Batch", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToClassDropDownList", "To Class", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToDivisionDropDownList", "To Division", "T", "", "", "", 20)
    ];
    if (fnDoValidate(himsValidator))
        return true;
    else
        return false;
}
function fnValidate2() {
    var himsValidator = [
                             new hims_ctl_val('ctl00_CP_AdmissionDateDatePickerControl' + '_DateTextbox', "Admission Date", "T", "", "", "", 10),
                             new hims_ctl_val("ctl00_CP_FromClassDropDownList", "From Class", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_FromDivisionDropDownList", "From Division", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToOrganizationDropDownList", "To Organization", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToBatchDropDownList", "To Batch", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToClassDropDownList", "To Class", "T", "", "", "", 20),
                             new hims_ctl_val("ctl00_CP_ToDivisionDropDownList", "To Division", "T", "", "", "", 20)
    ];
    if (fnDoValidate(himsValidator))
        return true;
    else
        return false;
}
function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}

function FormatIt(obj) {
    if (obj.value.length == 2)
        obj.value = obj.value + "/";
    if (obj.value.length == 5)
        obj.value = obj.value + "/";
}

function LoadingMessage(msg1, msg2) {
    $('#dvTestLoadingmsg').show();
    $('#spn1msg').html(msg1);
    $('#spn2msg').html(msg2);
    $('.hls-bg').show();
}

function CloseLoadingpopup() {
    $('#dvTestLoadingmsg').hide();
    $('.hls-bg').hide();
}

function OpenFileUpload() {
    $('#flUpload').click();
}

var reader = new FileReader();
reader.onload = function (e) {
}

function readURL(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUpload();
    }
}

function ValidateImageDetails() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload').value;
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields;
        alert(fields);
        return false;
    }
    else {
        return true;
    }
}

function ajaxFileUpload() {
    if (ValidateImageDetails()) {
        LoadingMessage('Uploading', '<b>Please Wait</b>');
        $("#loading").ajaxStart(function () {
            $(this).show();
        }).ajaxComplete(function () {
            $(this).hide();
        });
        $.ajaxFileUpload({
            url: '/UserControls/MultiFileUpload/common-file-upload.ashx',
            secureuri: false,
            fileElementId: 'flUpload',
            dataType: 'text',
            contentType: "application/json; charset=utf-8",
            data: { name: 'logan', id: 'id', hdn: '1' },
            success: function (response, status) {
                if (response == "-007") {
                    alert('Cannot upload file as the used space exceeds allocated space')
                    return
                }
                if (response == "-008") {
                    alert('Invalid Extention')
                    return
                }
                if (response == "-009") {
                    alert('Cannot include / or .. in a filename')
                    return;
                }
                window.setTimeout(function () {
                    CloseLoadingpopup();
                    $("#UploadLabel").text("Uploaded Successfully");
                }, 100);
            },
            error: function (response, status, e) {
                window.setTimeout(function () {
                    CloseLoadingpopup();
                }, 100);
            }
        })
        return false;
    }
}