﻿// Confirm action and redirect
function ConfirmAction(sText, sUrl) {
    if (confirm(sText)) {
        location.href = sUrl;
    }
}

// Popup
function PopUp(sURL, sName, iWidth, iHeight) {
    var sFeatures = "width=" + iWidth + ", height=" + iHeight + ", status=0, scrollbars=1";
    window.open(sURL, sName, sFeatures);
}

// Changes an object's source
function ChangeSource(sID, sNew) {
    var oItem = document.getElementById(sID);
    if (oItem) {
        if (oItem.src != sNew)
            oItem.src = sNew
    }
}

// Shows/Hides an object
function SwapDisplay(sItemID) {
    var iResult;
    var obj = document.getElementById(sItemID);

    if ((obj.style.display == "none") || (obj.style.display == "")) {
        obj.style.display = "inline";
        iResult = 1;
    }
    else {
        obj.style.display = "none";
        iResult = 0;
    }

    return iResult;
}

// Shows/Hides a html row
function SwapRowDisplay(sItemID) {
    var iResult;
    var obj = document.getElementById(sItemID);
    if ((obj.style.display == "none") || (obj.style.display == "")) {
        obj.style.display = "table-row";
        iResult = 1;
    }
    else {
        obj.style.display = "none";
        iResult = 0;
    }
    return iResult;
}
