// Global variables
var isCSS 			= false;
var isW3C 			= false;
var isIE4 			= false;
var isNN4 			= false;
var isIE6 			= false;
var isGecko 		= false;
var isOpera 		= false;
var isDHTML 		= false;
var suppressMenus	= false;
var timerID			= null;
var subtimerID		= null;

// initialize upon load to let all browsers establish content objects
function autoconfig()
{
    if(document && document.images)
    {
        isCSS		= (document.body && document.body.style) ? true : false;
        isW3C		= (isCSS && document.getElementById) ? true : false;
        isIE4		= (isCSS && document.all && readIEVer() >= 4.0) ? true : false;
        isNN4		= (document.layers) ? true : false;
        isGecko		= (isCSS && navigator && navigator.product && navigator.product == "Gecko");
        isOpera		= (isCSS && navigator.userAgent.indexOf( "Opera") != -1 );
		isIE6CSS	= (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
		isIE6		= ( isIE6CSS && readIEVer() >= 6.0 );
        isDHTML		= isCSS && ( isIE4 || isGecko || isOpera );

        if( suppressMenus )
        {
			// Netscape 6.2 puts the menus in the wrong place...
			// Safari, the menus don't go away... problem in ResetMenu
			isDHTML	= false;
        }
        else if( isOpera && readOperaVer() < 7 )
        {
			// Opera 6.x doesn't seem to like the DHTML...
			isDHTML	= false;
        }
		else if( isGecko && navigator.productSub <= 20011022 )
        {
			// Netscape 6.2 puts the menus in the wrong place...
			isDHTML	= false;
        }
		else if( isGecko && navigator.productSub == 20030107 )
        {
			// Safari, the menus don't go away... problem in ResetMenu
			isDHTML	= false;
        }
    }
}

function readIEVer()
{
	var agent	= navigator.userAgent;
	var offset	= agent.indexOf( "MSIE" );
	if( offset < 0 )
	{
		return 0;
	}
	return parseFloat( agent.substring( offset + 5, agent.indexOf( ";", offset ) ) );
}

function readOperaVer()
{
	var agent	= navigator.userAgent;
	var offset	= agent.indexOf( "Opera" );
	if( offset < 0 )
	{
		return 0;
	}
	return parseFloat( agent.substring( offset + 6 ) );
}

// Seek nested NN4 layer from string name
function seekLayer(doc, name)
{
    var theObj;
    for (var i = 0; i < doc.layers.length; i++)
    {
        if (doc.layers[i].name == name)
		{
            theObj = doc.layers[i];
            break;
        }

        // dive into nested layers if necessary
        if (doc.layers[i].document.layers.length > 0)
		{
            theObj = seekLayer(document.layers[i].document, name);
        }
    }
    return theObj;
}

function parentNode(elem)
{
	if( elem.parentElement )
	{
		return elem.parentElement;
	}
	
	if( elem.parentNode )
	{
		return elem.parentNode;
	}

	return null;
}

function contains(lookWhere,lookFor)
{
	if( lookWhere == null || lookFor == null )
	{
		return false;
	}
	
/*	if( lookWhere.contains )
	{
		return lookWhere.contains( lookFor );
	}
	else	*/
	{
		var parent = parentNode( lookFor );
		
		while( parent )
		{
			if( parent == lookWhere )
			{
				return true;
			}
			
			parent = parentNode( parent );
		}
	}
	
	return false;
}

// Convert object name string or object reference
// into a valid element object reference
function getRawObject(obj)
{
    var theObj;
    if (typeof obj == "string")
    {
        if (isW3C)
		{
			theObj = document.getElementById(obj);

			if( !theObj )
			{
				theObj = document.getElementByName(obj);
			}
		}
		else if (isIE4)
		{
			theObj = document.all(obj);
		}
		else if (isNN4)
		{
			theObj = seekLayer(document, obj);
		}
    } 
    else
    {
        // pass through object reference
        theObj = obj;
    }
    return theObj;
}

// Convert object name string or object reference
// into a valid style (or NN4 layer) reference
function getObject(obj)
{
    var theObj = getRawObject(obj);
    if (theObj && isCSS)
    {
        theObj = theObj.style;
    }
    return theObj;
}

function getObjectsByTag(tag)
{
	if( document.getElementsByTagName )
	{
		return document.getElementsByTagName(tag);
	}
	else if( document.all )
	{
		return document.all.tags(tag);
	}

	return null;
}

// get the element an event refers to
function eventToElement( evt )
{
	var elem = null;
	
	if( evt.target )
	{
		elem = evt.target;
	}
	else if( evt.toElement )
	{
		elem = evt.toElement;
	}
	
	if( elem && elem.nodeName == "#text" )
	{
		elem = elem.parentNode;
	}
	
	return elem;
}

// Set the visibility of an object to visible
function show(obj)
{
    var theObj = getObject(obj);
    if (theObj)
    {
        theObj.visibility = "visible";
    }
}

// Set the visibility of an object to hidden
function hide(obj)
{
    var theObj = getObject(obj);
    if (theObj)
    {
        theObj.visibility = "hidden";
    }
}

// Set the visibility of an object to hidden
function isVisible(obj)
{
    var theObj = getObject(obj);
    return (theObj) ? ( theObj.visibility == "visible" ) : false;
}

// Position an object at a specific pixel coordinate
function shiftTo(obj, x, y) 
{
    var theObj = getObject(obj);
    if (theObj) 
    {
        if (isCSS) 
        {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = x + units;
            theObj.top = y + units;
        }
        else if (isNN4) 
        {
            theObj.moveTo(x,y)
        }
    }
}

// Retrieve the x coordinate of a positionable object
function getObjectLeft(obj) 
{
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView)
    {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    }
    else if (elem.currentStyle)
    {
        result = elem.currentStyle.left;
    }
    else if (elem.style)
    {
        result = elem.style.left;
    }
    else if (isNN4)
    {
        result = elem.left;
    }
    return parseInt(result);
}

// Retrieve the y coordinate of a positionable object
function getObjectTop(obj) 
{
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView)
    {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("top");
    }
    else if (elem.currentStyle)
    {
        result = elem.currentStyle.top;
    }
    else if (elem.style)
    {
        result = elem.style.top;
    }
    else if (isNN4)
    {
        result = elem.top;
    }
    return parseInt(result);
}

// Retrieve the rendered width of an element
function getObjectWidth(obj) 
{
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetWidth)
    {
        result = elem.offsetWidth;
    }
    else if (elem.clip && elem.clip.width)
    {
        result = elem.clip.width;
    }
    else if (elem.style && elem.style.pixelWidth)
    {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}

// Retrieve the rendered height of an element
function getObjectHeight(obj) 
{
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetHeight)
    {
        result = elem.offsetHeight;
    }
    else if (elem.clip && elem.clip.height)
    {
        result = elem.clip.height;
    }
    else if (elem.style && elem.style.pixelHeight)
    {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}

// Return the available content width space in browser window
function getInsideWindowWidth() 
{
    if (window.innerWidth)
    {
        return window.innerWidth;
    }
    else if ( isIE6CSS )
    {
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth
    }
    else if (document.body && document.body.clientWidth)
    {
        return document.body.clientWidth;
    }
    return 0;
}

// Return the available content height space in browser window
function getInsideWindowHeight() 
{
    if( window.innerHeight )
    {
        return window.innerHeight;
    }
    else if( isIE6CSS )
    {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight
    }
    else if (document.body && document.body.clientHeight)
    {
        return document.body.clientHeight;
    }
    return 0;
}

function getCookie(NameOfCookie) 
{
	if (document.cookie.length > 0) 
	{
		begin = document.cookie.indexOf(NameOfCookie+"="); 
		if (begin != -1) 
		{
			begin += NameOfCookie.length + 1; 
			end = document.cookie.indexOf(";", begin);
			if (end == -1) 
			{
				end = document.cookie.length;
			}
			return unescape( document.cookie.substring(begin, end)); 
		} 
	}

	return ""; 
}

function SetCookie (NameOfCookie , value) 
{	
	document.cookie	= NameOfCookie + "=" + escape( value );
}

function AutoSubmit ( frm )
{
	var		cookieVal	= getCookie ( "autosubmit" );
	if ( cookieVal == document.location )
	{
		var 	submitForm	= window.confirm ( "Resubmit form?");
		if ( submitForm	)
		{
			frm.submit();
			return;
		}
		else
		{
			return;
		}	
		
	}
	SetCookie( "autosubmit" , document.location );
	frm.submit();
}

// menu builder
var m_header		= null;
var m_menu			= null;
var m_subMenu		= null;
var m_subMenuEvtCtl	= null;
var m_hilite		= null;
var m_colorDepth	= 0;
var m_stdTarget		= " target=\"_blank\"";
var m_stdEmpty		= "";
var m_stdOffImg;

function renderMenuStripSep()
{
	document.write( "<td nowrap style=\"background:url(/images/navSep.jpg);\" width=\"1\" height=\"100%\"></td>" );
	
}

function menuGoto( url )
{
	hideMenus();
	
	if ( url != null && url.indexOf( "javascript" ) > -1 )
	{
		eval ( url );
	}
	else if ( url != null && url.indexOf( "#popup" ) > -1 )
	{
		window.open( url );
		return false;
	}
	else
	{
		
		document.location = url;
	}
	
	
	if( event != null )
	{
		event.cancelBubble = true;
	}
	
	return false;
}

function menuWinOpen( url )
{
	hideMenus();
	
	window.open( url );
	
	return false;
}

function renderMenuStrip()
{
	var menuHeaderID;

	if( isIE6 )
	{
		bodyTag.style.behavior	= "url(#default#clientCaps)";
		m_colorDepth			= bodyTag.colorDepth;
	}

	spacing = "&nbsp;&nbsp;";
	
	if( m_menuBar.length < 4 )
	{
		spacing += spacing;
	}

	var presep = ( m_menuBar.length <= 3 );

	if( presep )
	{
		document.write( "<td class=\"menuMainItem\" id=\"rightSpaceHdr\" nowrap=\"1\">&nbsp;</td>" );
	}
	
	for( n = 0; n < m_menuBar.length; n++ )
	{
		if( n > 0 )
		{
			renderMenuStripSep();
		}
		
		menuHeaderID = m_menuBar[n].Id + "Hdr";

		if( isDHTML )
		{
			document.write( "<td class=\"menuMainItem\"  id=\"" + menuHeaderID + "\" onmouseover=\"showMenu(event, \'" + menuHeaderID + "\', \'" + m_menuBar[n].Id + "\' )\" onmouseout=\"resetMenu(event)\" onclick=\"" );
			
			if( m_menuBar[n].TargetHtml )
			{
				document.write( "return menuWinOpen( \'" + m_menuBar[n].Href + "\' )" );
			}
			else
			{
				document.write( "return menuGoto( \'" + m_menuBar[n].Href + "\' )" );
			}

			document.write( "\" align=\"center\" style=\"cursor:hand\" nowrap=\"1\">" );
			document.write( "<a href=\"" + m_menuBar[n].Href + "\" class=\"menuMainItem\" style=\"text-decoration:none\"" + this.TargetHtml + ">" + spacing + m_menuBar[n].Text );
			
			if( m_menuBar[n].OffDell )
			{
				document.write( m_stdOffImg );
			}
				
			document.write( "</a></td>" );
		}
		else
		{
			document.write( "<td class=\"menuMainItem\" id=\"" + menuHeaderID + "\" align=\"center\" nowrap=\"1\">" );
			document.write( "<a href=\"" + m_menuBar[n].Href + "\" class=\"menuMainItem\"" + this.TargetHtml + ">" + m_menuBar[n].Text );
			
			if( m_menuBar[n].OffDell )
			{
				document.write( m_stdOffImg );
			}
			
			document.write( "</a></td>" );
		}
	}
}

function renderItems( menu, z )
{
	renderSubItems( menu, z, "menuItem" );
}

function renderSubItems( menu, z, css )
{
	if( css == "menuItem" )
	{
		document.write( "<table border='0' bgcolor='#CCCCCC' class='menu' width='175' id='" + menu.Id + "' cellspacing='0' cellpadding='3'  style='position:absolute;top:0;left:0;z-index:" + z + ";visibility:hidden' onmouseout='resetMenu(event)' summary='Table for the " + menu.Id + "'>" );
	}
	else
	{
		document.write( "<table border='0' bgcolor='#CCCCCC' class='submenu' width='189' id='" + menu.Id + "' cellspacing='0' cellpadding='3' style='position:absolute;top:0;left:0;z-index:" + z + ";visibility:hidden' onmouseout='resetMenu(event)' summary='Table for the " + menu.Id + "'>" );
	}

	for( var n = 0; n < menu.MenuItems.length; n++ )
	{
		var	item = menu.MenuItems[n];
	
		if( item.IsSeparator )
		{
			document.write( "<tr><td><hr width=\"100%\" size=\"1\"></td></tr>" );
		}
		else if( item.MenuItems )
		{
			document.write( "<tr><td nowrap=\"1\" class=\"" + css + "\" onmouseover=\"showSubMenu(event, '" + item.Id + "')\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"subContainer\"><tr><td nowrap=\"1\"><a href=\"" + item.Href + "\" class=\"menuItem\" style=\"text-decoration:none\"" + item.TargetHtml + ">" + item.Text + "</a></td></tr></table></td></tr>" );
		}
		else
		{
			document.write( "<tr><td nowrap=\"1\" class=\"" + css + "\" onclick=\"" );
			
			if( item.TargetHtml )
			{
				document.write( "return menuWinOpen( \'" + item.Href + "\' )" );
			}
			else
			{
				document.write( "return menuGoto( \'" + item.Href + "\' )" );
			}
			
			document.write( "\"><a href=\"" + item.Href + "\" class=\"menuItem\" style=\"text-decoration:none\"" + item.TargetHtml + ">" + item.Text );
			
			if( item.OffDell )
			{
				document.write( m_stdOffImg );
			}
			
			document.write( "</a></td></tr>" );
		}
	}
	
	document.write( "</table>" );

	for( var n = 0; n < menu.MenuItems.length; n++ )
	{
		var	item = menu.MenuItems[n];
		
		if( item.MenuItems )
		{
			renderSubItems( item, z + 1, "menuSubItem" );
		}
	}
}

function menuRef( id, text, href, items, target )
{
	this.Id				= id;
	this.Text			= text;
	this.Href			= href; //mhFixupLink( href, "&~ck=mn");
	this.IsSeparator	= false;
	this.IsCaption		= false;
	this.MenuItems		= items;

	this.OffDell		= false;
	this.TargetHtml		= m_stdEmpty;

	if( ( typeof(target) != "undefined" ) && target )
	{
		this.OffDell	= ( target == "offdell" );
		this.TargetHtml	= " target=\"" + target + "\"";
	}
}

function menuItem( text, href, target )
{
	this.Text			= text;
	this.Href			= href; //mhFixupLink( href, "&~ck=mn" );
	this.IsSeparator	= false;
	this.IsCaption		= false;
	this.MenuItems		= null;

	this.OffDell		= false;
	this.TargetHtml		= m_stdEmpty;

	if( ( typeof(target) != "undefined" ) && target )
	{
		this.OffDell	= ( target == "offdell" );
		this.TargetHtml	= " target=\"" + target + "\"";
	}
}

function menuSep()
{
	this.IsSeparator	= true;
	this.IsCaption		= false;
}

// -------------------------------------------------------------
// menu display/hiding functions
// -------------------------------------------------------------

function showSubMenu( evt, menuID )
{
	if( isDHTML )
	{
		evt			= evt ? evt : event;
		
		var top		= -1;
		var left;
		var currentEle;

		var newMenu = getRawObject( menuID );
		
		if( m_menu.id == m_menuBar[m_menuBar.length - 1].Id )
		{
		//	left = m_header.offsetLeft + m_header.offsetWidth - m_menu.offsetWidth - newMenu.offsetWidth + 5 + document.body.offsetLeft;
			left = m_menu.offsetLeft - newMenu.offsetWidth + 5;
		}
		else
		{
		//	left = m_header.offsetLeft + m_menu.offsetWidth + 3;
			left = m_menu.offsetLeft + m_menu.offsetWidth - 8;
		}
		
		if( subtimerID )
		{
			if( newMenu && newMenu == m_subMenu )
			{
				return;
			}		
		
			clearTimeout( subtimerID );
			subtimerID = null;
		}
	
		if( m_subMenu != null)
		{
			if( m_subMenu == newMenu )
			{
				evt.cancelBubble = true;
				return;
			}
			
			if( isVisible(m_subMenu) )
			{
				hideSubMenu();
			}
		}
		

		if( m_hilite )
		{
			m_hilite.className = "";
			m_hilite = null;
		}
		
		m_subMenuEvtCtl = eventToElement( evt );
		m_subMenu		= newMenu;
		
		currentEle		= getHilite( evt );
			
		rowHeight		= ( ( m_menu.offsetHeight ) / ( m_menu.rows.length ) );

		top			+= m_menu.offsetTop - 1;
		top			+= currentEle.rowIndex * rowHeight;

		shiftTo( m_subMenu, left, top );
	
		if( !isVisible(m_subMenu) )
		{
			subtimerID = setTimeout( "showSubMenuTimed()", 100 );
		}
				
		evt.cancelBubble = true;
	}
}

function showSubMenuTimed()
{
	if( m_subMenu == null )
	{
		return;
	}

	if( isIE6 && m_subMenu.filters && m_colorDepth > 8 )
	{
		m_subMenu.filters.item(0).Apply();
		m_subMenu.filters.item(1).Apply();
	}

	show(m_subMenu);

	if( isIE6 && m_subMenu.filters && m_colorDepth > 8 )
	{
		m_subMenu.filters.item(0).Play();
		m_subMenu.filters.item(1).Play();
	}
}

// defines/shows the current header and menu
//
function showMenu( evt, menuHeaderID, menuID )
{
	if( isDHTML )
	{
		evt = evt ? evt : event;

		if( timerID )
		{
			clearTimeout( timerID );
			timerID = null;
		}

		if( subtimerID )
		{
			clearTimeout( subtimerID );
			subtimerID = null;
		}

		timerID = setTimeout( "showMenuTimed( '" + menuHeaderID + "', '" + menuID + "')", 200 );

		evt.cancelBubble = true;
	}
}

function showMenuTimed( menuHeaderID, menuID )
{
	var top		= 0;
	var left	= 0;
	var currentEle;

	var newMenu = getRawObject( menuID );

	if(m_header != null && m_menu != null && m_menu != newMenu)
	{
		if( isVisible(m_menu) )
		{
			hideMenu();
			showSelectCtrl();
		}
	}

	m_header			= getRawObject( menuHeaderID );
	m_menu				= newMenu;
	m_header.className	= "menuMainItemSel";
	
	currentEle	= m_header;
		
	// work out the position of the header and its parent elements
	//
	while( currentEle && currentEle.tagName.toLowerCase() != 'body' )
	{
		top			+= currentEle.offsetTop;
		left		+= currentEle.offsetLeft;
		currentEle	 = currentEle.offsetParent;
	}

	top			+= currentEle.offsetTop;
	left		+= currentEle.offsetLeft;
	
	if( menuHeaderID == ( m_menuBar[m_menuBar.length - 1].Id + "Hdr" ) )
	{
		left += m_header.offsetWidth - m_menu.offsetWidth;
	}
	
	// add the width of the header, and width of extra image.
	//
	top += (m_header.offsetHeight);
				
	shiftTo( m_menu, left, top );

	hideSelectCtrl();

	if( !isVisible(m_menu) )
	{
		if( isIE6 && typeof(m_menu.filters) != "undefined" && m_menu.filters && m_colorDepth > 8 )
		{
			m_menu.filters.item(0).Apply();
			m_menu.filters.item(1).Apply();
		}
		
		show(m_menu);

		if( isIE6 && typeof(m_menu.filters) != "undefined" && m_menu.filters && m_colorDepth > 8 )
		{
			m_menu.filters.item(0).Play();
			m_menu.filters.item(1).Play();
		}
	}
}

// Hide the current menu
//
function hideMenu()
{
	if( isDHTML && m_menu )
	{
		hideSubMenu();

		hide(m_menu);
		m_header.className			= "menuMainItem";
		m_menu						= null;
	}
}

function hideSubMenu()
{
	if( isDHTML && m_subMenu )
	{
		hide(m_subMenu);
		m_subMenuEvtCtl				= null;
		m_subMenu					= null;

		clearHilite( m_menu );
	}
}

function hideMenus()
{
	if( timerID )
	{
		clearTimeout( timerID );
		timerID = null;
	}
	
	hideMenu();
}

// hide/reset the current menu, but only if we're
// not moving onto the menu itself
//
function resetMenu( evt )
{
	if( isDHTML )
	{
		evt = evt ? evt : event;

		if( timerID )
		{
			clearTimeout( timerID );
			timerID = null;
		}

		if( m_header != null && m_menu != null )
		{
			var	dest		= eventToElement( evt );
			
			var notSubMenu	= ( m_subMenu != dest && !contains( m_subMenu, dest ) );
			
			// hide the submenu if necessary
			//
			if( m_subMenu && m_subMenuEvtCtl && notSubMenu && m_subMenuEvtCtl != dest && !contains( m_subMenuEvtCtl, dest ) && m_subMenu != dest && !contains( m_subMenu, dest ) )
			{
				hideSubMenu();
			}	

			// proceed if we're not moving onto a menu item
			//
			if( ( !m_subMenu || notSubMenu ) && dest && m_header != dest && !contains( m_header, dest ) && m_menu != dest && !contains( m_menu, dest ) )
			{
				hideSubMenu();

				hide(m_menu);
				m_header.className			= "menuMainItem";

				if( m_hilite )
				{
					m_hilite.className = "";
					m_hilite = null;
				}

				m_header							= null;
				m_menu								= null;
				m_hilite							= null;
				showSelectCtrl();
			}
			// work out what dest highlight
			//
			else if( m_menu || m_subMenu )
			{
				var hilite = getHilite( evt );
				
				if( hilite )
				{
					if( m_hilite && ( !m_subMenu || contains( m_subMenu, m_hilite ) ) )
					{
						m_hilite.className = "menuSubItem";
						m_hilite = null;
					}

					var content = hilite.innerHTML;
					
					if( content.indexOf( "menuSubItem" ) > 0 )
					{
						m_hilite = hilite;
						m_hilite.className = "menuSubSelRow";
					}
					else if( content.indexOf( "menuItem" ) > 0 )
					{
						m_hilite = hilite;
						m_hilite.className = "menuSelRow";
					}
				}
			}

			evt.cancelBubble = true;
		}
	}
}

function clearHilite( table )
{
	var	cell, row, count, ix;
	
	count = table.rows.length;
	
	for( ix = 0; ix < count; ix++ )
	{
		table.rows[ix].className = "";
	}
}

function getHilite( evt )
{
	evt			= evt ? evt : event;
	
	var hilite	= null;
	var	to		= eventToElement( evt );
	
	if( to && ( m_menu && contains( m_menu, to ) ) || ( m_subMenu && contains( m_subMenu, to ) ) )
	{
		hilite = to;
		
		while( hilite && hilite.tagName.toLowerCase() != "tr" )
		{
			hilite = parentNode( hilite );
		}
		
		if( hilite )
		{
			var menuTable = parentNode( parentNode( hilite ) );
			
			if( menuTable && menuTable.className && menuTable.className == "subContainer" )
			{
				var container = parentNode( menuTable );
				
				if( container.tagName.toLowerCase() == "td" )
				{
					hilite = parentNode( container );
				}
			}
		}
	}
	
	return hilite;
}

// -------------------------------------------------------------
// HTML workarounds
// -------------------------------------------------------------

// Show SELECT controls (dropdown lists) when menu is hidden
//
function showSelectCtrl()
{
	var obj;
	var tags = getObjectsByTag("select");
	
	for( var i = 0; i <tags.length; i++ )
	{
		obj = tags[i];
		if(obj && obj.offsetParent)
		{
			show(obj);
		}
	}

/**/	tags = getObjectsByTag("object");
	
	for( var i = 0; i <tags.length; i++ )
	{
		obj = tags[i];
		if(obj && obj.offsetParent)
		{
			show(obj);
		}
	}	/**/
}

// Hide SELECT controls (dropdown lists), otherwise the Select will
// appear on top of the menu (HTML workaround)
//
function hideSelectCtrl()
{
	hideCtrl( getObjectsByTag("select") );
	hideCtrl( getObjectsByTag("object") );
}

function hideCtrl( tags )
{
	var obj;
	var currentEle;
	var menuHeight;
	var timeout;
	var top			= 0;
	var left		= 0;
	
	for( var i = 0; i < tags.length; i++ )
	{
		obj			= tags[i];
		currentEle	= obj;
	
		while( currentEle && currentEle.tagName.toLowerCase() != 'body' )
		{
			top			+= currentEle.offsetTop;
			left		+= currentEle.offsetLeft;
			currentEle	 = currentEle.offsetParent;
		}

		if(m_menu != null)
		{
			menuHeight = ( m_menu.offsetTop + m_menu.offsetHeight );
			
			if( top < menuHeight )
			{
				if((left < (m_menu.offsetLeft + m_menu.offsetWidth)) && (left + obj.offsetWidth > m_menu.offsetLeft)) 
				{
					hide(obj);
				}
			}
		}

		top		= 0;
		left	= 0;
	}
}

// -------------------------------------------------------------
// client-side masthead
// -------------------------------------------------------------

var m_pnlinks;
var m_crumbs;
var m_mhFixed		= false;
var m_isHome		= false;
var m_isSegHome		= false;
var m_mda			= null;
//var m_printLink		= null;
//var m_emailLink		= false;
//var m_helpLink		= null;
var m_production	= true;
var m_menudef		= "/content/public/menudef.aspx";
var m_avgChW		= 6;
var m_crumbRegEx1	= /<.*>/g;
var m_crumbRegEx2	= /&nbsp;/g;
var m_crumbRegEx3	= /&~ck=bt/g;

function writeMHPop()
{
	autoconfig();

	writeMHPopInternal( true );
}

function writeMHFlat()
{
	autoconfig();

	writeMHPopInternal( false );
}

function writeMH( phoneTitle, phoneMsg, phoneTariff, segmentTitle, hasLocale, logoLink, pnmsg )
{
	autoconfig();

	if( !m_production && typeof(m_menuBar) == "undefined" )
	{
		document.write( "<div class=\"para\" style=\"color:red; font-weight:bold\">There is a problem with the menu definition. " );
		document.write( "<a href=\"" + m_menudef + "\">Click here to view</a></div>" );
		
		return;
	}
	
	m_mhFixed	= true;

	if( isDHTML )
	{
		for( var n = 0; n < m_menuBar.length; n++ )
		{
			renderItems( m_menuBar[n], 100 );
		}
	}

	if( document.body )
	{
		document.body.onmouseover	= resetMenu;
		document.body.onmouseout	= resetMenu;
	}
	else
	{
		var bodytags = getObjectsByTag( "body" );
		
		if( bodytags && bodytags.length > 0 )
		{
			bodytags[0].onmouseover	= resetMenu;
			bodytags[0].onmouseout	= resetMenu;
		}
	}
		// nav strip
		if( typeof(m_menuBar) != "undefined" && m_menuBar && m_menuBar.length > 0 )
		{
			
			document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">" );
			
			if( m_menuBar.length < 4 )
			{
				document.write( "<tr><td style=\"background:url(navBg.jpg) repeat-x;\">" );//INSERT BACKGROUND HERE
				document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>" );
				renderMenuStripSep();
			}
			else
			{
				document.write( "<tr><td style=\"background:url(navBg.jpg) repeat-x;\">" );//INSERT BACKGROUND HERE
				document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr>" );
			}
			
			renderMenuStrip();
			document.write( "</tr></table></td></tr></table>" );
		}
		else
		{
			document.write( "<tr><td bgcolor=\"#004E98\" colspan=\"5\">Menu bar is undefined.</td></tr></table>" );
		}

}

function renderCrumbs( forFooter )
{
	document.write( "<tr><td bgcolor=\"#e1e1e1\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"728\">" );
	document.write( "<tr><td bgcolor=\"#f5f5f5\" valign=\"middle\" height=\"23\" class=\"para_small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + m_backto + ":&nbsp;" );

	var totalw = 710 - ( m_backto.length * m_avgChW );

	for( var n = 0; n < 2; n++ )
	{
		if( n >= m_crumbs.length )
		{
			break;
		}
		
		if( n > 0 )
		{
			document.write( "&nbsp;&gt;&nbsp;" );
			totalw -= 16;
		}
		
		href = m_crumbs[n].Href;
		
		if( href )
		{
			if( forFooter )
			{
				href = href.replace( m_crumbRegEx3, "&~ck=bb" );
			}
			
			document.write( "<a class=\"lnk_small\" href=\"" + href + "\">" + m_crumbs[n].Text + "</a>" );
		}
		else
		{
			document.write( "<span class=\"crumbsel\">" + m_crumbs[n].Text + "</span>" );
		}
		
		totalw -= crumbWidth( m_crumbs[n].Text );
	}

	var trail = "";

	for( var n = m_crumbs.length - 1; n >= 2; n-- )
	{
		totalw -= crumbWidth( m_crumbs[n].Text ) + 16;
		
		if( totalw < 0 )
		{
			break;
		}

		href = m_crumbs[n].Href;
		
		if( href )
		{
			if( forFooter )
			{
				href = href.replace( m_crumbRegEx3, "&~ck=bb" );
			}

			trail = "&nbsp;>&nbsp;<a class=\"lnk_small\" href=\"" + href + "\">" + m_crumbs[n].Text + "</a>" + trail;
		}
		else
		{
			trail = "&nbsp;>&nbsp;<span class=\"crumbsel\">" + m_crumbs[n].Text + "</span>" + trail;
		}
	}
	
	if( trail.length > 0 )
	{
		if( totalw < 0 )
		{
			document.write( "&nbsp;&gt;&nbsp;<span class=\"crumbsel\">...</span>" );
		}
		
		document.write( trail );
	}
			
	document.write( "</td>" );
	
	document.write( "</tr></table></td></tr>" );
}

function crumbWidth( crumb )
{
	var text = crumb.replace( m_crumbRegEx1, "" );
	text = text.replace( m_crumbRegEx2, " " );
	
	var hasUnicode = false;
	
	for( n = 0; n < text.length; n++ )
	{
		if( text.charCodeAt( n ) > 0x1000 )
		{
			hasUnicode = true;
			break;
		}
	}
	
	if( hasUnicode )
	{
		return text.length * m_avgChW;
	}
	else
	{
		return text.length * 6;
	}
}

function addPnLink( text, href, icon )
{
	if( !m_pnlinks )
	{
		m_pnlinks = new Array();
	}
	
	m_pnlinks[m_pnlinks.length] = new mhLink( text, href, icon, "&~ck=pn" );
}

function addCrumb( text, href )
{
	if( !m_crumbs )
	{
		m_crumbs = new Array();
	}
	
	m_crumbs[m_crumbs.length] = new mhLink( text, href, null, "&~ck=bt" );
}
