/*
** These are our traditional hide/show tags used all over the place
*/
function showSpanTag(tag)
{
    document.getElementById(tag).style.display = "inline";
    document.getElementById(tag).style.visibility = "visible";
}


function hideSpanTag(tag)
{
    document.getElementById(tag).style.display = "none";
    document.getElementById(tag).style.visibility = "hidden";
}


function showDivTag(tag)
{
    document.getElementById(tag).style.display="block";
    document.getElementById(tag).style.visibility="visible";
}


function hideDivTag(tag)
{
    document.getElementById(tag).style.display="none";
    document.getElementById(tag).style.visibility="hidden";
}


function showHideDiv(showDiv, hideDiv)
{
    showDivTag(showDiv);
    hideDivTag(hideDiv);
}


function showHideSpan(showSpan, hideSpan)
{
    showSpanTag(showSpan);
    hideSpanTag(hideSpan);
}


function showHideAllSpan(showSpan)
{
    showSpanTag(showSpan);

    for ( i = 1; i < arguments.length; i++ )
    {
        hideSpanTag(arguments[i]);
    }
}


function hideShowAllSpan(hideSpan)
{
    hideSpanTag(hideSpan);

    for ( i = 1; i < arguments.length; i++ )
    {
        showSpanTag(arguments[i]);
    }
}


function showHideAllDiv(showDiv)
{
    showDivTag(showDiv);

    for ( i = 1; i < arguments.length; i++ )
    {
        hideDivTag(arguments[i]);
    }
}


function hideShowAllDiv(hideDiv)
{
    hideDivTag(hideDiv);

    for ( i = 1; i < arguments.length; i++ )
    {
        showDivTag(arguments[i]);
    }
}


/*******************************************************************************
*
* Name: showYearOptions
*
* Description: This subroutine calculates and returns year options for HTML
*              select menus.  The number of year options returned is based on
*              today's date and a requested number of years into the future.
*
* Parameters: menuID - ID of HTML select menu we wish to add year options to
*             numOfYears - number of years into the future to calculate year
*                          options (two years by default)
*             reset - flag to reset HTML select menu to the following:
*
*                     <select>
*                       <option>Year</option>
*                       <option>--------</option>
*                     </select>
*
********************************************************************************/
function showYearOptions(menuID, numOfYears, reset)
{
    // Check if number of years is not set
    if ( !numOfYears )
    {
        // Set to default of two years
        numOfYears = 2;
    }

    // Get today's full year
    var today = new Date;
    var year = today.getFullYear();

    // Get select menu to add year options to
    var select = document.getElementById(menuID);

    // Check if we need to reset select menu
    if ( reset )
    {
        // Process all options in menu
        for ( var i = (select.length - 1); i >= 0; i-- )
        {
            // Check if option text is not "Year" and separator label
            if ( (select.options[i].text != "Year") &&
                 (select.options[i].text != "--------") )
            {
                // Remove option from select menu
                select.remove(i);
            }
        }

        // Pre-select first option
        select.options[0].selected = true;
    }

    // Process number of years into future
    for ( var i = year; i <= (year + numOfYears); i++ )
    {
        // Create and set option object
        var option = document.createElement("option");
        option.text = i;
        option.value = i;

        try
        {
            // Add year option to select menu
            select.add(option, null);
        }

        catch(e)
        {
            // add() method is different for IE browsers
            select.add(option);
        }
    }
}

function jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function addMenuOption(menu, text, value)
{
    // Create and set option object
    var option = document.createElement("option");
    option.text = text;
    option.value = value;

    try
    {
        // Add option to select menu
        menu.add(option, null);
    }

    catch(e)
    {
        // add() method is different for IE browsers
        menu.add(option);
    }
}

