﻿            
            function toggleOpenState( oNode )
			{
				with( oNode.parentNode )
					className = className.match( /open/ ) ? className.replace( /open/, 'closed' ) : className.replace( /closed/, 'open' );
				return false; // return false so it's safe to use on the onclick of an A element
			}

			function NavigationTabs( mContainer )
			{
				if ( typeof mContainer == "string" )
					mContainer = document.getElementById( mContainer );
				this.init( mContainer );
			};
			NavigationTabs.prototype.init = function( oContainer )
			{
				this._image = new Object();
				var aLI     = oContainer.getElementsByTagName( "li" );
				for ( var i = 0; i < aLI.length; ++i )
					this._createInteractiveTab( aLI[ i ], i );
			};
			NavigationTabs.prototype._createInteractiveTab = function( oLI, nIndex )
			{
				var aImage = oLI.getElementsByTagName( "img" );
				if ( aImage && aImage.length > 0 )
				{
					var oImage        = aImage[ 0 ]; // always use the first image
					var bHoverState   = oImage.src.match( /.+(hover).+/ );
					var sActiveSource = oImage.src.replace( /(.+)\.gif/, "$1-hover.gif" );

					if ( oLI.className.match( /selected/ ) || bHoverState )
					{
						// enforce the 'over' image
						if ( !bHoverState )
							oImage.src = sActiveSource;
					}
					else
					{
						oLI._parent        = this;
						oLI._index         = nIndex;
						oLI.onmouseover    = this.__over;
						oLI.onmouseout     = this.__out;
						this._image[ nIndex ] = {
							image:oImage, 
							active:new Image(),
							normal:new Image()
						};

						this._image[ nIndex ].active.src = sActiveSource;
						this._image[ nIndex ].normal.src = oImage.src;
					}
				}
			};
			NavigationTabs.prototype.toggle = function( nIndex, bState )
			{
				this._image[ nIndex ].image.src = this._image[ nIndex ][ bState ? "active" : "normal" ].src;
			};
			NavigationTabs.prototype.__out = function()
			{
				this._parent.toggle( this._index, false );
			};
			NavigationTabs.prototype.__over = function()
			{
				this._parent.toggle( this._index, true );
			};
