//function cpageLoad() {
//	var browser=navigator.userAgent.toLowerCase();
//	if(browser.indexOf('firefox')>=0){		
//		$("#ctl00_CP_FileUpload1").fileUpload({
//			'uploader' : '../../../UserControls/MultiFileUpload/uploader.swf',
//			'cancelImg': '../../../Images/cancel.png',
//			'script': '../../../UserControls/MultiFileUpload/Upload.ashx?ASPSESSID=' + $('#ctl00_CP_hdnSessionid').val(),
//			'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
//			'multi': false,
//			'auto': true
//		});
//	}
//	else {
//		$("#ctl00_CP_FileUpload1").fileUpload({
//			'uploader': '../../../UserControls/MultiFileUpload/uploader.swf',
//			'cancelImg': '../../../Images/cancel.png',
//			'script': '../../../UserControls/MultiFileUpload/Upload.ashx',
//			'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
//			'multi': false,
//			'auto': true
//		});
//	}
//}

var DocId = "";
var reader = new FileReader();
var filename = '';
var CodeName = '';
var AssignFor = '';
var fileUploadName = '';
reader.onload = function (e) {
}
function readURL(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);

        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure3();
        }
        else {
            ajaxFileUpload();
        }
    }
}

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


///Start

function readURLNew(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUploadNew();
    }
}
function OpenFileUploadNew(Code) {
    CodeName = Code;
    $('#flUpload1').click();
}


//Mobile Student
function readURLMobile(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUploadMobile();
    }
}
function OpenFileUploadMobile(Code) {
    CodeName = Code;
    AssignFor = 'Student';
    $('#flUpload1').click();
    fileUploadName = 'flUpload1';
}
//Mobile Father
function MobilereadURLFather(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUploadMobile();
    }
}
function MobileOpenFileUploadFather(Code) {
    CodeName = Code;
    AssignFor = 'Father';
    $('#MobileFileUploadFather').click();
    fileUploadName = 'MobileFileUploadFather';
}
//Mobile Mother
function MobilereadURLMother(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUploadMobile();
    }
}
function MobileOpenFileUploadMother(Code) {
    CodeName = Code;
    AssignFor = 'Mother';
    $('#MobileFileUploadMother').click();
    fileUploadName = 'MobileFileUploadMother';
}
//Mobile Relative
function MobilereadURLRelative(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUploadMobile();
    }
}
function MobileOpenFileUploadRelative(Code) {
    CodeName = Code;
    //Changed for mantis : 36268 by Nilesh
    AssignFor = 'Relative';
    $('#MobileFileUploadRelative').click();
    fileUploadName = 'MobileFileUploadRelative';
}

//Employee
function readURLEmployee(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUpload2();
    }
}
function OpenFileUploadEmployee(Code) {
    CodeName = Code;
    AssignFor = 'Employee';
    $('#flUpload1').click();
    fileUploadName = 'flUpload1';
}

//Student
function readURL2(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUpload2();
    }
}
function OpenFileUpload2(Code) {
    CodeName = Code;
    AssignFor = 'Student';
    $('#flUpload1').click();
    fileUploadName = 'flUpload1';
}
//Father
function OpenFileUploadFather(Code) {
    CodeName = Code;
    AssignFor = 'Father';
    $('#FileUploadFather').click();
    fileUploadName = 'FileUploadFather';
}
function readURLFather(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUpload2();
    }
}
//Mother
function OpenFileUploadMother(Code) {
    CodeName = Code;
    AssignFor = 'Mother';
    $('#FileUploadMother').click();
    fileUploadName = 'FileUploadMother';
}
function readURLMother(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUpload2();
    }
}
//Relative
function OpenFileUploadRelative(Code) {
    CodeName = Code;
    AssignFor = 'Relative';
    $('#FileUploadRelative').click();
    fileUploadName = 'FileUploadRelative';
}
function readURLRelative(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        ajaxFileUpload2();
    }
}
function ajaxFileUploadNew() {
    if (ValidateImageDetails1()) {
        if (ValidateImageSize1()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/ClassWise_file_upload.ashx?Code=' + CodeName + '',
                secureuri: false,
                fileElementId: 'flUpload1',
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        if (CodeName == '')
                            $("#ctl00_CP_AssignOptionalFeeTabContainer_AssignOptionalFeeHeadTabPanel_Label3").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}

function ajaxFileUpload2() {
    if (ValidateImageDetails2()) {
        if (ValidateImageSize2()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/ClassWise_file_upload.ashx?Code=' + CodeName + '_' + AssignFor + '',
                secureuri: false,
                fileElementId: fileUploadName,
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_Label2").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}

function ajaxFileUploadMobile() {
    if (MobileValidateImageDetails()) {
        if (ValidateImageSize2()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/Mobile_file_upload.ashx?Code=' + CodeName + '_' + AssignFor + '',
                secureuri: false,
                fileElementId: fileUploadName,
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    //window.setTimeout(function () {
                    //    CloseLoadingpopup();
                    //    $("#ctl00_CP_Label2").text("Uploaded Successfully");
                    //}, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}

//End

function LoadingMessage(msg1, msg2) {
    $('#dvTestLoadingmsg').show();
    $('#spn1msg').html(msg1);
    $('#spn2msg').html(msg2);
    $('.hls-bg').show();
}
function CloseLoadingpopup() {
    $('#dvTestLoadingmsg').hide();
    $('.hls-bg').hide();
}
function ajaxFileUpload() {
    if (ValidateImageDetails()) {
        if (ValidateImageSize()) {
            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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_AssignOptionalFeeTabContainer_AssignOptionalFee_Label2").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function isFile(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    var doc = /\.(doc|)$/i;
    var txt = /\.(txt|)$/i;
    var jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var pdf = /\.(pdf|)$/i;

    var count = document.getElementById('flUpload').files;
    var fileValu = document.getElementById('flUpload');

    var count_file = 0;

    for (var i = 0; i < count.length; i++) {
        var t = fileValu.files[i].name.split('.').pop();

        if (t.toLowerCase() == "jpg" || t.toLowerCase() == "jpeg" || t.toLowerCase() == "png" || t.toLowerCase() == "pdf" || t.toLowerCase() == "doc" || t.toLowerCase() == "docx") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }
    //if (count_file > 0) {
    //    return true;
    //}
    //else
    //    return false;
}

function isDocument(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    var doc = /\.(doc|)$/i;
    var txt = /\.(txt|)$/i;
    var jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var pdf = /\.(pdf|)$/i;

    var count = document.getElementById('DocumentFileUpload').files;
    var fileValu = document.getElementById('DocumentFileUpload');

    var count_file = 0;

    for (var i = 0; i < count.length; i++) {
        var t = fileValu.files[i].name.split('.').pop();

        if (t.toLowerCase() == "jpg" || t.toLowerCase() == "jpeg" || t.toLowerCase() == "png" || t.toLowerCase() == "pdf" || t.toLowerCase() == "doc" || t.toLowerCase() == "docx") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }
    //if (count_file > 0) {
    //    return true;
    //}
    //else
    //    return false;
}

function isFile2(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    var doc = /\.(doc|)$/i;
    var txt = /\.(txt|)$/i;
    var jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var pdf = /\.(pdf|)$/i;

    var count = document.getElementById('flUpload1').files;
    var fileValu = document.getElementById('flUpload1');

    var count_file = 0;

    for (var i = 0; i < count.length; i++) {
        var t = fileValu.files[i].name.split('.').pop();

        if (t.toLowerCase() == "jpg" || t.toLowerCase() == "jpeg" || t.toLowerCase() == "png") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }
    //if (count_file > 0) {
    //    return true;
    //}
    //else
    //    return false;
}

function ValidateImageDetails() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload').value;
    var count = document.getElementById('flUpload').files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;

    //for (var i = 0; i < count.length; i++) {
    //    iSizeKB = ($("#flUpload")[0].files[i].size / 1024);
    //    Size = (Math.round((iSizeKB / 1024) * 100) / 100);
    //    var fileValu = document.getElementById('flUpload');
    //    if (Size > 1) {
    //        alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
    //        return false;
    //    }
    //    else if (iSizeKB > SizeLimit) {
    //        alert('Image size not according to configuration');
    //        return false;
    //    }
    //}
    //var filesize = this..size / 1024 / 1024;
    //if (isFile(document.getElementById('flUpload').value) == false || document.getElementById('flUpload').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }
}
function ValidateImageSize() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload').value;
    var count = document.getElementById('flUpload').files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;

    for (var i = 0; i < count.length; i++) {
        iSizeKB = ($("#flUpload")[0].files[i].size / 1024);
        //Size = (Math.round((iSizeKB / 1024) * 100) / 100);
        var fileValu = document.getElementById('flUpload');

        if ($('#ctl00_CP_AttachmentSizeHiddenField').val() != '') {
            if (iSizeKB > $('#ctl00_CP_AttachmentSizeHiddenField').val()) {
                alert('File should be less than ' + $('#ctl00_CP_AttachmentSizeHiddenField').val() + ' KB');
                return false;
            }

            else {
                return true;
            }
        }
        else {
            return true;
        }

    }

}
function ValidateStudentImageSize() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload').value;
    var count = document.getElementById('flUpload').files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;

    for (var i = 0; i < count.length; i++) {
        iSizeKB = ($("#flUpload")[0].files[i].size / 1024);
        //Size = (Math.round((iSizeKB / 1024) * 100) / 100);
        var fileValu = document.getElementById('flUpload');

        if ($('#ctl00_CP_AttachmentSizeHiddenField').val() != '') {
            if (iSizeKB > $('#ctl00_CP_AttachmentSizeHiddenField').val()) {
                alert('File should be less than ' + $('#ctl00_CP_AttachmentSizeHiddenField').val() + ' KB');
                return false;
            }

            else {
                return true;
            }
        }
        else {
            return true;
        }

    }

}
function ValidateDocumentDetails() {
    var fields;
    fields = "";
    var file = document.getElementById('DocumentFileUpload').value;
    var count = document.getElementById('DocumentFileUpload').files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;

    for (var i = 0; i < count.length; i++) {
        iSizeKB = ($("#DocumentFileUpload")[0].files[i].size / 1024);
        Size = (Math.round((iSizeKB / 1024) * 100) / 100);
        var fileValu = document.getElementById('DocumentFileUpload');
        if (Size > 1) {
            alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
            return false;
        }
        else if (iSizeKB > SizeLimit) {
            alert('Image size not according to configuration');
            return false;
        }
    }
    //var filesize = this..size / 1024 / 1024;
    //if (isDocument(document.getElementById('DocumentFileUpload').value) == false || document.getElementById('DocumentFileUpload').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }
}

function ValidateImageDetails1() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload1').value;
    var count = document.getElementById('flUpload1').files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;
    //for (var i = 0; i < count.length; i++) {
    //    iSizeKB = ($("#flUpload1")[0].files[i].size / 1024);
    //    Size = (Math.round((iSizeKB / 1024) * 100) / 100);
    //    iSizeKB = ($("#flUpload1")[0].files[i].size / 1024);
    //    //alert(Size);
    //    var fileValu = document.getElementById('flUpload1');
    //    if (Size > 1) {
    //        alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
    //        return false;
    //    }
    //    else if (iSizeKB > SizeLimit) {
    //        alert('Image size not according to configuration');
    //        return false;
    //    }
    //}

    //var filesize = this..size / 1024 / 1024;
    //if (isFile(document.getElementById('flUpload1').value) == false || document.getElementById('flUpload1').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    //if (Size > 1) {
    //    alert('File should be less than 1 MB');
    //    return false;
    //}
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }
}
function ValidateImageSize1() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload1').value;
    var count = document.getElementById('flUpload1').files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;
    for (var i = 0; i < count.length; i++) {
        iSizeKB = ($("#flUpload1")[0].files[i].size / 1024);
        //Size = (Math.round((iSizeKB / 1024) * 100) / 100);
        //iSizeKB = ($("#flUpload1")[0].files[i].size / 1024);
        //alert(Size);
        var fileValu = document.getElementById('flUpload1');
        //if (Size > 1) {
        //    alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
        //    return false;
        //}
        if ($('#ctl00_CP_AttachmentSizeHiddenField').val() != '') {
            if (iSizeKB > $('#ctl00_CP_AttachmentSizeHiddenField').val()) {
                alert('File should be less than ' + $('#ctl00_CP_AttachmentSizeHiddenField').val() + ' KB');
                return false;
            }

            else {
                return true;
            }
        }
        else {
            return true;
        }
    }

}
function ValidateImageDetails2() {
    var fields;
    fields = "";
    var file = document.getElementById(fileUploadName).value;
    var count = document.getElementById(fileUploadName).files;
    var iSize = 0;
    var Size = 0;
    for (var i = 0; i < count.length; i++) {
        iSize = ($("#" + fileUploadName + "")[0].files[i].size / 1024);
        iSize = (Math.round((iSize / 1024) * 100) / 100);
        Size = iSize;
        //alert(Size);
        var fileValu = document.getElementById(fileUploadName);
        //if (Size > 1) {
        //    alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
        //}
    }

    //var filesize = this..size / 1024 / 1024;
    //if (isFile2(document.getElementById(fileUploadName).value) == false || document.getElementById(fileUploadName).value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    //if (Size > 1) {
    //    alert('File should be less than 1 MB');
    //    return false;
    //}
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }


}

function MobileValidateImageDetails() {
    var fields;
    fields = "";
    var file = document.getElementById(fileUploadName).value;
    var count = document.getElementById(fileUploadName).files;
    var iSize = 0;
    var Size = 0;
    for (var i = 0; i < count.length; i++) {
        iSize = ($("#" + fileUploadName + "")[0].files[i].size / 1024);
        iSize = (Math.round((iSize / 1024) * 100) / 100);
        Size = iSize;
        //alert(Size);
        var fileValu = document.getElementById(fileUploadName);
        //if (Size > 1) {
        //    alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
        //}
    }

    //var filesize = this..size / 1024 / 1024;
    //if (isFile2(document.getElementById(fileUploadName).value) == false || document.getElementById(fileUploadName).value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    //if (Size > 1) {
    //    alert('File should be less than 1 MB');
    //    return false;
    //}
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }


}
function OpenFileUploadGrid(documentid) {
    $('#NewUpload').click();
    DocId = documentid;

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

        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure();
        }
        else {
            ajaxFileUploadGrid();
        }
    }
}
function OpenFileUploadGrid2(documentid) {
    $('#NewUpload').click();
    DocId = documentid;

}
function OpenFileUploadGrid3(documentid) {
    $('#DocumentFileUpload').click();
    DocId = documentid;

}

function OpenFileUploadGrid4(documentid) {
    $('#NewUpload').click();
    DocId = documentid;

}
function OpenFileUploadGrid5(documentid) {
    $('#NewUpload').click();
    DocId = documentid;

}
function readURLGrid5(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        console.log(DocId);
        $("#ctl00_CP_DocumentId").val(DocId);
        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure5();
        }
        else {
            ajaxFileUploadGrid3();
        }
    }
}
function OpenFileUploadGrid6(documentid) {
    $('#NewUpload').click();
    DocId = documentid;

}
function readURLGrid6(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        console.log(DocId);
        $("#ctl00_CP_DocumentId").val(DocId);
        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure6();
        }
        else {
            ajaxFileUploadGrid4();
        }
    }
}

function readURLGrid4(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadEmployeeDocumentTabContainer_UploadEmployeeDocument1_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure4();
        }
        else {
            ajaxFileUploadGrid2();
        }
    }
}

function readURLGrid2(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);

        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure2();
        }
        else {
            ajaxFileUploadGrid();
        }
    }
}
function readURLGrid3(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        console.log(DocId);
        $("#ctl00_CP_DocumentId").val(DocId);
        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure2();
        }
        else {
            ajaxFileUploadGrid();
        }
    }
}
function readURLDocument(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);

        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxDocumentUploadAzure();
        }
        else {
            ajaxDocumentUploadGrid();
        }
    }
}
function isFileGrid(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    var doc = /\.(doc|)$/i;
    var txt = /\.(txt|)$/i;
    var jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var pdf = /\.(pdf|)$/i;

    var count = document.getElementById('NewUpload').files;
    var fileValu = document.getElementById('NewUpload');

    var count_file = 0;

    for (var i = 0; i < count.length; i++) {
        var t = fileValu.files[i].name.split('.').pop();

        if (t.toLowerCase() == "jpg" || t.toLowerCase() == "jpeg" || t.toLowerCase() == "png" || t.toLowerCase() == "pdf" || t.toLowerCase() == "doc" || t.toLowerCase() == "docx") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }

}
function ValidateImageDetailsgrid() {
    var fields;
    fields = "";
    var file = document.getElementById('NewUpload').value;
    var count = document.getElementById('NewUpload').files;
    var iSize = 0;
    var Size = 0;
    for (var i = 0; i < count.length; i++) {
        iSize = ($("#NewUpload")[0].files[i].size / 1024);
        //iSize = (Math.round((iSize / 1024) * 100) / 100);
        Size = iSize;
        var fileValu = document.getElementById('NewUpload');
        //if (Size > 1) {
        //    alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
        //}
    }
    //if (isFileGrid(document.getElementById('NewUpload').value) == false || document.getElementById('NewUpload').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}

    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }


}
function ValidateStudentDocument() {
    var fields;
    fields = "";
    var file = document.getElementById('NewUpload').value;
    var count = document.getElementById('NewUpload').files;
    var iSize = 0;
    var Size = 0;
    for (var i = 0; i < count.length; i++) {
        iSize = ($("#NewUpload")[0].files[i].size / 1024);
        //iSize = (Math.round((iSize / 1024) * 100) / 100);
        Size = iSize;
        var fileValu = document.getElementById('NewUpload');
        if ($('#ctl00_CP_AttachmentSizeHiddenField').val() != '') {

            if (Size > $('#ctl00_CP_AttachmentSizeHiddenField').val()) {
                alert('File should be less than ' + $('#ctl00_CP_AttachmentSizeHiddenField').val() + ' KB');
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }


}
function ajaxFileUploadGrid() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/common-file-upload.ashx?DocId=' + DocId,
                secureuri: false,
                fileElementId: 'NewUpload',
                dataType: 'text',
                contentType: "application/json; charset=utf-8",
                data: { name: 'logan', id: 'id', hdn: '1' },
                success: function (response, status) {

                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_Label2").text("Uploaded Successfully");
                        $('#ctl00_CP_DocumentGridView_ctl02_DocumentRefreshbutton').click();
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadGrid3() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/common-file-upload.ashx?DocId=' + DocId,
                secureuri: false,
                fileElementId: 'NewUpload',
                dataType: 'text',
                contentType: "application/json; charset=utf-8",
                data: { name: 'logan', id: 'id', hdn: '1' },
                success: function (response, status) {

                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_Label2").text("Uploaded Successfully");
                        $('#ctl00_CP_StudentDocumentMasterGridView_ctl02_StudentDocumentRefreshbutton').click();
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadGrid4() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/common-file-upload.ashx?DocId=' + DocId,
                secureuri: false,
                fileElementId: 'NewUpload',
                dataType: 'text',
                contentType: "application/json; charset=utf-8",
                data: { name: 'logan', id: 'id', hdn: '1' },
                success: function (response, status) {

                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_UploadStudentDocumentTabContainer_UploadEmployeeDocument11_Label2").text("Uploaded Successfully");
                        $('#ctl00_CP_EmployeeDocumentMasterGridView_ctl02_EmployeeDocumentRefreshbutton').click();
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadGrid2() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/common-file-upload.ashx?DocId=' + DocId,
                secureuri: false,
                fileElementId: 'NewUpload',
                dataType: 'text',
                contentType: "application/json; charset=utf-8",
                data: { name: 'logan', id: 'id', hdn: '1' },
                success: function (response, status) {

                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_UploadEmployeeDocumentTabContainer_UploadEmployeeDocument1_Label2").text("Uploaded Successfully");
                        $('#ctl00_CP_DocumentGridView_ctl02_DocumentRefreshbutton').click();
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxDocumentUploadGrid() {
    if (ValidateStudentDocumentDigitalForm()) {
        LoadingMessage('Uploading', '<b>Please Wait</b>');
        $("#loading").ajaxStart(function () {
            $(this).show();
        }).ajaxComplete(function () {
            $(this).hide();
        });
        $.ajaxFileUpload({
            url: '/UserControls/MultiFileUpload/common-file-upload.ashx?DocId=' + DocId,
            secureuri: false,
            fileElementId: 'DocumentFileUpload',
            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();
                    //$("#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_Label2").text("Uploaded Successfully");
                    //$('#ctl00_CP_DocumentGridView_ctl02_DocumentRefreshbutton').click();
                }, 100);
            },
            error: function (response, status, e) {
                window.setTimeout(function () {
                    CloseLoadingpopup();
                }, 100);
            }
        })
        return false;
    }
}
function ajaxFileUploadAzure() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = 11;
            var UserSourceTypeId = $('#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                secureuri: false,
                fileElementId: 'NewUpload',
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();

                        $("#ctl00_CP_UploadStudentDocumentTabContainer_UploadStudentDocument11_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadAzure2() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = $('#ctl00_CP_ScreenIdHiddenField').val();
            var UserSourceTypeId = $('#ctl00_CP_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                secureuri: false,
                fileElementId: 'NewUpload',
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $('#ctl00_CP_DocumentGridView_ctl02_DocumentRefreshbutton').click();
                        $("#ctl00_CP_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadAzure5() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = $('#ctl00_CP_ScreenIdHiddenField').val();
            var UserSourceTypeId = $('#ctl00_CP_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                secureuri: false,
                fileElementId: 'NewUpload',
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $('#ctl00_CP_StudentDocumentMasterGridView_ctl02_StudentDocumentRefreshbutton').click();
                        $("#ctl00_CP_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadAzure6() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = $('#ctl00_CP_ScreenIdHiddenField').val();
            var UserSourceTypeId = $('#ctl00_CP_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                secureuri: false,
                fileElementId: 'NewUpload',
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $('#ctl00_CP_EmployeeDocumentMasterGridView_ctl02_EmployeeDocumentRefreshbutton').click();
                        $("#ctl00_CP_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxDocumentUploadAzure() {
    if (ValidateStudentDocumentDigitalForm()) {
        LoadingMessage('Uploading', '<b>Please Wait</b>');
        $("#loading").ajaxStart(function () {
            $(this).show();
        }).ajaxComplete(function () {
            $(this).hide();
        });
        var ScreenTypeId = $('#ctl00_CP_ScreenIdHiddenField').val();
        var UserSourceTypeId = $('#ctl00_CP_UserSourceTypeHiddenField').val();
        var UserSourceId = $('#ctl00_CP_UserSourceIdHiddenField').val();
        var DocumentId = 0;
        DocumentId = DocId;
        var DocumentName = filename;
        var GUID = 1;
        if ($('#ctl00_CP_GUIDHiddenField').val() != '')
            GUID = $('#ctl00_CP_GUIDHiddenField').val();
        $.ajaxFileUpload({
            url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
            secureuri: false,
            fileElementId: 'DocumentFileUpload',
            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;
                }
                /*var str = response;
				str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
				str = str.replace('</pre>','');				
				$('#hdnFileName').val(str);*/
                window.setTimeout(function () {
                    CloseLoadingpopup();
                    //$('#ctl00_CP_DigitalFormGridView_ctl02_DocumentFileRefresh').click();
                    //$("#ctl00_CP_Label2").text("Uploaded Successfully");
                }, 100);
            },
            error: function (response, status, e) {
                window.setTimeout(function () {
                    CloseLoadingpopup();
                }, 100);
            }
        })
        return false;
    }
}
function ajaxFileUploadAzure4() {
    if (ValidateImageDetailsgrid()) {
        if (ValidateStudentDocument()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = 12;
            var UserSourceTypeId = $('#ctl00_CP_UploadEmployeeDocumentTabContainer_UploadEmployeeDocument1_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UploadEmployeeDocumentTabContainer_UploadEmployeeDocument1_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                secureuri: false,
                fileElementId: 'NewUpload',
                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();

                        $("#ctl00_CP_UploadEmployeeDocumentTabContainer_UploadEmployeeDocument1_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadAzure3() {
    if (ValidateImageDetails()) {
        if (ValidateImageSize()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = $('#ctl00_CP_ScreenIdHiddenField').val();
            var UserSourceTypeId = $('#ctl00_CP_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            if (DocId != '')
                DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '' || $('#ctl00_CP_GUIDHiddenField').val() != undefined)
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                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;
                    }
                    /*var str = response;
                    str = str.replace('<pre style="word-wrap: break-word; white-space: pre-wrap;">','');
                    str = str.replace('</pre>','');				
                    $('#hdnFileName').val(str);*/
                    window.setTimeout(function () {
                        CloseLoadingpopup();

                        $("#ctl00_CP_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function checkallDocumnet(obj) {
    if ($(obj).is(':checked')) {
        $('input:checkbox').attr('checked', 'checked');
    }
    else
        $('input:checkbox').removeAttr('checked');
}
function OpenFileUploadDocument() {
    var a = $('#ctl00_CP_DocumentDropDownList').val();
    //alert(a);
    if (a > 0) {
        OpenFileUploadGrid(a);
    }
    else {
        alert('Please Select Document..!!');
    }
}
function ValidateImageSize2() {
    var fields;
    fields = "";
    var file = document.getElementById(fileUploadName).value;
    var count = document.getElementById(fileUploadName).files;
    var Size = 0;
    var SizeLimit = $("input[type='hidden'][id$='ImageMaxSize']").val()
    var iSizeKB = 0;
    for (var i = 0; i < count.length; i++) {
        iSizeKB = ($("#" + fileUploadName + "")[0].files[i].size / 1024);
        //Size = (Math.round((iSizeKB / 1024) * 100) / 100);
        //iSizeKB = ($("#" + fileUploadName + "")[0].files[i].size / 1024);
        //alert(Size);
        var fileValu = document.getElementById(fileUploadName);
        //if (Size > 1) {
        //    alert('File ' + fileValu.files[i].name + ' should be less than 1 MB');
        //    return false;
        //}
        if ($('#ctl00_CP_AttachmentSizeHiddenField').val() != '') {
            if (iSizeKB > $('#ctl00_CP_AttachmentSizeHiddenField').val()) {
                alert('File should be less than ' + $('#ctl00_CP_AttachmentSizeHiddenField').val() + ' KB');
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }

}


function UploadStudentPhotoreadURL(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);

        filename = input.files[0].name;
        if ($('#ctl00_CP_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxStudentPhotoUploadAzure3();
        }
        else {
            ajaxStudentPhotoUpload();
        }
    }
}
function ajaxStudentPhotoUploadAzure3() {
    if (ValidateImageDetails()) {
        if (ValidateStudentImageSize()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = $('#ctl00_CP_ScreenIdHiddenField').val();
            var UserSourceTypeId = $('#ctl00_CP_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_UserSourceIdHiddenField').val();
            var DocumentId = 0;
            if (DocId != '')
                DocumentId = DocId;
            var DocumentName = filename;
            var GUID = 1;
            if ($('#ctl00_CP_GUIDHiddenField').val() != '' || $('#ctl00_CP_GUIDHiddenField').val() != undefined)
                GUID = $('#ctl00_CP_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                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();

                        $("#ctl00_CP_Label2").text("Uploaded Successfully");

                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxStudentPhotoUpload() {
    if (ValidateImageDetails()) {
        if (ValidateStudentImageSize()) {
            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();
                        $("#ctl00_CP_AssignOptionalFeeTabContainer_AssignOptionalFee_Label2").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}

function ValidateStudentDocumentDigitalForm() {
    var file = document.getElementById('DocumentFileUpload').value;
    var count = document.getElementById('DocumentFileUpload').files;
    var iSize = 0;
    for (var i = 0; i < count.length; i++) {
        iSize = ($("#DocumentFileUpload")[0].files[i].size / 1024);
        //iSize = (Math.round((iSize / 1024) * 100) / 100);

        if ($('#ctl00_CP_AttachmentSizeHiddenField').val() != '') {
            if (iSize > $('#ctl00_CP_AttachmentSizeHiddenField').val()) {
                alert('File should be less than ' + $('#ctl00_CP_AttachmentSizeHiddenField').val() + ' KB');
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }
}