
function checkitem(checkBox, textBox1) {
    var e = document.getElementById(textBox1.id);
    var f = document.getElementById(checkBox.id);
    if (f.checked == true) {
        e.disabled = true;
    }
    else {
        e.disabled = false;
    }
}

var reader = new FileReader();
var filename = '';
var ScreenId = '';
reader.onload = function (e) {
}
function readURL(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        filename = input.files[0].name;
        ScreenId = '2';
        if ($('#ctl00_CP_LearningTabContainer_LearningDetails_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzure();
        }
        else {
            ajaxFileUpload();
        }
    }
}
function readResourceURL(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        filename = input.files[0].name;
        ScreenId = '19';
        if ($('#ctl00_CP_LearningTabContainer_LearningDetails_UploadConfigurationHiddenField').val() == "Azure") {
            ajaxFileUploadAzureNew();
        }
        else {
            ajaxFileUploadNew();
        }
        
    }
}
function readURL2(input) {

    if (input.files && input.files[0]) {
        var id = input.id;
        var file_size = (document.getElementById(id).files[0].size / 1024);
        //var file_size = (document.getElementById(id).files[0].size / (1024 * 1024));
        if ($('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_AttachmentSizeHiddenField').val() != '') {
            if (file_size >= $('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_AttachmentSizeHiddenField').val()) {
                alert('File size should be less than ' + $('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_AttachmentSizeHiddenField').val() + ' KB');
                return;
            }
        }

        var filename_valid = input.files[0].name.substr(0, input.files[0].name.lastIndexOf('.'));
        var format = /[!@#$%^&*()_+\=\[\]{};':"\\|,.<>\/?]+/;        

        if (format.test(filename_valid)) {
            alert("Cannot include special characters in file name");
            return;
        }
        
        
        if (input.files[0].name.substr(0, input.files[0].name.lastIndexOf(".")).length > 20) {
            alert('File Name should be of 20 characters or less');
        }
        else {
            document.getElementById("ctl00_CP_StudentViewTabContainer_SearchTabPanel_UploadButton").disabled = false;
            reader.readAsDataURL(input.files[0]);
            filename = input.files[0].name;
            $('#ctl00_CP_DocumentNameHiddenField').val(filename);
            if ($('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_UploadConfigurationHiddenField').val() == "Azure") {
                ajaxStudentFileUploadAzure();
            }
            else {
                ajaxFileUpload2();
            }
        }
    }
}
function MeetingAccountreadURL(input) {
    if (input.files && input.files[0]) {
        reader.readAsDataURL(input.files[0]);
        MeetingAccountajaxFileUpload();
    }
}
function OpenFileUpload() {
    $('#flUpload').click();
}
function OpenFileUpload1() {
    $('#FileUpload').click();
}
function OpenFileUpload2() {
    $('#flUpload2').click();
    document.getElementById("ctl00_CP_StudentViewTabContainer_SearchTabPanel_UploadButton").disabled = false;
}
function OpenMeetingAccountFileUpload() {
    $('#MeetingAccountflUpload').click();
}
//function StudentjoinMeeting() {
//    var form = document.createElement("form");
//    form.setAttribute('method', "post");
//    window.open("StudentZoomWebApp.aspx", "_blank");
//    window.document.forms[0].target = '_blank';
//    form.submit();
//}
function StudentjoinMeeting() {
    var MeetingProviderId = document.getElementById('ctl00_CP_StudentViewTabContainer_SearchTabPanel_MeetingProviderIdHiddenField').value;
    var MeetingCode = document.getElementById('ctl00_CP_StudentViewTabContainer_SearchTabPanel_MeetingCodeHiddenField').value;

    var Config = document.getElementById('ctl00_CP_StudentViewTabContainer_SearchTabPanel_ConfigTextBox').value;
    var AppPath = document.getElementById('ctl00_CP_StudentViewTabContainer_SearchTabPanel_AppPathTextBox').value;
    var IsLoginFlag = document.getElementById('ctl00_CP_StudentViewTabContainer_SearchTabPanel_IsLoginFlagTextBox').value;
    // var InstallStatus = document.getElementById('ctl00_CP_InstallStatusTextBox').value;

    if (MeetingProviderId == '1') {
        var form = document.createElement("form");
        form.setAttribute('method', "post");
        if (Config === "APP") {
            if (IsLoginFlag == "True") {
                alert('Already Login From Another System');
            }
            else {
                window.open(AppPath, "_blank");
            }

        }
        else {
            if (IsLoginFlag == "True") {
                alert('Already Login From Another System');
            }
            else {
                window.open("StudentZoomWebApp.aspx", "_blank");
            }
        }

        window.document.forms[0].target = '_blank';
        form.submit();
    }
    else if (MeetingProviderId == '2') {
        if (IsLoginFlag == "True") {
            alert('Already Login From Another System');
        }
        else {
            var form = document.createElement("form");
            form.setAttribute('method', "post");
            window.open(MeetingCode, "_blank");
            window.document.forms[0].target = '_blank';
            form.submit();
        }
    }
    else if (MeetingProviderId == '4') {
        if (IsLoginFlag == "True") {
            alert('Already Login From Another System');
        }
        else {
            var form = document.createElement("form");
            form.setAttribute('method', "post");
            window.open(MeetingCode, "_blank");
            window.document.forms[0].target = '_blank';
            form.submit();
        }
    }
    else if (MeetingProviderId == '5' || MeetingProviderId == '3') {
        if (IsLoginFlag == "True") {
            alert('Already Login From Another System');
        }
        else {
            var form = document.createElement("form");
            form.setAttribute('method', "post");
            window.open(MeetingCode, "_blank");
            window.document.forms[0].target = '_blank';
            form.submit();
        }
    }
    else {
        var form = document.createElement("form");
        form.setAttribute('method', "post");
        if (Config === "APP") {
            if (IsLoginFlag == "True") {
                alert('Already Login From Another System');
            }
            else {
                window.open(AppPath, "_blank");
            }

        }
        else {
            if (IsLoginFlag == "True") {
                alert('Already Login From Another System');
            }
            else {
                window.open("StudentZoomWebApp.aspx", "_blank");
            }
        }

        window.document.forms[0].target = '_blank';
        form.submit();

    }
}

//function AdminjoinMeeting() {
//    var MeetingProviderId = document.getElementById('ctl00_CP_MeetingProviderIdTextBox').value;
//    var MeetingCode = document.getElementById('ctl00_CP_MeetingCodeTextBox').value;

//    var Config = document.getElementById('ctl00_CP_ConfigTextBox').value;
//    var AppPath = document.getElementById('ctl00_CP_AppPathTextBox').value;
//   // var InstallStatus = document.getElementById('ctl00_CP_InstallStatusTextBox').value;
//    if (MeetingProviderId == '1') {
//        var form = document.createElement("form");
//        form.setAttribute('method', "post");
//        if (Config === "APP") {

//                window.open(AppPath, "_blank");

//        }
//        else {
//            window.open("AdminZoomWebApp.aspx", "_blank");
//        }

//        window.document.forms[0].target = '_blank';
//        form.submit();
//    }
//    else if (MeetingProviderId == '2') {

//        var form = document.createElement("form");
//        form.setAttribute('method', "post");
//        window.open(MeetingCode, "_blank");
//        window.document.forms[0].target = '_blank';
//        form.submit();
//    }
//    else if (MeetingProviderId == '4') {

//        var form = document.createElement("form");
//        form.setAttribute('method', "post");
//        window.open(MeetingCode, "_blank");
//        window.document.forms[0].target = '_blank';
//        form.submit();
//    }
//    else {

//        var form = document.createElement("form");
//        form.setAttribute('method', "post");
//        if (Config === "APP") {
//            //if (InstallStatus == '1') {
//            window.open(AppPath, "_blank");
//            //}
//            //else {
//            //    alert('Install Zoom App');
//            //}
//        }
//        else {
//            window.open("AdminZoomWebApp.aspx", "_blank");
//        }

//        window.document.forms[0].target = '_blank';
//        form.submit();

//    }
//}


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;
                    }
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                        $("#ctl00_CP_LearningTabContainer_LearningDetails_Label2").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadAzure() {
    if (ValidateImageDetails()) {
        if (ValidateImageSize()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = ScreenId;
            var UserSourceTypeId = $('#ctl00_CP_LearningTabContainer_LearningDetails_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_LearningTabContainer_LearningDetails_UserSourceIdHiddenField').val();
            var DocumentId = $('#ctl00_CP_LearningTabContainer_LearningDetails_DocumentIdHiddenField').val();
            var DocumentName = filename;
            var GUID = 0;
            if ($('#ctl00_CP_LearningTabContainer_LearningDetails_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_LearningTabContainer_LearningDetails_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();
                        //if ($('#ctl00_CP_LearningTabContainer_LearningDetails_UploadConfigurationHiddenField').val() == "Azure" && $('#ctl00_CP_LearningTabContainer_LearningDetails_DocumentIdHiddenField').val() != 0) {
                        //    AddtoDataSet();
                        //}
                        $("#ctl00_CP_LearningTabContainer_LearningDetails_Label2").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function ajaxFileUploadAzureNew() {
    if (ValidateResourceDetails()) {
        if (ValidateResourceSize()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            var ScreenTypeId = ScreenId;
            var UserSourceTypeId = $('#ctl00_CP_LearningTabContainer_LearningDetails_UserSourceTypeHiddenField').val();
            var UserSourceId = $('#ctl00_CP_LearningTabContainer_LearningDetails_UserSourceIdHiddenField').val();
            var DocumentId = $('#ctl00_CP_LearningTabContainer_LearningDetails_DocumentIdHiddenField').val();
            var DocumentName = filename;
            var GUID = 0;
            if ($('#ctl00_CP_LearningTabContainer_LearningDetails_GUIDHiddenField').val() != '')
                GUID = $('#ctl00_CP_LearningTabContainer_LearningDetails_GUIDHiddenField').val();
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
                secureuri: false,
                fileElementId: 'FileUpload',
                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 ($('#ctl00_CP_LearningTabContainer_LearningDetails_UploadConfigurationHiddenField').val() == "Azure" && $('#ctl00_CP_LearningTabContainer_LearningDetails_DocumentIdHiddenField').val() != 0) {
                        //    AddtoDataSet();
                        //}
                        $("#ctl00_CP_LearningTabContainer_LearningDetails_Label7").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function AddtoDataSet() {
    var Id = 0;
    Id = $('#ctl00_CP_LearningTabContainer_LearningDetails_DocumentIdHiddenField').val()
    var data = {
        "DocumentId": Id,
        "FileName": filename
    };
    $.ajax({
        type: "POST",
        url: "/Pages/OnlineLearning/OnlineLearning.aspx/AddtoDataSet",
        data: JSON.stringify(data),
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt) {
            //var datas = $.parseJSON(dt.d);
            //$('#FileGridView').html(datas.res);
        },
        error: function (xhr, status, error) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}
function ajaxStudentFileUploadAzure() {
    if (ValidateImageDetails2()) {
        LoadingMessage('Uploading', '<b>Please Wait</b>');
        $("#loading").ajaxStart(function () {
            $(this).show();
        }).ajaxComplete(function () {
            $(this).hide();
        });
        var ScreenTypeId = 3;
        var UserSourceTypeId = $('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_UserSourceTypeHiddenField').val();
        var UserSourceId = $('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_UserSourceIdHiddenField').val();
        var DocumentId = $('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_DocumentIdHiddenField').val();
        var DocumentName = filename;
        var GUID = 0;
        if ($('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_GUIDHiddenField').val() != '')
            GUID = $('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_GUIDHiddenField').val();
        $.ajaxFileUpload({
            url: '/UserControls/MultiFileUpload/DocumentUpload.ashx?ScreenTypeId=' + ScreenTypeId + '&UserSourceTypeId=' + UserSourceTypeId + '&UserSourceId=' + UserSourceId + '&DocumentId=' + DocumentId + '&DocumentName=' + DocumentName + '&GUID=' + GUID,
            secureuri: false,
            fileElementId: 'flUpload2',
            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 ($('#ctl00_CP_StudentViewTabContainer_SearchTabPanel_UploadConfigurationHiddenField').val() == "Azure") {
                    //    AddtoDataSet();
                    //}
                    $("#ctl00_CP_StudentViewTabContainer_SearchTabPanel_UploadStatusLabel").text("Uploaded Successfully");
                }, 100);
            },
            error: function (response, status, e) {
                window.setTimeout(function () {
                    CloseLoadingpopup();
                }, 100);
            }
        })
        return false;
    }
}
function ajaxFileUploadNew() {
    if (ValidateResourceDetails()) {
        if (ValidateResourceSize()) {
            LoadingMessage('Uploading', '<b>Please Wait</b>');
            $("#loading").ajaxStart(function () {
                $(this).show();
            }).ajaxComplete(function () {
                $(this).hide();
            });
            $.ajaxFileUpload({
                url: '/UserControls/MultiFileUpload/ClassWise_file_upload.ashx',
                secureuri: false,
                fileElementId: 'FileUpload',
                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_LearningTabContainer_LearningDetails_Label7").text("Uploaded Successfully");
                    }, 100);
                },
                error: function (response, status, e) {
                    window.setTimeout(function () {
                        CloseLoadingpopup();
                    }, 100);
                }
            })
            return false;
        }
    }
}
function StudentUpload() {
    var form = document.createElement("form");
    form.setAttribute('method', "post");
    //window.document.forms[0].target = '_blank';
    form.submit();
}
function ajaxFileUpload2() {
    if (ValidateImageDetails2()) {
        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: 'flUpload2',
            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_StudentViewTabContainer_SearchTabPanel_UploadStatusLabel").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 jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var txt = /\.(.txt|)$/i;
    var doc = /\.(.doc|)$/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() == "csv" || t.toLowerCase() == "xls" || t.toLowerCase() == "txt" || t.toLowerCase() == "doc" || t.toLowerCase() == "docx" || t.toLowerCase() == "pdf" || t.toLowerCase() == "mp4") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }

    //if ((/\.(jpg|jpeg|png|csv|xls|txt|doc|docx|pdf|)$/i).test(file))
    //    return true;
    //else
    //    return false;
}
function ValidateImageDetails() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload').value;
    var iSize = ($("#flUpload")[0].files[0].size / 1024);
    iSize = (Math.round((iSize / 1024) * 100) / 100);

    //if (isFile(document.getElementById('flUpload').value) == false || document.getElementById('flUpload').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    //else if (iSize > 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 ValidateImageDetails2() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload2').value;
    var iSize = ($("#flUpload2")[0].files[0].size / 1024);
    iSize = (Math.round((iSize / 1024) * 100) / 100);

    //if (isFile2(document.getElementById('flUpload2').value) == false || document.getElementById('flUpload2').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    //else if (iSize > 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 isFile2(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    var jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var txt = /\.(.txt|)$/i;
    var doc = /\.(.doc|)$/i;
    var pdf = /\.(.pdf|)$/i;
    var count = document.getElementById('flUpload2').files;
    var fileValu = document.getElementById('flUpload2');
    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() == "csv" || t.toLowerCase() == "xls" || t.toLowerCase() == "txt" || t.toLowerCase() == "doc" || t.toLowerCase() == "docx" || t.toLowerCase() == "pdf") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }

    //if ((/\.(jpg|jpeg|png|csv|xls|txt|doc|docx|pdf|)$/i).test(file))
    //    return true;
    //else
    //    return false;
}
function ValidateResourceDetails() {
    var fields;
    fields = "";
    var file = document.getElementById('FileUpload').value;
    var iSize = ($("#FileUpload")[0].files[0].size / 1024);
    iSize = (Math.round((iSize / 1024) * 100) / 100);

    //if (isResourceFile(document.getElementById('FileUpload').value) == false || document.getElementById('FileUpload').value == null) {
    //    fields = fields + "\n Invalid file ";
    //}
    //else if (iSize > 5) {
    //    alert('File should be less than 5 MB');
    //    return false;
    //}
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields + filename;
        alert(fields);
        return false;
    }
    else {
        return true;
    }
}
function isResourceFile(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    var jpg = /\.(jpg|)$/i;
    var png = /\.(png|)$/i;
    var jpeg = /\.(jpeg|)$/i;
    var gif = /\.(gif|)$/i;
    var txt = /\.(.txt|)$/i;
    var doc = /\.(.doc|)$/i;
    var pdf = /\.(.pdf|)$/i;
    var count = document.getElementById('FileUpload').files;
    var fileValu = document.getElementById('FileUpload');
    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() == "csv" || t.toLowerCase() == "xls" || t.toLowerCase() == "txt" || t.toLowerCase() == "doc" || t.toLowerCase() == "docx" || t.toLowerCase() == "pdf" || t.toLowerCase() == "mp4" || t.toLowerCase() == "ppt") {
            count_file = count_file + 1;
        }
        else {
            filename = fileValu.files[i].name;
            return false;
        }
    }

    //if ((/\.(jpg|jpeg|png|csv|xls|txt|doc|docx|pdf|)$/i).test(file))
    //    return true;
    //else
    //    return false;
}

function MeetingAccountajaxFileUpload() {
    if (ValidateMeetingAccountImageDetails()) {
        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: 'MeetingAccountflUpload',
            dataType: 'text',
            contentType: "application/json; charset=utf-8",
            data: { name: 'logan', id: 'id', hdn: '1' },
            success: function (response, status) {
                /*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_MeetingAccountTabContainer_ImportAccount_Label2").text("Uploaded Successfully");
                }, 100);
            },
            error: function (response, status, e) {
                window.setTimeout(function () {
                    CloseLoadingpopup();
                }, 100);
            }
        })
        return false;
    }
}
function isMeetingAccountFile(file) {
    var video = /\.(xls|)$/i;
    var CSV = /\.(csv|)$/i;
    var xlsx = /\.(xlsx|)$/i;
    if (video.test(file.toLowerCase()))
        return true;
    else
        return false;
}
function ValidateMeetingAccountImageDetails() {
    var fields;
    fields = "";
    var file = document.getElementById('MeetingAccountflUpload').value;
    if (isMeetingAccountFile(document.getElementById('MeetingAccountflUpload').value) == false || document.getElementById('MeetingAccountflUpload').value == null) {
        fields = fields + "\n-- Invalid file --";
    }
    if (fields != "") {
        fields = "Please fill in the following details:\n------------------------------------" + fields;
        alert(fields);
        return false;
    }
    else {
        return true;
    }
}
function ValidateImageSize() {
    var fields;
    fields = "";
    var file = document.getElementById('flUpload').value;
    var iSize = ($("#flUpload")[0].files[0].size / 1024);
    //iSize = (Math.round((iSize / 1024) * 100) / 100);

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

        else {
            return true;
        }
    }
    else
    {
        return true;
    }
}
function ValidateResourceSize() {
    var fields;
    fields = "";
    var file = document.getElementById('FileUpload').value;
    var iSize = ($("#FileUpload")[0].files[0].size / 1024);
    //iSize = (Math.round((iSize / 1024) * 100) / 100);

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

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