
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
// Prompt functions
// Examples:
//          Are you sure
//          You are about to delete...
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//

var DialogResultAbort = "Abort";            // The dialog box return value is Abort(usually sent from a button labeled Abort).
var DialogResultCancel = "Cancel";          // The dialog box return value is Cancel(usually sent from a button labeled Cancel).
var DialogResultContinue = "Continue";      // The dialog box return value is Continue(usually sent from a button labeled Continue).
var DialogResultIgnore = "Ignore";          // The dialog box return value is Ignore(usually sent from a button labeled Ignore).
var DialogResultNo = "No";                  // The dialog box return value is No(usually sent from a button labeled No).
var DialogResultNone = "None";              // Nothing is returned from the dialog box.This means that the modal dialog continues running.
var DialogResultOK = "OK";                  // The dialog box return value is OK(usually sent from a button labeled OK).
var DialogResultRetry = "Retry";            // The dialog box return value is Retry(usually sent from a button labeled Retry).
var DialogResultTryAgain = "TryAgain";      // The dialog box return value is Try Again(usually sent from a button labeled Try Again).
var DialogResultYes = "Yes";	            // The dialog box return value is Yes(usually sent from a button labeled Yes).

var bMessageBoxDialogIsOpen = false;
var bPromptForValueDialogIsOpen = false;
var bWarnDeleteDialogIsOpen = false;
var bHasSpecialPromptControls = false;

// Prompt for OK, Yes/No, or a value
function Prompt(prompt, proceedcallback, proceedobject) {

    if (!prompt)
        return;

    // Type of prompt
    if (prompt.bCollectValue)
        OpenPromptForValueDialog(prompt, proceedcallback, proceedobject);
    else
        OpenMessageBox(prompt, proceedcallback, proceedobject);
    return;
}


/**
 * Open a Windows-Style MessageBox with OK, Cancel, Yes, No
 * @param {any} prompt
 */
function OpenMessageBox(prompt, proceedcallback, proceedobject, isresizable) {

    // Open the message box dialog for OK, Yes/No
    // See: MessageBoxDialogView.cshtml

    if (!prompt)
        return;
    if (!prompt.sPrompt)
        return;

    if (!isresizable)
        isresizable = false;

    // Message text
    $("#igDialogMessageBoxPromptLabel").html(prompt.sPrompt);


    var nDlgWidth = 500;
    var nDlgHeight = 350;
    var nWindowWidth = $(window).width();
    var nWindowHeight = $(window).height();
    if (nWindowWidth < nDlgWidth)
        nDlgWidth = nWindowWidth * 0.95;
    if (nWindowHeight < nDlgHeight)
        nDlgHeight = nWindowHeight * 0.95;

    // Open the dialog
    // igniteui.com/help/igdialog-property-reference
    $("#igDialogMessageBox").igDialog({ modal: true, headerText: prompt.sTitle, width: nDlgWidth, height: nDlgHeight, resizable: isresizable, closeOnEscape: true, openAnimation: "", /*closeAnimation: "fade", openAnimation: "fade"*/ });
    $("#igDialogMessageBox").igDialog("open");

    // Two message boxes in rapid sequence
    // The first dialog is not full closed when the second one is shown
    // The first dialog is still setting "display: none" when the second is opened by JS
    // Therefore, the second dialog gets the "display: none" style, and is not displayed
    // All you see is the dark gray overlay, and no dialog
    // This hack shows the second dialog
    // It was learned that the closeAnimation "fade" was the cause of the first slow-closing dialog
    // This hack may not be necessary

    // RW 6/17/2025
    // Commentted out because this is suspected as reason for multiple dialogs appearing
    // Perhaps that are multiple divs with this id, and this line redisplays them
    //setTimeout(function () { $("#igDialogMessageBox").css("display", "block"); }, 500);

    // Make the dialog as big as the content
    // Works, but needs more testing before going into production
    setTimeout(function () { $("#igDialogMessageBox").css("width", "max-content").css("max-width", ($(window).width() * 0.60) + "px"); CenterDialog("igDialogMessageBox"); }, 200);


    // Hack to resize Infragistics dialog box based on content
    //ResizeDialogToWindowSize("igDialogMessageBox");
    CenterDialog("igDialogMessageBox");
    setTimeout(function () { ResizeDialogBasedOnContent("igDialogMessageBox"); }, 100);

    // Need more work
    //setTimeout(function () { ResizeDialogHeightToContents("igDialogMessageBox"); }, 1000);

    // Set up controls
    var sIcon = "stdata.images.enabled.warning@16px.png";
    if (prompt.MbIcon == 48/*StMessageBoxIcon.IconExclamation*/)
        sIcon = "stdata.images.enabled.stop@16px.png";
    else if (prompt.MbIcon == 64/*StMessageBoxIcon.Information*/)
        sIcon = "stdata.images.enabled.success@16px.png";

    AjaxFillImage($("#igDialogMessageBoxImage"), sIcon, 256);
    bMessageBoxDialogIsOpen = true;

    // stdata.StMessageBoxButtons MbButtons
    $("#igDialogMessageBoxOKButton").show();
    $("#igDialogMessageBoxCancelButton").show();
    if (prompt.MbButtons === 0/*StMessageBoxButtons.OK*/) {
        $("#igDialogMessageBoxOKButton").val("OK");
        $("#igDialogMessageBoxCancelButton").hide();
    }
    else if (prompt.MbButtons === 4/*StMessageBoxButtons.YesNo*/) {
        $("#igDialogMessageBoxOKButton").val("Yes");
        $("#igDialogMessageBoxCancelButton").val("No");
    }
    else {
        $("#igDialogMessageBoxOKButton").val("OK");
        $("#igDialogMessageBoxCancelButton").val("Cancel");
    }

    // OK button click
    $("#igDialogMessageBoxOKButton").unbind().click(function () {

        CloseMessageBoxDialog();

        // Check for special case that warns user and asks for special input to proceed
        // Double verification, requiring an answer to proceed
        // This verifies the user's intention
        // Example: "Enter YES to proceed"
        if (prompt.bDoubleVerifyWithAnswer && prompt.sDoubleVerifyAnswer) {
            // Stop! You are about to delete some potentially valuable data. Are you sure?
            OpenWarnDeleteDialogBox(prompt, proceedcallback, proceedobject);
            return;
        }
        else {
            // Normal case, not special warnings, just proceed
            if (proceedcallback)
                proceedcallback(prompt, proceedobject);
        }

    });

    // Cancel button click
    $("#igDialogMessageBoxCancelButton").unbind().click(function () { CloseMessageBoxDialog(); });
}




function Prompts(PromptArray, proceedcallback, proceedobject) {

    if (!PromptArray) {
        if (proceedcallback)
            proceedcallback(prompt, proceedobject);
        return;
    }

    var NextPromptVars = {};
    NextPromptVars.PromptArray = PromptArray;
    NextPromptVars.nextpromptidx = 0;
    NextPromptVars.finalproceedcallback = proceedcallback;
    NextPromptVars.finalproceedobject = proceedobject;
    NextPrompt(null/*previouspromptresults*/, NextPromptVars);
}

function NextPrompt(previouspromptresults, NextPromptVars) {

    if (NextPromptVars.nextpromptidx >= NextPromptVars.PromptArray.length) {
        if (NextPromptVars.finalproceedcallback)
            NextPromptVars.finalproceedcallback(null/*previouspromptresults*/, NextPromptVars.finalproceedobject);
        return;
    }

    // Prepare for the next prompt
    var thispromptidx = NextPromptVars.nextpromptidx;
    NextPromptVars.nextpromptidx++;

    // Prompt next
    setTimeout(function () { Prompt(NextPromptVars.PromptArray[thispromptidx], NextPrompt, NextPromptVars); }, 500);
}


/**
 * Hack to resize Infragistics dialog box based on content
 * @param {any} dialogsDivId
 */
function ResizeDialogHeightToContents(dialogsDivId) {

    var modal = $("#" + dialogsDivId);

    var nOldWidth = $("#" + dialogsDivId).igDialog("option", "width");
    var nOldHeight = $("#" + dialogsDivId).igDialog("option", "height");

    var sHiddenDialogSizer = '<div id="hiddenDialogSizer" '
        + 'style="display:none; width: ' + nOldWidth + 'px;' + ' height:max-content;" >'
        + $("#" + dialogsDivId).html()
        + '</div>';
    $('body').append(sHiddenDialogSizer);

    var nNewHeight = $("#hiddenDialogSizer").height() + 50;

    //$("#" + dialogsDivId).igDialog("option", "minHeight", nNewHeight);

    modal.css({ "height": nNewHeight + "px", });

    $("#hiddenDialogSizer").remove();
}


function CenterDialog(dialogsDivId) {

    var modal = $("#" + dialogsDivId);
    var body = $(window);

    // Get modal size
    var w = modal.width();
    var h = modal.height();

    // Get window size
    var bw = body.width();
    var bh = body.height();

    // Update the css and center the modal on screen
    modal.css({
        "position": "absolute",
        "top": ((bh - h) / 2) + "px",
        "left": ((bw - w) / 2) + "px"
    });

    // Didn't work
    //$("#" + dialogsDivId).addClass("centeronscreen");
    //$("#" + dialogsDivId).removeClass("centeronscreen");
}


function PostionDialogLowerRight(dialogsDivId, margin) {

    var modal = $("#" + dialogsDivId);
    var body = $(window);

    // Get modal size
    var w = modal.width();
    var h = modal.height();

    // Get window size
    var bw = body.width();
    var bh = body.height();

    // Lower-right
    var newtop = bh - h - margin;
    var newleft = bw - w - margin;

    // Update the css and center the modal on screen
    modal.css({
        "position": "absolute",
        "top": newtop + "px",
        "left": newleft + "px"
    });

    // Didn't work
    //$("#" + dialogsDivId).addClass("centeronscreen");
    //$("#" + dialogsDivId).removeClass("centeronscreen");
}


function ResizeDialogBasedOnContent(DialogDivId) {

    var modal = $("#" + DialogDivId);
    var body = $(window);

    // Get modal size
    var w = modal.width();
    var h = modal.height();

    // Get window size
    var bw = body.width();
    var bh = body.height();

    // Find the element at the bottom of the dialog
    var MaxBottom = 0;
    var AllElements = $(modal).find("*");
    AllElements.each(function () {
        var ChildElement = $(this);
        var ChildElementType = this.nodeName;
        if (ChildElementType.toLowerCase() == "div")
            return true;

        var ElementBottom = ChildElement.position().top + ChildElement.outerHeight(true);
        if (ElementBottom > MaxBottom)
            MaxBottom = ElementBottom;
    });

    // 11/29/2022 Changed from 100 to 50 because of extra space at bottom of dialog
    var NewBottom = MaxBottom + 50;
    var ExtraSpaceAtBottom = h - NewBottom;
    var bChanged = false;

    if (NewBottom >= bh)
        NewBottom = bh - 20;

    // Dialog content is cut off (probably too much text)
    if (NewBottom > h && NewBottom < bh) {
        bChanged = true;
        modal.igDialog("option", "height", NewBottom);
    }

    // Dialog is too long (too little text)
    if (ExtraSpaceAtBottom > 75 && NewBottom < bh) {
        bChanged = true;
        modal.igDialog("option", "height", NewBottom);
    }

    // Changed? Recenter dialog
    if (bChanged)
        CenterDialog(DialogDivId);
}


function PositionDialogLowerRight(dialogsDivId) {

    var modal = $("#" + dialogsDivId);
    var body = $(window);

    // Get modal size
    var w = modal.width();
    var h = modal.height();

    // Get window size
    var bw = body.width();
    var bh = body.height();

    var NewTop = bh - h - 100;
    var NewLeft = bw - w - 100;

    // Update the css and center the modal on screen
    modal.css({
        "position": "absolute",
        "top": NewTop + "px",
        "left": NewLeft + "px"
    });
}

function PositionDialogOffsetFromMouse(dialogsDivId, offsetX, offsetY) {

    var modal = $("#" + dialogsDivId);

    if (!currentMousePos)
        return;

    var NewTop = currentMousePos.y + offsetY;
    var NewLeft = currentMousePos.x + offsetX;

    // Update the css and center the modal on screen
    modal.css({
        "position": "absolute",
        "top": NewTop + "px",
        "left": NewLeft + "px"
    });
}



// Sort-of worked
//function ResizeDialogToWindowSize(dialogsDivId) {

//    var modal = $("#" + dialogsDivId);
//    var body = $(window);

//    // Get modal size
//    var w = modal.width();
//    var h = modal.height();

//    // Get window size
//    var bw = body.width();
//    var bh = body.height();

//    // Make the dialog smaller
//    if (w >= (bw-50))
//        modal.css({ "width": (bw - 50) + "px", });
//    if (h >= (bh-50))
//        modal.css({ "height": (bh - 50) + "px", });
//}



/**
 * Open a dialog box to prompt for a user value
 * Example: Enter a new name for the project
 * @param {any} prompt
 */
function OpenPromptForValueDialog(prompt, proceedcallback, proceedobject) {

    // Open a dialog to accept user input
    // See: PromptForValueView.cshtml

    if (!prompt)
        return;
    if (!prompt.sPrompt)
        return;
    if (bPromptForValueDialogIsOpen)
        return;

    // Set the current values
    var nPromptLines = prompt.sPrompt.split(/\r\n|\r|\n/).length;
    if (!nPromptLines)
        nPromptLines = 1;
    nPromptLines = nPromptLines * 1.5;
    $("#igDialogPromptForValuePromptLabel").attr("rows", nPromptLines);
    $("#igDialogPromptForValuePromptLabel").val(prompt.sPrompt);
    $("#igDialogPromptForValueTextBox").val(prompt.sValue);
    if (prompt.sInitialValue)
        $("#igDialogPromptForValueTextBox").val(prompt.sInitialValue);
    if (prompt.bMultiline)
        $("#igDialogPromptForValueTextBox").attr("rows", 4);

    if (bHasSpecialPromptControls)
        $("#igDialogPromptForValueSpecialControls").show();
    else {
        $("#igDialogPromptForValueSpecialControls").hide();
        $("#igDialogPromptForValueSpecialControls").html("");
    }
    bHasSpecialPromptControls = false;

    var nDlgWidth = 600;
    var nDlgHeight = 250;
    var nWindowWidth = $(window).width();
    var nWindowHeight = $(window).height();
    if (nWindowWidth < nDlgWidth)
        nDlgWidth = nWindowWidth * 0.95;
    if (nWindowHeight < nDlgHeight)
        nDlgHeight = nWindowHeight * 0.95;

    // Open the dialog
    // igniteui.com/help/igdialog-property-reference
    $("#igDialogPromptForValue").igDialog({ modal: true, headerText: prompt.sTitle, width: nDlgWidth, height: nDlgHeight, resizable: false, closeOnEscape: true, openAnimation: "", closeAnimation: "fade", stateChanged: function (event, ui) { OnPromptForValueStateChanged(event, ui); }/*, openAnimation: "fade"*/ });
    $("#igDialogPromptForValue").igDialog("open");

    //ResizeDialogToWindowSize("igDialogPromptForValue");
    CenterDialog("igDialogPromptForValue");
    setTimeout(function () { ResizeDialogBasedOnContent("igDialogPromptForValue"); }, 100);

    // Set up controls
    AjaxFillImage($("#igDialogPromptForValueImage"), "stdata.images.enabled.warning@16px.png", 256);
    setTimeout(function () { $("#igDialogPromptForValueTextBox").focus(); $("#igDialogPromptForValueTextBox").select(); }, 250);
    bPromptForValueDialogIsOpen = true;

    // stdata.StMessageBoxButtons MbButtons
    if (prompt.MbButtons === 4/*StMessageBoxButtons.YesNo*/) {
        $("#igDialogPromptForValueOKButton").val("Yes");
        $("#igDialogPromptForValueCancelButton").val("No");
    }
    else {
        $("#igDialogPromptForValueOKButton").val("OK");
        $("#igDialogPromptForValueCancelButton").val("Cancel");
    }

    // OK button click
    $("#igDialogPromptForValueOKButton").unbind().click(function () {

        // User entered this value
        // Example: Project name: WO3823
        var EnteredValue = $("#igDialogPromptForValueTextBox").val();

        ClosePromptForValueDialog();

        // MUST answer this question before proceeding?
        // Often used to verify intent to delete important information
        // User must enter exact value to delete valuable data
        // Example: YES
        if (prompt.sDoubleVerifyAnswer) {

            // Must be EXACT value
            if (EnteredValue.trim() !== prompt.sDoubleVerifyAnswer) {
                alert("Value incorrect\r\n\r\n'" + EnteredValue + "' is not equal to '" + prompt.sDoubleVerifyAnswer + "'\r\n\r\nOperation canceled!");
                return;
            }
        }

        // Trim CRLF from end, which can cause problems with JS values and params
        if (EnteredValue && EnteredValue != null)
            EnteredValue = EnteredValue.trim();

        // Save the value and close
        // Then proceed to the callback
        prompt.sValue = EnteredValue
        prompt.bValueEntered = true;

        if (proceedcallback)
            proceedcallback(prompt, proceedobject);
    });

    // Cancel button click
    $("#igDialogPromptForValueCancelButton").unbind().click(function () {
        ClosePromptForValueDialog();
    });
}




function OnPromptForValueStateChanged(event, ui) {

    if (!ui)
        return;
    if (!ui.action)
        return;

    // Close event
    if (ui.action == 'close') {

        // Closed dialog
        bPromptForValueDialogIsOpen = false;
    }
}



function OnPromptMessageBoxKeyUp(event) {

    if (!event)
        return;

    // Enter key
    if (event.key === "Enter") {
        // "Click" the OK button to close the prompt dialog
        $("#igDialogMessageBoxOKButton").click();
        return;
    }
}


function OnPromptWarnDeleteKeyUp(event) {

    if (!event)
        return;

    // Enter key
    if (event.key === "Enter") {
        // "Click" the OK button to close the prompt dialog
        $("#igDialogWarnDeleteOKButton").click();
        return;
    }
}

/**
 * Key entered into prompt value textarea
 * @param {any} event
 */
function OnPromptValueKeyUp(event) {

    if (!event)
        return;

    // Enter key
    if (event.key === "Enter") {
        // "Click" the OK button to close the prompt dialog
        $("#igDialogPromptForValueOKButton").click();
        return;
    }

    if (!event.currentTarget)
        return;

    var element = event.currentTarget;
    var PromptValueTextAreaElement = $(element);
    if (!PromptValueTextAreaElement)
        return;

    var PromptValueText = PromptValueTextAreaElement.val();
    if (!PromptValueText)
        return;
}



/**
 * Open a Windows-Style MessageBox with OK, Cancel, Yes, No
 * @param {any} prompt
 */
function OpenWarnDeleteDialogBox(prompt, proceedcallback, proceedobject) {

    // Open the message box dialog for OK, Yes/No
    // See: MessageBoxDialogView.cshtml

    // Set the current values
    $("#igDialogWarnDeletePromptLabel").val("You're about to delete some potentially valuable information! Are you sure?");

    var nDlgWidth = 500;
    var nDlgHeight = 350;
    var nWindowWidth = $(window).width();
    var nWindowHeight = $(window).height();
    if (nWindowWidth < nDlgWidth)
        nDlgWidth = nWindowWidth * 0.95;
    if (nWindowHeight < nDlgHeight)
        nDlgHeight = nWindowHeight * 0.95;

    // Open the dialog
    // igniteui.com/help/igdialog-property-reference
    $("#igDialogWarnDelete").igDialog({ modal: true, headerText: prompt.sTitle, width: nDlgWidth, height: nDlgHeight, resizable: false, closeOnEscape: true, openAnimation: "", closeAnimation: "fade"/*, openAnimation: "fade"*/ });
    $("#igDialogWarnDelete").igDialog("open");

    // Set up controls
    AjaxFillImage($("#igDialogWarnDeleteImage"), "stdata.images.enabled.stop@16px.png", 256);
    bWarnDeleteDialogIsOpen = true;

    //ResizeDialogToWindowSize("igDialogWarnDelete");
    CenterDialog("igDialogWarnDelete");
    setTimeout(function () { ResizeDialogBasedOnContent("igDialogMessageBox"); }, 100);

    // OK button click
    $("#igDialogWarnDeleteOKButton").unbind().click(function () {

        CloseWarnDeleteDialog();

        if (prompt.bDoubleVerifyWithAnswer && prompt.sDoubleVerifyAnswer) {
            // Stop! You are about to delete some potentially valuable data. Are you sure?
            var AnswerYesPrompt = { sTitle: prompt.sTitle, sPrompt: "Enter YES to proceed", sDoubleVerifyAnswer: prompt.sDoubleVerifyAnswer };
            OpenPromptForValueDialog(AnswerYesPrompt, proceedcallback, proceedobject);
            return;
        }
        else {
            // Normal case, not special warnings, just proceed
            if (proceedcallback)
                proceedcallback(prompt, proceedobject);
        }

    });

    // Cancel button click
    $("#igDialogWarnDeleteCancelButton").unbind().click(function () {
        CloseWarnDeleteDialog();
    });
}



function OpenMessageBoxAlerts(MessageBoxAlerts) {

    // See stdata.MessageAlert
    // See BcData.MessageBoxAlerts
    if (!MessageBoxAlerts)
        return;
    if (!Array.isArray(MessageBoxAlerts))
        return;
    if (MessageBoxAlerts.length == 0)
        return;

    // Only display one messagebox for now
    // Improve this later to send all messages in the list
    var MessageAlert1 = MessageBoxAlerts[0];
    if (!MessageAlert1)
        return;
    if (!MessageAlert1.sTitle)
        return;
    if (!MessageAlert1.sMessage)
        return;

    PopupMessageBox(MessageAlert1.sTitle, MessageAlert1.sMessage);
}


//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//


function PopupMessageBox(title, msg) {

    var prompt = { sTitle: title, sPrompt: msg, MbButtons: 0 };
    OpenMessageBox(prompt, null/*proceedcallback*/, null/*proceedobject*/);
}

function PopupResizableMessageBox(title, msg) {

    var prompt = { sTitle: title, sPrompt: msg, MbButtons: 0 };
    OpenMessageBox(prompt, null/*proceedcallback*/, null/*proceedobject*/, true/*isresizable*/);
}

function PopupErrorMessage(title, msg) {

    var prompt = { sTitle: title, sPrompt: msg, MbButtons: 0, MbIcon: 48/*StMessageBoxIcon.IconExclamation*/, };
    OpenMessageBox(prompt, null/*proceedcallback*/, null/*proceedobject*/);
}

function PopupInfoMessage(title, msg) {

    var prompt = { sTitle: title, sPrompt: msg, MbButtons: 0, MbIcon: 64/*StMessageBoxIcon.Information*/, };
    OpenMessageBox(prompt, null/*proceedcallback*/, null/*proceedobject*/);
}

function PopupYesNoWithCallback(title, msg, proceedcallback, proceedobject) {

    var prompt = { sTitle: title, sPrompt: msg, MbButtons: 4/*StMessageBoxButtons.YesNo*/, MbIcon: 32/*StMessageBoxIcon.Question*/, };
    OpenMessageBox(prompt, proceedcallback, proceedobject);
}

function PopupYesNoWithDoubleVerification(title, msg, proceedcallback, proceedobject) {

    var prompt = { sTitle: title, sPrompt: msg, bDoubleVerifyWithAnswer: true, sDoubleVerifyAnswer: "YES", MbButtons: 4/*StMessageBoxButtons.YesNo*/, MbIcon: 32/*StMessageBoxIcon.Question*/, };
    OpenMessageBox(prompt, proceedcallback, proceedobject);
}

function PopupPromptForValueBox(title, msg, value, proceedcallback, proceedobject) {

    var prompt = { sTitle: title, sPrompt: msg, sValue: value, MbButtons: 1, MbIcon: 32/*StMessageBoxIcon.Question*/, bCollectValue: true, };
    OpenPromptForValueDialog(prompt, proceedcallback, proceedobject);
}








//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
// Close the messagebox dialog
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
function CloseMessageBoxDialog() {
    $("#igDialogMessageBox").igDialog("close");
    bMessageBoxDialogIsOpen = false;
}

function IsMessageBoxDialogOpen() {
    return bMessageBoxDialogIsOpen;
}


//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
// Close the prompt for value dialog
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
function ClosePromptForValueDialog() {
    $("#igDialogPromptForValue").igDialog("close");
    bPromptForValueDialogIsOpen = false;
}

function IsPromptForValueDialogOpen() {
    return bPromptForValueDialogIsOpen;
}

//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
// Close the warning dialog
//\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\////\\//
function CloseWarnDeleteDialog() {
    $("#igDialogWarnDelete").igDialog("close");
    bWarnDeleteDialogIsOpen = false;
}

function IsWarnDeleteDialogOpen() {
    return bWarnDeleteDialogIsOpen;
}


function IsAnyModalDialogOpen() {

    // Is there a generic way to find out if any modal dialog is open?
    try {
        if (bEditRecordDialogIsOpen)
            return true;
        if (bMessageBoxDialogIsOpen)
            return true;
        if (bPromptForValueDialogIsOpen)
            return true;
        if (bWarnDeleteDialogIsOpen)
            return true;
        if (bHasSpecialPromptControls)
            return true;
        if (bSpeechRecognitionDialogIsOpen)
            return true;
        if (bTaskLinkDetailsDialogIsOpen)
            return true;
        if (bTaskLinkTypeDialogIsOpen)
            return true;
        if (bDateRangePickerDialogIsOpen)
            return true;
        if (bGridEditPopupDialogIsOpen)
            return true;
        if (bFilterFavoritesDialogIsOpen)
            return true;
        if (bViewImageDialogIsOpen)
            return true;
        if (bChangePasswordDialogIsOpen)
            return true;
        if (bProjectAssistantDialogIsOpen)
            return true;
    }
    catch (e) {
    }

    // No modal dialog is open
    return false;
}




