//
// common.js
//

// -------------------------------------------------------------
// cross-browser helper functions
// -------------------------------------------------------------

document.domain						= "shiplaser.com" ;

// 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 legacyMode		= false;
var timerID			= null;
var subtimerID		= null; 
var resetmain		= null;
var resetsub		= null;
var	resetmenu		= null;
var tempEvent		= null;
var lastPopup		= null;
var resetTime		= 500;
var screenWidth		= null;
var	m_anchorClicked = false;
var m_mhbg			= "#E9E9E9";


function addBookMark()
{
	if (window.external) 
		{
			window.external.AddFavorite(document.location.href,document.title);
		} 
		else 
		{
			alert("Sorry, your browser doesn't support bookmarking this page...\n\nPlease try pressing Control + D instead");
		}  

}
		
// 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 ); 
        //screenWidth = (screen.width >= 1024 ? 952 : 728);   
        //According to the updated Storm 4.0 SRS      
		screenWidth	= 728; 
        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 )
        {
			var x = navigator.userAgent.indexOf( "AppleWebKit" );
			if( x > -1 )
			{
				// Tiger and newer versions of Safari ... 
				isDHTML = ( navigator.userAgent.substring( x + 12, x + 15 ) ) > 300;
			}
			else
			{
				// older versions of Safari ... the menus don't go away... problem in ResetMenu
				isDHTML	= false;
			}
        }
		var bwcv=  getCookie( "bandwidth" );
		var bw	= Bandwidth();
		if ( !(bwcv) || (bw && bwcv && bwcv.indexOf ( bw ) > -1 ))
		{
			SetCookie ( "bandwidth" , bw );
		}	
		
		
		//fix css
		if( typeof(m_search) != "undefined" && m_search != null )
		{
			var r1			= /mh_search_large\"/g;
			var r2			= /mh_search\"/g;
			var r3			=  /mh_search_sep\"/g;			
				
			m_search		= m_search.replace ( r1, "mh_search_large_SE\"" ).replace ( r2 , "mh_search_SE\"" ).replace ( r3 , "mh_search_sep_SE\"" ).replace ( "contentnav/btn_action_brand.gif", "brand/ui/primary.gif" );
		}
    }
}

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 BandWidthRedir (  url )
{
	var		bWidth	= Bandwidth();
	if ( bWidth == "Modem" ) 
	{
		document.location.href = url ;
	}
}
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);
		}
		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;
}

// Open a popup window
function winopen(url,stuff,morestuff) 
{
	var popwin = window.open(url,stuff,morestuff);
	
	// you may get "undefined" if a popup blocker did its thing...
	if( typeof(popwin) != "undefined" && popwin )
	{
		popwin.focus();
	}
	
	lastPopup = popwin;
}

// -------------------------------------------------------------
// cookie handling functions
// -------------------------------------------------------------

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 );
}

// Auto Submit the form if valid
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();
}

// Auto Submit Form if Valid/Create Form Freq Popup Window
function AutoSubmit2 ( frm, url, freq )
{
	var oldAction = frm.action;
	frm.action = url;
	var		cookieVal	= getCookie ( "autosubmit" );
	if ( cookieVal == document.location )
	{
		var 	submitForm	= window.confirm ( "Resubmit form?");
		if ( submitForm	)
		{
			if( freq == "true" )
			{
				frm.target = "FreqFormPopup";
				var x = window.open( url, "FreqFormPopup", "width=600, height=400, location=yes, menubar=yes, status=yes, toolbar=yes, scrollbars=yes, resizable=yes" );
			}
			frm.submit();
			frm.target = "_self";
			frm.action = oldAction;
			return;
		}
		else
		{
			return;
		}	
	}
	SetCookie( "autosubmit" , document.location );
	if( freq == "true" )
	{
		frm.target = "FreqFormPopup";
		var x = window.open( url, "FreqFormPopup", "width=600, height=400, location=yes, menubar=yes, status=yes, toolbar=yes, scrollbars=yes, resizable=yes" );
	}
	frm.submit();
	frm.target = "_self";
	frm.action = oldAction;
}

// Dynamic Forms Single Choice Skip Level
function singlechoiceskiplevel( formInput )
{
	if( typeof(formInput) != "undefined" )
	{
		var i = 0;
		while ( i < formInput.length )
		{
			if( formInput[i].value != null && formInput[i].value != "")
			{
				if( document.getElementById(formInput[i].value) != null )
				{
					if( formInput[i].selected || formInput[i].checked )
					{
						document.getElementById(formInput[i].value).style.display = "inline";
					}
					else
					{
						document.getElementById(formInput[i].value).style.display = "none";
					}
				}
			}
			i++;
		}
	}
}

// -------------------------------------------------------------
// menu builder functions
// -------------------------------------------------------------

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_menuArrows	= true;
var m_stdTarget		= " target=\"_blank\"";
var m_stdEmpty		= "";
var m_stdOffImg;

function renderMenuStripSep()
{
	document.write( "<td class=\"mhsep\" nowrap=\"1\"></td>" );
}

function menuGoto( url )
{
	if ( m_anchorClicked )
	{
		return;
	}
	m_anchorClicked	= true;
	hideMenus();
	if ( url != null && url.indexOf( "javascript" ) > -1 )
	{
		eval ( url );
	}
	else
	{
		document.location = url;
	}
	if( document.event != null )
	{
		document.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\" 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 style=\"padding-right:5px;\" 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:pointer\" 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].Offshiplaser )
			{
				document.write( m_stdOffImg );
			}
			
			if( m_menuArrows )
			{
				document.write( "<img src='" + m_imgPfx + "/images/global/masthead/mnmenuarrow.gif' height='7' width='15' alt='' border='0' />" );
				
				if( presep )
				{
					document.write( spacing );
				}
			}
			else
			{
				document.write( spacing );
			}
			
			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].Offshiplaser )
			{
				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)' onmouseover='clearReset()' summary='Table for the " + menu.Id + "'>" );
	}

	for( var n = 0; n < menu.MenuItems.length; n++ )
	{
		var	item = menu.MenuItems[n];
	    //where is menusep class
		if( item.IsSeparator )
		{
			document.write( "<tr><td class=\"menuSep\" background=\"" + m_imgPfx + "/images/global/masthead/menu_isep.gif\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" height=\"2\" width=\"1\" alt=\"\" /></td></tr>" );
		}
		else if( item.IsCaption )
		{
			if( n > 0 )
			{
				document.write( "<tr><td class=\"menuSep\" background=\"" + m_imgPfx + "/images/global/masthead/menu_isep.gif\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" height=\"2\" width=\"1\" alt=\"\" /></td></tr>" );
			}
			
			document.write( "<tr><td class=\"menuCaption\"><center><i>" + item.Text + "</i></center></td></tr>" );
			document.write( "<tr><td class=\"menuSep\" background=\"" + m_imgPfx + "/images/global/masthead/menu_isep.gif\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" height=\"2\" width=\"1\" alt=\"\" /></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><td nowrap=\"1\" align=\"right\" valign=\"middle\"><img src=\"" + m_imgPfx + "/images/global/masthead/menuarrow.gif\" height=\"7\" width=\"16\" alt=\"\" /></td></tr></table></td></tr>" );
		}
		else
		{
			document.write( "<tr><td nowrap=\"1\" class=\"" + css + "\" onmouseover=\"showSubMenu(event, null )\" onclick=\"" );
			
			if( item.TargetHtml )
			{
				document.write( "return menuWinOpen( \'" + item.Href + "\' )" );
			}
			else
			{
				document.write( "return menuGoto( \'" + item.Href + "\' )" );
			}
			
			document.write( "\"><a class=\"menuItem\" style=\"text-decoration:none\"" + item.TargetHtml + ">" + item.Text );
			
			if( item.Offshiplaser )
			{
				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			= mhFixupLink( href, "&~ck=mn" );
	this.IsSeparator	= false;
	this.IsCaption		= false;
	this.MenuItems		= items;

	this.Offshiplaser		= false;
	this.TargetHtml		= m_stdEmpty;

	if( ( typeof(target) != "undefined" ) && target )
	{
		this.Offshiplaser	= ( target == "offshiplaser" );
		this.TargetHtml	= " target=\"" + target + "\"";
	}
}

function menuItem( text, href, target )
{
	this.Text			= text;
	this.Href			= mhFixupLink( href, "&~ck=mn" );
	this.IsSeparator	= false;
	this.IsCaption		= false;
	this.MenuItems		= null;

	this.Offshiplaser		= false;
	this.TargetHtml		= m_stdEmpty;

	if( ( typeof(target) != "undefined" ) && target )
	{
		this.Offshiplaser	= ( target == "offshiplaser" );
		this.TargetHtml	= " target=\"" + target + "\"";
	}
}

function menuCaption( text )
{
	this.Text			= text;
	this.Href			= null;
	this.IsSeparator	= false;
	this.IsCaption		= true;
	this.MenuItems		= null;
}

function menuSep()
{
	this.IsSeparator	= true;
	this.IsCaption		= false;
}

// -------------------------------------------------------------
// menu display/hiding functions
// -------------------------------------------------------------

function clearReset()
{
	if( resetsub )
	{
		clearTimeout( resetsub );
		resetsub = null;
	}
	if( resetmain )
	{
		clearTimeout( resetmain );
		resetmain = null;
	}
	if( resetmenu )
	{
		clearTimeout( resetmenu );
		resetmenu = null;
	}
}

function showSubMenu( evt, menuID )
{
	if( resetmenu )
	{
		clearTimeout( resetmenu );
		resetmenu = null;		
	}
	if( !isIE6 )
	{
		clearTimeout( resetsub );
		resetsub = null;
	}
	
	if( menuID != null )
	{
		if( resetsub && isIE6 )
		{
			if( resetmain )
			{
				clearTimeout( resetmain );
				resetmain = null;
			}
			tempEvent = document.createEventObject( evt );
			resetmain = setTimeout( "showSubMenuDelay( '" + menuID + "' )", resetTime );
		}
		else
		{
			showSubMenuNow( evt, menuID );
		}
	}
	else
	{
		if( isIE6 && resetsub )
		{
			if( resetmain )
			{
				clearTimeout( resetmain );
				resetmain = null;
			}
			tempEvent = document.createEventObject( evt );
			resetmain = setTimeout( "setHiliteDelay()", resetTime );
		}
	}
}

function showSubMenuDelay( menuID )
{
	showSubMenuNow( tempEvent, menuID );
	setHilite( tempEvent );
}

function showSubMenuNow( 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;
		}
		else
		{
			left = m_header.offsetLeft + m_menu.offsetWidth + 3;
		}
		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;
		if( currentEle )
		{
			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 )
{	
	clearReset();
	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 );
	}
	if( resetsub )
	{
		clearTimeout( resetsub );
		resetsub = null;
	}
}

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( !resetsub )
	{
		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 ) )
				{
					if( !resetsub )
					{
						resetsub = setTimeout( "hideSubMenu()", resetTime );
					}	
				}
				
				// 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 ) )
				{
					if( !resetsub )
					{
						resetsub = setTimeout( "hideSubMenu()", resetTime );
					}	
					if( !resetmenu )
					{
						resetmenu = setTimeout( "hideMenus()", resetTime);
					}
					m_header.className			= "menuMainItem";

					if( m_hilite )
					{
						m_hilite.className = "";
						m_hilite = null;
					}

					if( !resetsub && !resetmenu )
					{
						m_header							= null;
						m_menu								= null;
						m_hilite							= null;
					}	
					showSelectCtrl();
				}
				// work out what dest highlight
				//
				else if( m_menu || m_subMenu )
				{
					setHilite( evt );
				}

				evt.cancelBubble = true;
			}
		}
	}
}

function setHiliteDelay()
{
	if( typeof(tempEvent) != "undefined" )
	{
		setHilite( tempEvent );
	}
}

function setHilite ( evt )
{
	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";
		}
	}
}

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/menu.aspx";
var m_avgChW				= 6;
var m_crumbRegEx1			= /<.*>/g;
var m_crumbRegEx2			= /&nbsp;/g;
var m_crumbRegEx3			= /&~ck=bt/g;
var m_subNavLinksDisplay	= false;
var m_subNavIconsDisplay	= false;
var m_largeFont				= false;
var m_pbarEnabled			= false;


function writeMH( phoneTitle, phoneMsg, phoneTariff, segmentTitle, hasLocale, logoLink, pnmsg )
{   
	
	document.writeln ( "<!-- begin masthead -->" );
		
	autoconfig();	

	if ( typeof(m_suppressPrintLink) != "undefined" )
	{
		m_printLink	= null;
	}
	if ( typeof(m_menuBar) == "undefined" )
	{
		if( !m_production  )
		{
			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;
		}
		return;
	}	
	

//	document.write( "<xmp>" );

	if( m_largeFont )
	{
		m_avgChW = m_avgChW + 2;	
	}
	
	m_mhFixed	= true;

	m_stdOffImg = "<img src=\"" + m_imgPfx + "/images/global/brand/icons/smextlink.gif\", width=\"16\" height=\"9\" border=\"0\"/>";

	if( isDHTML )
	{
		for( var n = 0; n < m_menuBar.length; n++ )
		{
			renderItems( m_menuBar[n], 100 );
		}
	}
	
	if( typeof(m_printableText) == "undefined" )
	{
		m_printableText = m_printText;
	}
	
	if( typeof(m_helpText) == "undefined" )
	{
		m_helpText = "Help";
	}

	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;
		}
	}
	
	if( m_isHome || hasLocale )
	{
		document.writeln( m_isHome ? m_localeSelector : m_localeSelectLite );
	}
		
	document.write( "</td></tr>" );//This is opened in pagehost file
	
	//Fix for Storm 4.2 100% width
	document.write ( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">" );
	document.write( "</td></tr>" );
	
	// phone strip	
	var phoneMdaWidth = 350;
	
	document.write( "<tr><td>" );	
	document.writeln( "<a name=\"mastheadtop\"></a>" );
	document.write( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">" );
		
	document.write( "<tr><td>" );		
	document.write( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"" + screenWidth + "\" >");	
	document.write( "<tr>" );	
	
	if( m_mda )
	{		
			document.write( "<td width=\"365\" align=\"left\" valign=\"bottom\" style=\"padding-left:8px;padding-top:0px;padding-bottom:3px;padding-right:8px\">" );
			document.write( "<span class=\"mhTextNewMda\">" );
			document.write( m_mda );
			document.write( "</span>" );
			document.write( "</td>" );	
	}	
	document.write( "<td style=\"padding-left:6px; padding-right:4px; padding-top:0px; padding-bottom:3px;\"  align=\"right\" valign=\"bottom\">" );

	if( phoneTitle || phoneMsg )
	{		
		document.write( "<span class=\"mhTextNewPnMsg\">" );
		
		if( phoneTitle )
		{
			document.write( phoneTitle );
			document.write( " " );
		}

		if( phoneMsg )
		{
			document.write( phoneMsg );
		}
			
		document.write( "</span>" );
	}
	
	if( phoneTariff )
	{		
		document.write( "<span class=\"mhTextNewTrf\"> " + phoneTariff + "</span>" );
	}		
	document.write("</td>" );
		
	document.writeln( "</tr>" );
	document.write( "</table>" );
	document.write( "</td><td width=\"100%\"></td></tr>" );	 

	// main section	
	
		document.write( "<tr class=\"mhbg\"><td>" );	
		document.write( "<table height=\"44\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + screenWidth + "\">" );
		document.write( "<tr><td height=\"44\" width=\"1\"></td>" );
		document.write( "<td width=\"122\">" );
		
		// Skip Navigation Link
		document.write( "<a href=\"#skipMH\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"Skip to main content\" border=\"0\" width=\"1\" height=\"1\" /></a>" );
				
		if( typeof( m_nothomelogo ) != "undefined" )
		{
			m_nothomelogo	= m_nothomelogo.replace ( "images/global/brand/ui/logo.gif" , "images/global/brand/ui/logo42.gif");
			
			if( logoLink )
			{
				document.write( "<a href=\"" + m_homelink + "\">" );
			}	
			
			document.write( "<img src=\"" + m_nothomelogo + "\" alt=\"\" align=\"absmiddle\" border=\"0\" width=\"123\" height=\"28\" />" );		
			
			if( logoLink )
			{
				document.write( "</a>" );
			}	
		}
		
		if(typeof(m_mhTheme) != "undefined")
		{
			if( m_mhTheme != null && m_mhTheme.length>0 )
			{
				document.write( "</td><td width=\"62%\" style=\"background-image: url(" + m_mhTheme + ");background-repeat: no-repeat;background-position:right;\">" );
			}
			else
			{
				document.write( "</td><td width=\"62%\">" );
			}
		}
		else
		{
			document.write( "</td><td width=\"62%\">" );
		}
		
		
		if( flag )
		{
			document.writeln( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td width=\"2\" nowrap=\"1\"><span class=\"mhTitle_SE\">" + m_ctryShort + "&nbsp;</span></td><td><img src=\"" + m_imgPfx + "/images/global/masthead/smlflags/" + flag + ".gif\" alt=\"" + m_ctryName + "\" border=\"0\" /></td></tr></table>" );
		}
		else
		{
			document.writeln( "<div class=\"mhTitle_SE\">" + m_ctryShort + "</div>" );
		}
		
		if( segmentTitle )
		{
			document.write( "<div  class=\"mhTitle_SE\">" );
			
			if( m_seglink )
			{
				document.write( "<a href=\"" + m_seglink + "\" class=\"mhTitleLink_SE\">" );
			}		
			
			document.write( segmentTitle );

			if( m_seglink )
			{
				document.write( "</a>" );
			}
						 
			document.write( "</div></td>" );
		}

		if( m_search )
		{
			document.write( "<td nowrap=\"1\" align=\"right\" valign=\"bottom\" width=\"100%\">" );
			document.write( m_search );
		}
		else
		{
			document.write( "<td style=\"padding-right:4px;\" align=\"right\" valign=\"middle\" width=\"100%\">" );
			renderSearchLinks();
		}

		document.write( "</td></tr>" );		
		
		// nav strip
		if( typeof(m_menuBar) != "undefined" && m_menuBar && m_menuBar.length > 0 )
		{			
		    document.write( "</table></td><td width=\"100%\"></td></tr>" );
	
			document.write("<tr class=\"mhpn\"><td>");		
			
			document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + screenWidth + "\" height=\"24\">" );
			
			if( m_menuBar.length < 4 )
			{
				document.write( "<tr class=\"mhpn\"><td align=\"right\">" );
				document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" height=\"24\"><tr>" );
				renderMenuStripSep();
			}
			else
			{	
				document.write( "<tr class=\"mhpn\"><td>" );
				document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + screenWidth + "\" height=\"24\"><tr>" );
			}
			
			renderMenuStrip();
		
			document.write( "</tr></table></td></tr></table></td>" );			
			document.write( "<td class=\"mhpn\" width=\"100%\"><div class=\"mhsep\" style=\"height:24px\"></div></td></tr>" );
					
		}
		else
		{
			document.write( "<tr class=\"mhLine\"><td colspan=\"5\"><img src=\"" );
			document.write( m_imgPfx );			
			document.write( "/images/global/general/spacer.gif\" alt=\"\" border=\"0\" height=\"1\" width=\"1\" /></td></tr></table></td><td class=\"mhLine\" width=\"100%\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\"  height=\"1\" width=\"1\" /></td></tr>" );
		}
	
	// breadcrumbs and subnav links	
	
	if( m_crumbs || m_pnlinks)
	{ 		
		var bcTwoLine = false;
		if( m_crumbs )
		{
			var bcWidth = breadCrumbsWidth( false );		
			bcWidth		= screenWidth - bcWidth;	
			
			//Display Subnav links if the screen width is greater or equal to 800X600 and personalization bar is not present
			
			if( (( !m_pbarEnabled ) && ( window.screen.width >= 800 )) || window.screen.width < 800 )
			{			
				var snWidth = subNavWidth();		 
				bcTwoLine	=( bcWidth + snWidth >= 715 )? true : false;				 
			}				
		}
		
		if( !bcTwoLine )
		{
			document.write( "<tr class=\"bcbg\"><td>" );
			document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + screenWidth + "\">" );
			document.write( "<tr>" );
			if( m_crumbs )
			{
				renderCrumbsNew( false );
			}
			if( m_pnlinks && m_subNavLinksDisplay &&  ( ( !m_pbarEnabled  &&  screen.width >= 800 ) ||  screen.width < 800 )  )
			{
				renderSubNavLinks();
			}
			 
			document.write( "</tr></table></td><td width=\"100%\"></td></tr>" );
		}
		else
		{	
			if( m_pnlinks && m_subNavLinksDisplay &&  ( ( !m_pbarEnabled  &&  screen.width >= 800 ) ||  screen.width < 800 )  )
			{
				document.write( "<tr class=\"bcbg\">" );
				renderSubNavLinks();
				document.write( "<td width=\"100%\"></td></tr>" );
			}
			
			document.write( "<tr class=\"mhLine\"><td colspan=\"2\" width=\"100%\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\"  height=\"1\" width=\"1\" /></td></tr>" );
			document.write( "<tr class=\"bcbgSplit\">" );
			renderCrumbsNew( false );
			document.write( "<td width=\"100%\"></td></tr>" );
		}
		
		document.write( "<tr class=\"mhLine\">" );		
		document.write( "<td width=\"" + screenWidth + "\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\"  height=\"1\" width=\"1\" /></td>" );
		document.write( "<td width=\"100%\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\"  height=\"1\" width=\"1\" /></td>" );
		document.write( "</tr>" );
	}		
	
	document.write("</table>");	
	document.writeln ( "<!-- end masthead -->" );
	
 	//document.write( "</xmp>" );
}

function renderSubNavLinks()
{	
	document.write("<td width=\"" + screenWidth + "\" height=\"10\" align=\"right\">");
	
	document.write( "<table class=\"bcbg\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" height=\"10\"><tr>" );
	
	for( var n = 0; n < m_pnlinks.length; n++ )
	{
		if( n > 0 )
		{
			document.write( "<td><img src=\"" + m_imgPfx + "/images/global/masthead/secondary_sep.gif\" alt=\"\"></td>" );
		}

		var href = m_pnlinks[n].Href;
		var icon = m_pnlinks[n].Icon;
		
		if( icon && m_subNavIconsDisplay )
		{				
			document.write( "<td valign=\"middle\"><a href=\"" + href + "\"><img src=\"" + m_imgPfx + "/images/global/brand/icons/" + icon + ".gif\" border=\"0\"  alt=\"\"></a></td>" );
		}		
		
		document.write( "<td align=\"right\" valign=\"middle\" nowrap=\"true\"><a class=\"lnk_crumb\" href=\"" + href + "\">" + m_pnlinks[n].Text + "</a></td>" );
		
	}
	document.write( "</tr></table>" );		
	document.write( "</td>" );
	  

}


function getBackto()
{
	if ( typeof ( m_backto ) != "undefined" )
	{
		return m_backto;
	}
	return "";
}
function getGotoTop ()
{
	if ( typeof ( m_gototop ) != "undefined" )
	{
		return m_gototop;
	}
	return "";
}
function getPrintableText ()
{
	if ( typeof ( m_printableText ) != "undefined" )
	{
		return m_printableText;
	}
	return "";
}
function renderCrumbsNew( forFooter )
{
		document.write( "<td nowrap=\"1\" valign=\"middle\" height=\"20\" class=\"para_crumb_SE\">" + getBackto() + ":&nbsp;" );
		var totalw = 700 - ( getBackto().length * m_avgChW );
		 
		if( forFooter )
		{
			if( m_printLink )
			{
				totalw -= 20 + ( getPrintableText().length * m_avgChW );
			}
			
			if( m_emailLink )
			{
				totalw -= 20 + ( m_emailText.length * m_avgChW );
			}
			
			if( m_helpLink )
			{
				totalw -= 20 + ( m_helpText.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_crumb\" 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_crumb\" 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>" );
		
		if( forFooter )
		{
			renderPrintEmailLinks();
		}
}


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
	{
		if( m_largeFont )
		{
			return text.length * 8;
		}
		else
		{
			return text.length * 6;
		}		
	}
}
function subNavWidth()
{
	var navWidth = 0;
	if( m_pnlinks)
	{   		
		for( var n = 0; n < m_pnlinks.length; n++ )
			{
				if( n > 0 )
				{
					//separator
					navWidth = navWidth + 23;
				}
				
				var icon = m_pnlinks[n].Icon;
				
				if( icon && m_subNavIconsDisplay )
				{
					 navWidth = navWidth + 24;					
				}	
					
				navWidth = navWidth + crumbWidth( m_pnlinks[n].Text) ;					
				
				if( m_largeFont)
				{
					navWidth = navWidth + 7;
				}
												
			}
			
	}
	
	return navWidth;

}
function breadCrumbsWidth(forFooter)
{	
	var totalw = 700 - ( getBackto().length * m_avgChW ); 	

		for( var n = 0; n < 2; n++ )
		{
			if( n >= m_crumbs.length )
			{
				break;
			}
			
			if( n > 0 )
			{				
				totalw -= 16;
			}	
			
			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;
			}			
		}		
		
	return totalw;		
	
}


function renderPrintEmailLinks()
{  
	if( m_printLink || m_emailLink || m_helpLink )
	{
		//document.write( "<td bgcolor=\"#f5f5f5\" align=\"right\" valign=\"middle\">" );
		// added the padding to match the MDA (John Tipton)
		document.write( "<td align=\"right\" valign=\"middle\" style=\"padding-top:4px;\">" );

		document.write( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>" );

		if( m_emailLink )
		{
			var m_emailsubject = document.title;
			if( typeof(m_emailSubject) != "undefined" && m_emailSubject != null && m_emailSubject.length > 0 )
			{
				m_emailsubject = m_emailSubject;
			}
			
			var emailUrl = "javascript:void(document.location.href=" + "'mailto:?subject=" + m_emailsubject + "&body=" +  document.location.href.replace(/%26/g,'%2526').replace(/&/g,'%2526') + "')" ;

			document.write( "<td valign=\"middle\"><a href=\"" + emailUrl + "\"><img src=\"" + m_imgPfx + "/images/global/brand/icons/email.gif\" border=\"0\" alt=\"" + m_emailText + "\" /></a></td>" );
			document.write( "<td align=\"right\" valign=\"middle\" nowrap=\"1\" class=\"para_small\"><a class=\"lnk_small\" href=\"" + emailUrl + "\">" + m_emailText + "</a></td>" );
		}			

		if( m_printLink )
		{
			if( m_emailLink )
			{
				document.write( "<td><div class=\"mhSpace\">|</div></td>" );				
			}

			document.write( "<td valign=\"middle\"><a href=\"" + m_printLink + "\"><img src=\"" + m_imgPfx + "/images/global/brand/icons/print.gif\" border=\"0\" alt=\"" + getPrintableText() + "\" /></a></td>" );
			document.write( "<td align=\"right\" valign=\"middle\" nowrap=\"1\" class=\"para_small\"><a class=\"lnk_small\" href=\"" + m_printLink + "\">" + getPrintableText() + "</a></td>" );
		}			

		if( m_helpLink )
		{
			if( m_emailLink )
			{
				document.write( "<td><div class=\"mhSpace\">|</div></td>" );
			}

			document.write( "<td valign=\"middle\"><a href=\"" + m_helpLink + "\"><img src=\"" + m_imgPfx + "/images/global/brand/icons/help.gif\" border=\"0\" alt=\"" + m_helpText + "\" /></a></td>" );
			document.write( "<td align=\"right\" valign=\"middle\" nowrap=\"1\" class=\"para_small\"><a class=\"lnk_small\" href=\"" + m_helpLink + "\">" + m_helpText + "</a></td>" );
		}			
		
		document.write( "<td style=\"padding-right:10px;\"></td></tr></table></td>" );
		
	}

}

function renderSearchLinks()
{
	if( m_searchLinks )
	{
		document.write( "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr>" );
		
		for( var n = 0; n < m_searchLinks.length; n++ )
		{
			if( n > 0 )
			{
				document.write( "<td nowrap=\"1\" class=\"mh_search_sep_SE\"><div class=\"mhSpace\">|</div></td>" );
			
			}
			
			var href = m_searchLinks[n].Href;
			var text = m_searchLinks[n].Text;
		
			document.write( "<td valign=\"middle\" nowrap=\"1\"><a href=\"" + href + "\" class=\"para_small\">" + text + "</a></td>" );
		}
		
		document.write( "</tr></table>" );
		
	}
	
}

function mhFixupLink( href, extra )
{
	if( typeof(extra) == "undefined" )
	{
		extra = "&~ck=mn";
	}
	
	if( href )
	{
		var anchor		= null;
		var anchorix	= href.indexOf( "#" );
		
		if( anchorix != -1 )
		{
			anchor		= href.substr( anchorix );
			href		= href.substr( 0, anchorix );
		}
		
		if( href.indexOf( "?" ) == -1 )
		{
			extra = "?" + extra.substr( 1 );
		}

		if( href.toLowerCase().indexOf( "javascript:" ) == -1 )
		{
			href += extra;
		}
		else
		{
			start = href.indexOf( "?" );
			
			if( start != -1 )
			{
				ix = href.indexOf( "\'", start );
				
				if( ix == -1 )
				{
					ix = href.indexOf( "\\", start );

					if( ix == -1 )
					{
						ix = href.indexOf( "\"", start );
					}
				}
				
				if( ix != -1 )
				{
					href = href.substr( 0, ix ) + extra + href.substr( ix );
				}
			}
		}
		
		if( anchor )
		{
			href += anchor;
		}
	}
	
	return href;
}

function mhLink( text, href, icon, extra )
{
	href = mhFixupLink( href, extra );

	this.Text			= text;
	this.Href			= href;
	this.Icon			= icon;
}

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" );
}

// -------------------------------------------------------------
// client-side footer
// -------------------------------------------------------------

function writeFooterLine()
{
	document.writeln( "<tr><td class=\"mhLine\" height=\"1\" width=\"1\"></td></tr>" );
}

function writeFooterStart()
{	
	var width = ( m_mhFixed ? "728" : "100%" );
	document.write( "<table width=\"" + width + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ededed\">" );
	document.write( "<tr><td bgcolor=\"white\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" border=\"0\" height=\"8\" width=\"1\" alt=\"\" /></td></tr>" );
	
	if( typeof(m_pageTheme) != "undefined" )
	{
		if( m_pageTheme != null && m_pageTheme.length > 0 )
		{
			document.write( "<tr><td bgcolor=\"white\"><img src=\"" )
			document.write( m_pageTheme );
			document.write(	"\" border=\"0\" alt=\"\" /></td></tr>" );
		}
	}
	
	if( m_crumbs ) 
	{
		writeFooterLine();
		document.write("<tr><td><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + screenWidth + "\"><tr class=\"bcbgSplit\">");
		renderCrumbsNew( true );
		document.write("</tr></td></table></tr>");
	}
	
	document.write( "</table>" );
}

function writeFooterMid()
{
	var width	= ( m_mhFixed ? "728" : "100%" );
	var sepCol	= "#cccccc";
	
	if( m_crumbs )
	{
		sepCol = "#999999";
	}
	
	document.write( "<table width=\"" + width + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ededed\">" );
	document.write( "<tr><td colspan=\"2\" bgcolor=\"" + sepCol + "\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" /></td></tr>" );
	document.write( "<tr><td colspan=\"2\" ><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" border=\"0\" height=\"5\" width=\"1\" alt=\"\" /></td></tr><tr><td width=\"" + width + "\" align=\"center\" valign=\"top\">" );
}

function writeFooterBegin()
{
	writeFooterStart();
	writeFooterMid();
}

function writeFooterClose()
{
	document.write( "</td><td><table><tr><td valign=\"middle\"><a href=\"#mastheadtop\"><img src=\"" + m_imgPfx + "/images/global/brand/ui/arrow_top.gif\" alt=\"\" border=\"0\"></a></td><td style=\"padding-right:6px;\" valign=\"middle\"><a href=\"#mastheadtop\"><span class=\"para\">" + getGotoTop() + "</span></a></td></tr></table></td></tr><TR><td colspan=\"2\" ><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\" height=\"5\" width=\"1\" /></td></tr><TR><td colspan=\"2\" bgcolor=\"#cdcdcd\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\" height=\"1\" width=\"1\" /></td></tr></table>" );
	//Fix for Storm 4.2 100% width
	document.write ( "</td></tr></table>" );
}

function StripCookieValue ( inVal , removeVal )
{
	if ( !inVal || inVal.length == 0 || !removeVal || removeVal.length == 0 )
	{
		return inVal;
	}
	var idx			= 0;
	var ampIdx		= 0;
	var semiIdx		= 0;
	var len			= 0;
	var repString	= "";
	idx				= inVal.indexOf ( removeVal );
	
	if ( idx > - 1)
	{
		
		ampIdx		= inVal.indexOf (  "&" , idx );
		semiIdx		= inVal.indexOf (  ";" , idx);
		len			= ampIdx ;
		
		
		if ( len == -1 )
		{
			len		= semiIdx; 
		}
		else if ( semiIdx != -1 && semiIdx < len )
		{
			len		= semiIdx;
		}
		
		
		if ( len > -1 )
		{
			
			repString	= inVal.substring( idx , len  );
		}
		else
		{
			repString	= inVal.substr( idx );
		}
		
		
		return inVal.replace (  repString , "" ).replace("&&" , "&" ) ;
		
	}
	return inVal;
}
function RemoveName()
{
	
	var cookie		= getCookie ( "StormPCookie" )
	
	
	if ( cookie && cookie.length > 0 )
	{
		cookie= StripCookieValue( cookie , "fstn" );
		cookie	= StripCookieValue( cookie , "lstn");
		document.cookie	= "StormPCookie=" + cookie  + ";domain=.shiplaser.com";
		
	}
	
	cookie			= getCookie ( "lwp" );
	if ( cookie && cookie.length > 0 )
	{
	
		cookie = StripCookieValue( cookie , "fstn" );
		cookie	= StripCookieValue( cookie , "lstn");
		cookie	= StripCookieValue ( cookie , "fn" );
		document.cookie	= "lwp=" + cookie+ ";domain=.shiplaser.com";
		
	}
}

function Bandwidth()
{
	if( readIEVer() < 5.0 || isOpera || navigator.appVersion.toLowerCase().indexOf("win") == -1 )
	{
		return "NA";
	}
	
	document.body.addBehavior ("#default#clientCaps");
	
	if ( typeof( document.body.connectionType) != "undefined"  ) 
	{
		if ( document.body.connectionType == "modem" )
		{
			return "Modem";
		}
		return "Lan";
	}

}

function FlashLibrary(){
	var t = this;
	var activeX = false;
	t.ieAutoInstall = true;
	t.hasVersion = function(ver){
		t.swf = false;
		if(!ver) ver = 0;
		var n = navigator;
		if(n.plugins && n.plugins.length > 0){
			var m,tp,d,v;
			m = n.mimeTypes;
			tp = 'application/x-shockwave-flash';
			if(m && m[tp] && m[tp].enabledPlugin && m[tp].enabledPlugin.description){
				d = m[tp].enabledPlugin.description;
				v = d.charAt(d.indexOf('.')-1);
				t.swf = (v >= ver) ? true : false;
			}
		}else if(n.appVersion.indexOf("Mac") == -1 && window.execScript){
			for(var i=ver; i<=7&&i!=1&&t.swf!=true; i++){
				execScript('on error resume next: flash.swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');
			}
			activeX = true;
		}else{
			t.swf = false;
		}
		return t.swf;
	}
	t.getPluginTag = function(swfFile,width,height,bgcolor,ver,altFormat,params){
		
		var s = '';
		var win = (navigator.appVersion.toLowerCase().indexOf("win")!=-1);
		var ie = (navigator.appName=="Microsoft Internet Explorer");
		if(t.hasVersion(ver) && swfFile || win && ie && swfFile && t.ieAutoInstall){
			var additionalParams = '';
			
			var		qPos	= swfFile.indexOf ( "?" )		
	
			if ( qPos > -1 && qPos + 1 < swfFile.length && ver == 6 )
			{
				var	ta			= 'FlashVars';
				var v 			= swfFile.substring ( qPos + 1 );
				swfFile			= swfFile.substring ( 0 , qPos );
				additionalParams += (activeX)?'\t<param name="' + ta + '" value="' + v + '" />\n': ' '+ ta + '="' + v + '"';
			}
			
			if(activeX){
				s = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,21,0" width="'+width+'" height="'+height+'">\n';
				s += '\t<param name="movie" value="'+swfFile+'" />\n';
				s += '\t<param name="quality" value="high" />\n';
				s += '\t<param name="menu" value="false" />\n';
				s += '\t<param name="wmode" value="opaque" />\n';
				s += '\t<param name="bgcolor" value="'+bgcolor+'" />\n';
				s += additionalParams;
				s += altFormat;
				s += '</object>\n\n';
				return s;
			}else{
				s = '<embed src="'+swfFile+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'"'+additionalParams+'></embed>\n';
				return s;
			}
		}else{
			return altFormat;
		}
	}
}

function fixupFragHeight()
{
	var tags = getObjectsByTag("tr");
	
	for( var i = 0; i < tags.length; i++ )
	{
		var tr = tags[i];
		var className = tr.className;
		
		if( className == "rowsolid" || className == "rowlight" )
		{
			var h = getObjectHeight( tr );
			
			if( h > 29 )
			{
				tr.className = className + "2";
			}
		}
	}
}

function ResizePBarFrame ( )
{
	if ( ! isW3C ) 
	{
		return;
	}
	
	var iframeObj					= null;
	var height						= 0;
	try
	{
		iframeObj						= document.getElementById ( "pbarwin" );
		if ( iframeObj == null )
		{
			var	iframes					= document.getElementsByTagName("iframe" );
			if ( iframes.length > 0 )
			{
				iframeObj				= iframes[0];
			}
		}
	}
	catch(e)
	{
	}
	
	if ( iframeObj != null )
	{
		var pbarColumn = parent.document.getElementById ( "pbarTableColumn" );
		if ( pbarColumn != null )
		{
			height = pbarColumn.offsetHeight;
		}
		
		if ( height > 20 && height > iframeObj.height )
		{
			iframeObj.height = height;
		}
	}
}

// -------------------------------------------------------------
// end of common.js
// -------------------------------------------------------------
