// JavaScript Document

function BrowserInfo()
{
    this.IsNetscape = navigator.appName == "Netscape";
    this.IsIE       = navigator.appName == "Microsoft Internet Explorer";
}

function Point( x, y )
{
    this.X = x;
    this.Y = y;
}

var Browser = new BrowserInfo();

function getElementPageLocation( el )
{
    var x = 0;
    var y = 0;
    
    while ( el != null )
    {
        x += el.offsetLeft;
        y += el.offsetTop;
        el = el.offsetParent;
    }
    
    return new Point( x, y );
}

function findElement( name )
{
    if ( Browser.IsNetscape )
    {
        return document.getElementById( name );
    } 
    else if ( Browser.IsIE )
    {
        return document.all( name );	
    }
    else
    {
        return document.getElementById( name );
    }
}

function MenuSection( title, link )
{
    this.Title          = title;
    this.Link           = link;
    this.SubMenuItems   = null;
    this.SubmenuName    = "fmenu_" + title;
}

function MenuItem( item, link )
{
    this.Item   = item;
    this.Link   = link;
}

MenuSection.prototype.addMenuItem = function( item )
{
    if ( this.SubMenuItems == null )
    {
        this.SubMenuItems = new Array();
    }
    
    this.SubMenuItems[ this.SubMenuItems.length ] = item;
}

MenuSection.prototype.genSingleMenu = function( menuId, items )
{
    var menuId = this.SubmenuName;
    var items  = this.SubMenuItems;
    
    if ( items != null )
    {
        document.write( "<div id='" + menuId + "' style='visibility:hidden; position:absolute;' class='fnav_sectionmenu' onmouseover=\"showSection('" + menuId + "')\" onmouseout=\"hideSection('" + menuId + "')\">" );
        document.write( "<table width='100%' border='1' cellpadding='0' cellspacing='0' >" );
        document.write( "<tr><td>" );
        document.write( "<table width='100%' border='0' cellpadding='0' cellspacing='0' >" );
    
        for ( var i = 0; i < items.length; ++i )
        {
            document.write( "<tr><td class='fnav_menuitem' onclick=\"javascript:location.href = '" + items[ i ].Link + "'\" onmouseover='MenuItemMouseAction(this, true)' onmouseout='MenuItemMouseAction(this, false)'>" );
            document.write( "&#8226;&nbsp;" );
            document.write( items[ i ].Item );
            document.write( "</td></tr>" );
        }
    
        document.write( "</table>" );
        document.write( "</td></tr>" );
        document.write( "</table>" );
        document.write( "</div>" );
    }
}

function setSectionState( menuName, parentName, show )
{
    var menuElement = findElement( menuName );
    var menuParent  = findElement( parentName );
    
    if ( menuElement != null )
    {
        if ( show )
        {
            p = getElementPageLocation( menuParent );
            menuElement.style.left = (p.X - 2) + "px";	
            menuElement.style.top  = (p.Y + menuParent.offsetHeight - 1) + "px";
            menuElement.style.width = (menuParent.offsetWidth) + "px";
            menuElement.style.visibility = "visible";
        }
        else
        {
            menuElement.style.visibility = "hidden";
        }
    }

    if ( menuParent != null )
    {
        if ( show )
        {
            menuParent.className = "fnav_section_highlight";
        }
        else
        {
            menuParent.className = "fnav_section";
        }
    }
}

function showSection( id )
{
    setSectionState( id, id + "Parent", true );
}

function hideSection( id )
{
    setSectionState( id, id + "Parent", false );
}

function MenuItemMouseAction( el, highlight )
{
    if ( el != null )
    {
        if ( highlight )
        {
	       el.className = "fnav_menuitem_highlight";
        }
        else
        {
	       el.className = "fnav_menuitem";
        }
    }
}

function MenuBarC()
{
    this.MenuSections = new Array();
}

MenuBarC.prototype.addSection = function( section )
{
    this.MenuSections[ this.MenuSections.length ] = section;
}

MenuBarC.prototype.curSection = function()
{
    return this.MenuSections[ this.MenuSections.length - 1 ];
}

MenuBarC.prototype.genMenuBar = function()
{
    var menus   = this.MenuSections;
    
    document.write( "<div class='floatleft fnav_bar' >" );
    document.write( "<table width='100%' border='0' cellspacing='0' cellpadding='0'>" );
    document.write( "<tr>" );
    
    // Generate the bar itself
    for ( var i = 0; i < menus.length; ++i )
    {
        document.write( "<td>&nbsp;</td>" );
        document.write( "<td class='fnav_section' id='" + menus[ i ].SubmenuName + "Parent' onclick=\"javascript:location.href = '" + menus[ i ].Link + "'\"" );
        
        // If there are children, only then put the mouse over effects
        if ( menus[ i ].SubMenuItems != null )
        {
            document.write( " onmouseover=\"showSection('" + menus[ i ].SubmenuName + "')\" onmouseout=\"hideSection('" + menus[ i ].SubmenuName + "')\"" );
        }
        
        document.write( ">" + menus[ i ].Title + "</td>" );
    }

    document.write( "<td>&nbsp;</td>" );
    document.write( "</tr></table></div>" );

    // Generate the hidden sub menus of the menubar
    for ( var i = 0; i < menus.length; ++i )
    {
        menus[ i ].genSingleMenu();
    }
}
//-->
