/****************************************************************************************
Function/Procedure  Name            :- fnmodalWink
functionality                       :- Function to open Search Window.
****************************************************************************************/

var childPopupArray = new Array(30)

function modalWin(strFullWindowName, strWindowTitle, dialogSize) {
    
    var targetWin = null;
    var CurrentPopUpIndex = 0;
    for (var PopUpCount = 0; PopUpCount < childPopupArray.length - 1; PopUpCount++) {
        if (childPopupArray[PopUpCount] != undefined)
            if (childPopupArray[PopUpCount][0] == strWindowTitle) {
            targetWin = childPopupArray[PopUpCount][1];
            if (targetWin.closed)
                childPopupArray[PopUpCount] = undefined;
            break;
        }
    }
    if (targetWin != null && targetWin.closed)
        targetWin = null;
    if (targetWin == null) {
        targetWin = window.open(strFullWindowName, '', 'height=1000,width=1200,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=yes');
        targetWin.moveTo(0, 0);
        targetWin.resizeTo(screen.availWidth , screen.availHeight );
    }

    else {
        targetWin.location = strFullWindowName;
        targetWin.focus();
        targetWin.moveTo(0, 0);
        targetWin.resizeTo(screen.availWidth, screen.availHeight);
    }
    for (var ExistingPopUpCount = 0; ExistingPopUpCount < childPopupArray.length - 1; ExistingPopUpCount++) {
        if (childPopupArray[ExistingPopUpCount] != undefined)
            if (childPopupArray[ExistingPopUpCount][0] == strWindowTitle) {
            childPopupArray[ExistingPopUpCount][1] = targetWin;
            CurrentPopUpIndex = ExistingPopUpCount;
            break;
        }
    }
    if (CurrentPopUpIndex == 0) {
        for (var EmptyPopUpCount = 0; EmptyPopUpCount < childPopupArray.length - 1; EmptyPopUpCount++) {
            if (childPopupArray[EmptyPopUpCount] == undefined) {
                childPopupArray[EmptyPopUpCount] = new Array(2);
                childPopupArray[EmptyPopUpCount][0] = strWindowTitle;
                childPopupArray[EmptyPopUpCount][1] = targetWin;
                break;
            }
        }
    }

}

/****************************************************************************************
Function/Procedure  Name            :- textboxMultilineMaxNumber
functionality                       :- Function to restrict max length of Multiline Textbox on key press
****************************************************************************************/
function textboxMultilineMaxNumber(txt, maxLen) {
    try {
        if (txt.value.length > (maxLen - 1)) return false;
    } catch (e) {
    }
}
/****************************************************************************************
Function/Procedure  Name            :- textboxMultilineTextChangeMaxNumber
functionality                       :- Function to restrict max length of Multiline Textbox on Copy/ Paste
****************************************************************************************/
function textboxMultilineTextChangeMaxNumber(txt, maxLen) {
    try {
        if (txt.value.length > (maxLen - 1)) {
            txt.value = txt.value.substring(0, maxLen);
            return false;
        }
    } catch (e) {
    }
}