// show the info popup
function showInfo(infoText)
{
    alert(infoText);
    return false;
}

// Sets the window status text that will appear in the browser's status bar.
function setStatus(statusText)
{
    window.status = statusText;
    return true;
}

// call the function param with the data param - load the
// url that is returned from the function
function urlFromFunction(aFunction, p1, p2, p3, p4, p5) 
{
    var href = aFunction(p1, p2, p3, p4, p5);
    if (href) 
    {
	g_pauseForRefresh = true;
        setWindowLocation(href);
    }
}

// Sets the href of the window
function setWindowLocation(location)
{
    window.location.href = location;
    return false;
}

// Displays the help in a separate window
function openHelp(helpUrl)
{
    var helpWindow = window.open(helpUrl, "RAHelpWindow", "width=850,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes", false);
    helpWindow.focus();
    return false;
}

// Enables or disables buttons
function enableButton(btn, enable)
{
    if (btn == null)
    {
        return;
    }
	
    if (enable)
    {
        btn.disabled  = false;
        btn.className = "";
    }
    else
    {
        btn.disabled  = true;
        btn.className = "disabledButton";
    }
}


function isUndefined(a) {
    return typeof a == 'undefined';
}

// Returns the ancestor of the current node with the given tag name, or null
// if it cannot be found.
function getAncestorWithTagName(startNode, tagName)
{
    tagName = tagName.toLowerCase();

    var checkNode  = startNode;
    var returnNode = null;

    while (checkNode != null)
    {
        if (checkNode.tagName.toLowerCase() == tagName)
        {
            returnNode = checkNode;
            checkNode  = null;
        }
        else
        {
            checkNode = checkNode.parentNode;
        }
    }

    return returnNode;
}

function deleteTableRow(rowId)
{
    // find the row where the old collection is stored
    var row = document.getElementById(rowId);

    // Get the table element where this node is found
    var table = getAncestorWithTagName(row, "table");

    row.parentNode.removeChild(row);

    // Redraw the table to get the rows alternating correctly
    setRowStyles(table);
}

