//----------------------------------
// By default, the widgets are in 
// the "closed" position 

	document.widgetOpened = new Array();

//----------------------------------
// Function to open/close a widget

	function switchWidgetState (widgetId, widgetElement) {

		//----------------------------------
		// Fail if the browser is incapable
		// of doing getElementById

			if (!document.getElementById) {
				return false;
			}

		//----------------------------------
		// If a widget is already open...

			if (document.widgetOpened[widgetId] != null) {
	
				//----------------------------------
				// Close the widget which is
				// currently open

					var closingWidget = document.getElementById(document.widgetOpened[widgetId]);
					closingWidget.className = closingWidget.className.replace(widgetId + 'Show', widgetId + 'Hidden');
					
				//----------------------------------
				// If the user clicked on the widget
				// which is already open, then there
				// intention would be to close it,
				// so stop execution here
					
					if (document.widgetOpened[widgetId] == widgetElement) {
						document.widgetOpened[widgetId] = null;
						return false;
					}
	
			}
				
		//----------------------------------
		// Change the class on the widget,
		// so that it can be visible.
		
			var openingWidget = document.getElementById(widgetElement);
			openingWidget.className = openingWidget.className.replace(widgetId + 'Hidden', widgetId + 'Show');

		//----------------------------------
		// Remember which widget is currently
		// open
	
			document.widgetOpened[widgetId] = widgetElement;

	}
