﻿var returnValue = null;
var buttonClientID;

function customConfirm(_buttonClientID) {
    buttonClientID = _buttonClientID;
    if (returnValue == null) {
        var modal = document.getElementById("modalconfirmdiv");
        modal.style.display = "block";
    }
    else if (returnValue == "yes") {
        returnValue = null;
        return true;
    }

    returnValue = null;
    return false;
}

function process(result) {
    var modal = document.getElementById("modalconfirmdiv");
    modal.style.display = "none";
    
    if (result == "yes") {
        returnValue = "yes";

        var button = document.getElementById(buttonClientID)

        if (typeof (button.href) != "undefined") {
            returnValue = null;
            window.location.href = document.getElementById(buttonClientID).href;
        }
        else
            button.click();
    }
}

function customAlert(message) {
    var modal = document.getElementById("modalalertdiv");
    modal.style.display = "block";

    var messagediv = document.getElementById("messagediv");
    messagediv.innerHTML = message;
    return false;
}

function closeAlertDiv() {
    var modal = document.getElementById("modalalertdiv");
    modal.style.display = "none";
}
