/*******************************************************************************
* Name         = general.js
*
* Description  = General purpose Javascript functions for Ryder.com Investor
*                 Portal.
*
* Revision History:
*
*  Date        Developer           Description
* ------------------------------------------------------------------------------
*  08/22/06    Maria Kaufmann      Initial implementation
********************************************************************************/

/*******************************************************************************
* Expands the left navigation bar's second-level menu items under the
* first-level menu identified by id.
*******************************************************************************/
function LeftNav_showMenu(id)
{
	var element = document.getElementById(id);
    var linkImgName = "img_" + id;
	
	// Toggle the state of the current division
	if ( element != null )
	{
		if ( element.style.display != "block" )
    	{
			element.style.display = "block";

            if ( document[linkImgName] != null )
				document[linkImgName].src = "images/nav_icon_down.gif";
    	}
    	else
    	{
			element.style.display = "none";
			
            if ( document[linkImgName] != null )
            	document[linkImgName].src = "images/nav_icon.gif";
    	}

		// Hide all other divisions
		if ( document.all )
		{
			// This is an IE browser.
			var divcount = document.all.tags("div").length;
			var divarray = document.all.tags("div");
			for ( var i=0; i < divcount; i++ )
			{
				if ( divarray[i].id )
				{
					if ( divarray[i].id.indexOf("sm_") != -1 &&
						 divarray[i].id != id )
					{
						document.getElementById(divarray[i].id).style.display = "none";
						
                        var linkImgName2 = "img_" + divarray[i].id;
                        if ( document[linkImgName2] != null )
                        	document[linkImgName2].src = "images/nav_icon.gif";
					}
				}
			} // end for
		} // end if ( document.all )
	} // end if ( element != null )
	
}

/*******************************************************************************
* Opens a scrollable, resizeable window with no menubar and tool bars.
*******************************************************************************/
function openWindow(url, urlDescription, height, width)
{
	if ( height == null ) height = 400;
	if ( width == null ) width = 600;

	var windowOptions = "width="  + width  + ",height=" + height + ",menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
  	window.open (url, urlDescription, windowOptions);
}

/*******************************************************************************
* Given a form.select object, with a pick list of URL value definitions, this
* function takes the user to the link selected from the pick list.
*******************************************************************************/
function goToSelectedLink(selectObj)
{
	if ( selectObj != undefined && selectObj != null )
	{
    	var selIndex = selectObj.options.selectedIndex;
		if ( selIndex != -1 && selectObj.options[selIndex].value != "#")
		{
			openWindow(selectObj.options[selIndex].value, "OnlineTool", 800, 600);
		}
	}
}
