
function setFileName(selectedFile) {

    var file = selectedFile.files[0];
    var filename = file.name;
    document.getElementById(selectedFile.parentElement.children[1].id).value = filename;
    //$('ctl00_MainContent_txtBrowse').val(filename);
    //$("#ctl00_MainContent_txtBrowse").setAttribute('title', selectedFile.value);
    //document.getElementById('ctl00_MainContent_txtBrowse').setAttribute('title', selectedFile.value);
}

function openFileBrowser(selected) {

    var uploaderid = selected.parentElement.children[0].id
    document.getElementById(selected.parentElement.children[0].id).click();
    //$("#ctl00_MainContent_fileuploadExcel").click();
}

function ClosePopup() {
    try {
        if (window.parent.$('.ui-dialog-content:visible').length > 0) {
            window.parent.$('.ui-dialog-content:visible').dialog('close');
        }
        else if (window.parent.$('iframe').length > 0) {
            window.parent.$('iframe').closest('div').css('display', 'none');
            window.parent.$('iframe').remove();
        }
        else
            window.close();
    } catch (e) {
        throw (e);
    }
}
//Added on 6-Sep-2021 || MohiniM || MASCLI-1374 start || MASCLI-2114 || MohiniM || 18-Nov-2021 -start
function ShowDocument(DocumentSrc, height, width,sourcepath) {
    //window.open('F:\1FinIQ_Logs\UploadFiles\download.png');
    //height = Number(height) + Number("50");
    //width = Number(width) + Number("50");
    height = $('#ctl00_MainContent_hdndocheight').val()
    width = $('#ctl00_MainContent_hdndocwidth').val()
    virtualDirectoryAlias = $('#ctl00_MainContent_hdnVirtualDocAlias').val()

    //debugger;
    var top1 = (screen.height) / 4
    var left1 = (screen.width) / 3
    //var top1 = 200;
    //var left1 = 150;
    //window.open('../OrderEntry_DocumentUpload/ViewDoc.aspx?height=' + height + '&width=' + width + '&Master_Popup=POPUP', 'QuickOrderEntry', 'top=' + top1 + 'px,left=' + left1
    //    + 'px,status= no, resizable=yes, scrollbars=yes, toolbar=no,width='+ width + ',height=' +  height);

    var ViewDocumentpopup = window.open(window.top.location.origin + '/' + virtualDirectoryAlias + '/' + DocumentSrc + '?height=' + height + '&width=' + width + '&Master_Popup=POPUP', 'QuickOrderEntry', 'top=' + top1 + 'px,left=' + left1
        + 'px,status= no, resizable=yes, scrollbars=yes, toolbar=no,width=' + width + ',height=' + height, "ViewDocumentpopup");
    ViewDocumentpopup.onload = function () {
        ViewDocumentpopup.onunload = function () {
            $('[id$="hdndeleteviewedDoc"]').click();      
        };
    }

}
//MASCLI - 2114 || MohiniM || 18 - Nov - 2021 -End

function ViewDoc(DocumentSrc, height, width) {
    iframe = $('<iframe id="#ModalDialog1"  src=' + DocumentSrc + '></iframe>');
    $("<div id='ModalBoxInside113'></div>").append(iframe).appendTo("body").dialog({
        height: height,
        width: width,
        modal: true,
        resizable: true,
        draggable: true,
        autoOpen: true,
        bgiframe: true,
        top: "100",
        left: "100",
        close: function () { $('html').find('#collDialog').html(); },
        open: function () { $('html').find('#collDialog').html(''); }
    });
}
//Added on 6-Sep-2021 || MohiniM || MASCLI-1374 End

//'MASCLI-2114 || MohiniM || 26-Nov-2021
function EnableDisableButton(id)
{   
    document.getElementById(id.id).disabled = true;
    $('[id$="hdnviewrowID"]').val(document.getElementById(id.id).parentNode.parentNode.rowIndex -1);
    $('[id$="hdnviewdocbtn"]').click();

}
