
var m_pnlinks;
var m_mhFixed				    = false;
var m_mda					    = 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_supressSubNav			    = false;
var m_stdEmpty		            = "";
var m_stdOffImg;
var m_pageTab                   = null;
var m_activeTab                 = null;
var m_mastheadWidth             = 728;
var m_defaultTabs               = false;
var m_tabNav                    = false; 
var m_buyonlineMessage          = null;
var m_subNavLinkWidth           = null;
var m_phoneTitle                = null;
var m_phoneMsg                  = null;
var m_phoneTariff               = null;
var m_tabContentDiv             = null;
var m_timeoutDelay              = null;
var Screen                      = new GetScreen();
var loaded                      = new Array();
var onloadFired                 = false;




function writeMH( phoneTitle, phoneMsg, phoneTariff, segmentTitle, hasLocale, logoLink, pnmsg )
{   
    m_phoneTitle            = phoneTitle;
    m_phoneMsg              = phoneMsg;
    m_phoneTariff           = phoneTariff;
    document.writeln ( "<!-- begin masthead -->" );
    //country homepage will have mastheadwidth of 728
    m_mastheadWidth         = 520;
    m_defaultTabs           = m_pageTab == "Auto" ? true : false;
    
	// Off Dell (external link) Icon
	m_stdOffImg             = "<img src=\"" + m_imgPfx + "/images/global/brand/icons/smextlink.gif\", width=\"16\" height=\"9\" border=\"0\"/>";

	//Browser Compatibility Tests
	autoconfig();	

    // If there is a m_suppressPrintLink, then the 'printlink' link should not be displayed in the footer
    if ( typeof(m_suppressPrintLink) != "undefined" )
    {
        m_printLink    = null;
    }
    
	// Menu Definition Error
	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;
	}	
    
	if( m_largeFont )
	{
		m_avgChW = m_avgChW + 2;	
	}
	
	// If it is normal layout the width of the footer will be '728' else if it is popup or print layout, footer width will be 100%.
	m_mhFixed	= true;
    
    document.writeln( "<a name=\"mastheadtop\"></a>" );	
	// Masthead container	
	document.write( "<table id=\"masthead\" width=\"" + m_mastheadWidth + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">" );	
   	document.write( "<tr><td valign=\"bottom\" rowspan=\"2\">" );	    
    
    // Logo    
    document.write( "<div class=\"logocontainer\" id=\"logocontainer\">" );
    
    // 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>" );
    // Mahesha : This is for the applications who uses prior to storm 4.2 dll's.  In vid.xdb file, the logo is set to logo.jpg
    // If we change the image ref in vid.xdb file, it will affect the applications which are not using
    // storm 4.2 or storm 4.3 dlls. If everybody moves to storm 4.2/4.3, then this can be removed.
    if( typeof( m_nothomelogo ) != "undefined" )
	{
		m_nothomelogo	= m_nothomelogo.replace ( "/images/global/brand/ui/logo.gif" , "/images/global/brand/ui/logo43.gif");
        
		if( logoLink )
		{
			document.write( "<a class=\"logolink\" href=\"" + m_homelink + "\">" );
		}
		
        document.write( "<img class=\"logo\" src=\"" + m_nothomelogo + "\" border=\"0\"  width=\"109\" height=\"41\" alt=\"\" />" );		
	
		if( logoLink )
		{
			document.write( "</a>" );
		}	
	}
	document.write( "</div></td><td valign=\"top\" " + ((typeof(m_menuBar) != "undefined" && m_menuBar && m_menuBar.length > 0) ? "colspan=\"2\"" : "") + "><table id=\"pbarstriptable\" width=\"" + (m_mastheadWidth - 109) + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td>" );	
    //Phone Message
    if( m_buyonlineMessage )
	{
	    document.write( "<div class=\"mhTitle_SE\">" );
	    document.write( m_buyonlineMessage );
	    document.write( "</div>" );
	}
	else
	{
	    renderBuyOnline();
    }
	
	document.write( "</td><td><div style=\"height:20px;\" /></td><td nowrap=\"true\" valign=\"top\">" );
	var ticks = new Date();                
    
    // Language Selector
	// Render languague toggle If the secondary nav bar is not present, otherwise langugage toggler will be duplicate
    if( !( m_pnlinks && m_subNavLinksDisplay &&  ( !m_supressSubNav ) ) && ( typeof( m_langSelectorUrl ) != "undefined") )
    {
        document.write( "<div class=\"lang_selector\">" );
        renderLanguageToggle();
        document.write( "</div>" );
    }
        
    document.write( "</td></tr></table></td></tr><tr>" );
    
    // Render Primary Tabs
    if( typeof(m_menuBar) != "undefined" && m_menuBar && m_menuBar.length > 0 )
	{	
	    document.write( "<td valign=\"bottom\">" );
	    // Determine Selected Tab
	    if( !isNaN( parseInt( m_pageTab ) ) )
        {
            m_pageTab = parseInt( m_pageTab );
        }
        else
        {
            var noTab = true;
            for( n = 0; n < m_menuBar.length; n++ )
            {
                if( m_pageTab == m_menuBar[n].Text )
                {
                   m_pageTab = n;
                   noTab = false;
                }
            }
            if( m_pageTab == "Auto" )
            {
                var qTab = getQueryVariable( "~tid" );
                if( typeof(qTab) != "undefined" && !isNaN( parseInt( qTab ) ) && qTab < m_menuBar.length )
                {
                    m_pageTab = qTab;
                    noTab = false;
                }
            }
            if( noTab )
            {
                m_pageTab = 0;
            }
        }
        for( n = 0; n < m_menuBar.length; n++ )
        {
            if( m_menuBar[n].IsSelectedTab )
            {
                m_pageTab   = n;
            }
        }
        document.write( "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr>" );
    	renderPrimaryTabStrip();
    	document.write( "<td width=\"100%\"><div class=\"tabspacer\" /></td>" );		
        document.write( "</tr></table></td>" );
    }
    
    document.write( "<td>" );
	
	// Search
	if ( typeof( m_supressSearch ) == "undefined" || m_supressSearch == false )
    {
        document.write( "<div class=\"searchcontainer\" id=\"searchcontainer\">")
	    if( m_search )
	    {		
		    document.write( m_search );
        }
	    else
	    {		
		    renderSearchLinks();
	    }
	    document.write( "</div>" );
	}
		
	document.write( "</td></tr><tr><td colspan=\"3\">" );
    
    // Render Secondary Tabs	
	var noNav   = "<div class=\"subnavcontainernomenu\" id=\"subnav\" ><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" border=\"0\" alt=\"\" height=\"5\" width=\"1\" /></div>";
	if( typeof(m_menuBar) != "undefined" && m_menuBar && m_menuBar.length > 0 )
	{
	    if( typeof(m_menuBar[m_pageTab]) != "undefined" && m_menuBar[m_pageTab].MenuItems.length > 0 && !m_tabNav )
	    {
	        document.write( "<div class=\"subnavcontainer\" id=\"subnav\">" );
	        document.write( renderSecondaryTabStrip( m_menuBar[m_pageTab] ) );
	        document.write( "</div>" );
	    }
	    else
	    {
	        document.write( noNav );
	    }
	}
	else
	{
	    document.write( noNav );
	}	
	
	// Render Sub Navigation Link
	if( m_pnlinks && m_subNavLinksDisplay &&  (!m_supressSubNav)  )
	{
		document.write( "<div class=\"secondarynavcontainer\">" );
		renderSubNavLinks();
		document.write( "</div>" );
	}		
	
    // Render MDA Strip
    if( m_mda )
	{
	    document.write( "<div class=\"mdabarcontainer\" id=\"mdabar\">" );
        document.write( "<span class=\"mdainfo\">" );
        document.write( m_mda );
        document.write( "</span>" );        
        document.write( "</div>" );
    }
    // Render Masthead Bread Crumbs    
    //Chk whether home    
    document.write( "<div class=\"breadcrumbcontainer\">" );
    renderHomepageCrumbs();
    document.write( "</div>" ); 
   
	document.write ( "</td></tr></table>" );
	document.write ( "<a name=\"skipMH\"></a>" );
	document.writeln ( "<!-- end masthead -->" );
}

function renderBuyOnline()
{
    if( m_phoneTitle || m_phoneMsg )
    {	
	    document.write( "<div class=\"message_buyonline\">" );	
	    if( m_phoneTitle )
	    {
		    document.write( m_phoneTitle );
		    document.write( " " );
	    }
	    if( m_phoneMsg )
	    {
		    document.write( m_phoneMsg );
	    }
	    if( m_phoneTariff )
        {   
            document.write( "<span class=\"mhTextNewTrf\">" + m_phoneTariff + "</span>" );
        }
        document.write( "</div>" );	
	}
}
// -------------------------------------------------------------
// End Render Masthead
// -------------------------------------------------------------

// -------------------------------------------------------------
// cross-browser helper functions
// -------------------------------------------------------------

// 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	m_anchorClicked = false;

// Add a BookMark
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 );
        
        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;
			}
        }
    
    } 
    
}


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 ) );
}

// ----------------------------------------------------
// End Browser Sniffer Content
// ----------------------------------------------------

// -------------------------------------------------------------
// Start Render Tab Strip
// -------------------------------------------------------------
function renderPrimaryTabStrip()
{
	var menuHeaderID;

    // Make sure everything loads for IE
	if( isIE6 )
	{
		bodyTag.style.behavior	= "url(#default#clientCaps)";
		m_colorDepth			= bodyTag.colorDepth;
	}
	
	var cssPrefix               = "inactivetab";
	
	for( n = 0; n < m_menuBar.length; n++ )
	{
	    if( n == m_pageTab )
		{
		    cssPrefix = "activetab";
		}
		
		// Tab Links
		if( ( m_menuBar[n].Href != null && m_menuBar[n].Href.length > 0 ) || m_tabNav )
		{		    
		    document.write( "<td>" );
		    if( !m_tabNav )
		    {
		        document.write( "<div onclick=\"SwapTab( this, '" + createNavLink( m_menuBar[n].Href, n ) + "' )\" class=\"" + cssPrefix + "\" id=\"" + m_menuBar[n].Id + "\" name=\"mh_tabselector\">" );
            }
            else
            {
                document.write( "<div onclick=\"SwapTab( this, '" + createNavLink( m_menuBar[n].Href, n ) + "' )\" onmouseover=\"TabNavActiveEvent( this )\" onmouseout=\"TabNavInActiveEvent( this )\" class=\"" + cssPrefix + "\" id=\"" + m_menuBar[n].Id + "\" name=\"mh_tabselector\">" );
            }
            document.write( "<div id=\"" + m_menuBar[n].Id + "left\" class=\"" + cssPrefix + "left\"></div>" ); 
        	document.write( "<div class=\"" + cssPrefix + "content\" id=\"" + m_menuBar[n].Id + "content\" align=\"center\" nowrap=\"1\">" );
			document.write( m_menuBar[n].Text );
			document.write( "</div>" );
			if( m_tabNav )
			{
			    document.write( "<div id=\"" + m_menuBar[n].Id + "TabNav\" class=\"floatingmenu\">" );
			    document.write( "<ul class=\"mh_linklist\">" );
                var sep             = "sub";
                var item            = m_menuBar[n];
                for( var nn = 0; nn < item.MenuItems.length; nn++ )
                {
                    var	drop = item.MenuItems[nn];
            	    if( drop.Text != null )
                    {
                        document.write( "<li class=\"" + sep + "\" onMouseOver=\"this.className='" + sep + "hover';\" onMouseOut=\"this.className='" + sep + "';\"><a class=\"menulink\" href=\"" + createNavLink( drop.Href, n ) + "\" " + drop.TargetHtml + ">" + drop.Text );
            		    if( drop.OffDell )
                        {
                            document.write( m_stdOffImg );
                        }
                        document.write( "</a></li>" );
                    }
                    sep  =  drop.IsSeparator ? "sep" : "sub";
                }
                document.write( "</ul></div>" );
			}
			document.write( "</div>" );
			document.write( "</td>" );
	    }
		else
		{
		    document.write( "<td><div onclick=\"swapSecondaryTabStrip('" + m_menuBar[n].Id + "','" + n + "')\" class=\"" + cssPrefix + "\" id=\"" + m_menuBar[n].Id + "\" name=\"mh_tabselector2\">" );
            document.write( "<div id=\"" + m_menuBar[n].Id + "left\" class=\"" + cssPrefix + "left\"></div>" ); 
        	document.write( "<div class=\"" + cssPrefix + "content\" id=\"" + m_menuBar[n].Id + "content\" align=\"center\" style=\"cursor:pointer\" nowrap=\"1\">" );
			document.write( m_menuBar[n].Text );
			document.write( "</div></div></td>" );
		}
        
		if( n == m_pageTab )
		{
		    m_activeTab = getRawObject( m_menuBar[n].Id );
		}
		cssPrefix               = "inactivetab";
	}

}

function createNavLink( url, tab )
{
    var link    = null;
    if( url != null )
    {
        if( m_defaultTabs )
        {
            if( url.indexOf( "?" ) > 0 )
            {
                link = url + "&~tid=" + tab;
            }   
            else
            {
                link = url + "?~tid=" + tab;
            }      
        }
        else
        {
            link = url;
        }
    }
    return link;
}
// -------------------------------------------------------------
// End Render Tab Strip
// -------------------------------------------------------------

// -------------------------------------------------------------
// Start Render Search Links
// -------------------------------------------------------------
function renderSearchLinks()
{
	if( m_searchLinks )
	{
		for( var n = 0; n < m_searchLinks.length; n++ )
		{
			if( n > 0 )
			{
				document.write( "<span class=\"mhSpace\">|</span>" );
			}
			
			var href = m_searchLinks[n].Href;
			var text = m_searchLinks[n].Text;
		
			document.write( "<span class=\"mh_search_sep_SE\" style=\"white-space:nowrap\"><a href=\"" + href + "\" class=\"para_small\">" + text + "</a></span>" );
		}
	}
}

// -------------------------------------------------------------
// End Render Search Links
// -------------------------------------------------------------

// ---------------------------------------------------
// Start Render Secondary Tabs
// ---------------------------------------------------
function swapSecondaryTabStrip( src, id )
{
    subNavContent       = getRawObject( "subnav" );
    menu                = m_menuBar[ id ];
    SwapTab( getRawObject( src ), null );
    subNavContent.innerHTML = renderSecondaryTabStrip( menu );
	BindEvents();
}

function renderSecondaryTabStrip( menu )
{   
    var sep             = "sub";
    var subNavHTML      = "";
    for( var n = 0; n < menu.MenuItems.length; n++ )
	{
	    var	item = menu.MenuItems[n];
        
        if( item.Text != null )
        {
            if( isDHTML )
		    {
		        if( item.MenuItems )
	            {
	                subNavHTML += "<div id=\"mh_" + item.Id + n + "\" name=\"mh_subnavlink\" class=\"subnavlinkcontainer\">" + 
	                "<a href=\"" + createNavLink( item.Href, n ) + "\" " + item.TargetHTML + " id=\"mh_" + item.Id + n + "link\" class=\"subnavlink\">" + item.Text + "</a>" +
	                "<div id=\"mh_" + item.Id + n + "content\" style=\"width:250px;\" class=\"floatingmenu\">" +
	                "<ul class=\"mh_linklist\">";
	                for( var nn = 0; nn < item.MenuItems.length; nn++ )
                    {
	                    var	drop = item.MenuItems[nn];
                	    
                        if( drop.Text != null )
                        {
                            subNavHTML += "<li class=\"" + sep + "\" onMouseOver=\"this.className='" + sep + "hover';\" onMouseOut=\"this.className='" + sep + "';\"><a class=\"menulink\" href=\"" + createNavLink( drop.Href, n ) + "\" " + drop.TargetHtml + ">" + drop.Text;
                		    
	                        if( drop.OffDell )
	                        {
	                            subNavHTML += m_stdOffImg;
	                        }
	                        subNavHTML += "</a></li>";
                        }
                        sep  =  drop.IsSeparator ? "sep" : "sub";
                    }
                    subNavHTML += "</ul></div></div>";
                }
                else
                {
                    subNavHTML += "<div id=\"mh_" + item.Id + n + "\" name=\"mh_subnavlink\" class=\"subnavlinkcontainernomenu\">" +
	                "<a href=\"" + createNavLink( item.Href, n ) + "\" " + item.TargetHTML + " id=\"mh_" + item.Id + n + "link\" class=\"subnavlinknomenu\">" + item.Text + "</a>" +
	                "</div>";
	            }
	        }
	        else
		    {
		        subNavHTML += "<div class=\"subnavlinkcontainernomenu\">" +
	            "<a href=\"" + createNavLink( item.Href, n ) + "\" " + item.TargetHTML + " class=\"subnavlinknomenu\">" + item.Text + "</a>" +
	            "</div>";
            }
        }
	}
    return subNavHTML;	
}
// ---------------------------------------------------
// End Render Secondary Tabs
// ---------------------------------------------------

// ---------------------------------------------------
// Start Bind Secondary Tabs
// ---------------------------------------------------
window.onload = function()
{
	BindEvents();
}

function BindEvents()
{
    if( !m_tabNav )
    {
	    var subnavlinks = ParseDivObjects( "mh_subnavlink" );
	    var subnavlink;
    	
	    for( var subnavidx = 0; subnavidx < subnavlinks.length; subnavidx++ )
	    {
		    subnavlink = subnavlinks[subnavidx];
		    subnavlink.onmouseover = function() { SubNavEventActive( this ); }
		    subnavlink.onmouseout = function() { SubNavEventInActive( this ); }
	    }
    }
}

//-- Parse the objects by name in a browser independent way
function ParseDivObjects( targetName )
{
	var objs = document.getElementsByName( targetName );
	
	//-- Workaround for "inconsistent" W3C ruleset in IE as DIV's aren't mapped with name properties
	if( objs.length == 0 )
	{
		var targets = document.getElementsByTagName( "DIV" );
		var tmpObj;
		
		objs = new Array();
		
		for( var targetidx = 0; targetidx < targets.length; targetidx++ )
		{
			tmpObj = targets[targetidx];
			
			if( tmpObj.name == targetName )
			{
				objs.push( tmpObj );
			}
		}
	}
	return objs;
}

function SwapTab( src, url )
{
    if ( m_activeTab != null )
    {
        m_activeTab.className = "inactivetab";
        getRawObject( m_activeTab.id + "left" ).className = "inactivetableft";
        getRawObject( m_activeTab.id + "content" ).className = "inactivetabcontent";
    }
    
    src.className = "activetab";
    getRawObject( src.id + "left" ).className = "activetableft";
    getRawObject( src.id + "content" ).className = "activetabcontent";

    m_activeTab = src;
    
    if( url != null )
    {
        document.location = url;    
    }
}

function TabNavActiveEvent( src )
{
    if( m_timeoutDelay )
    {
        ClearSubNavTimeOut(false);
    }
	if( m_tabContentDiv != src.id )
    {
        var content = getRawObject( src.id + "TabNav" );
        if( content != null )
	    {
            if( m_tabContentDiv != null )
            {
                TabNavInActiveClose();
            }
            m_tabContentDiv = src.id;
	        if ( m_activeTab.id != src.id )
            {
                src.className = "activetabhover";
                getRawObject( src.id + "left" ).className = "activetabhoverleft";
                getRawObject( src.id + "content" ).className = "activetabhovercontent";
                if( m_activeTab != null )
                {
                    m_activeTab.style.zIndex    = 1;
                }
           }
	       content.style.display = "block";
	    }
	}
}

function TabNavInActiveEvent( src )
{
    if( !m_timeoutDelay )
    {
        m_timeoutDelay = setTimeout( "TabNavInActiveClose()",500 );
    }
}

function TabNavInActiveClose()
{
    var src     = getRawObject( m_tabContentDiv );
    var content = getRawObject( m_tabContentDiv + "TabNav" );

	if( content != null && m_tabContentDiv )
	{
        if ( m_activeTab.id != m_tabContentDiv )
        {
            src.className = "inactivetab";
            getRawObject( src.id + "left" ).className = "inactivetableft";
            getRawObject( src.id + "content" ).className = "inactivetabcontent";
	        if( m_activeTab != null )
	        {
	            m_activeTab.style.zIndex    = 2;
	        }
	    }
	    content.style.display = "none";
	    m_tabContentDiv = null;
	}
}

function ClearSubNavTimeOut()
{
    clearTimeout( m_timeoutDelay );
    m_timeoutDelay = null;
}


function SubNavEventActive( src )
{
    var link = getRawObject( src.id + "link" );
	var content = getRawObject( src.id + "content" );
	if( m_timeoutDelay )
    {
        ClearSubNavTimeOut();
    }
    
    if( m_tabContentDiv != src.id )
    {
        if( m_tabContentDiv != null )
        {
            SubNavEventInActiveClose();
        }
        m_tabContentDiv    = src.id;
        if( src.id.indexOf( "undefined" ) > -1 )
	    {
            src.className = "subnavlinkcontainernomenuselected";
	    }
	    else
	    {
            src.className = "subnavlinkcontainerselected";
	    }

        if( link != null )
        {
            if( src.id.indexOf( "undefined" ) > -1 )
	        {
	            link.className = "subnavlinknomenuselected";
	        }
	        else
	        {
	            link.className = "subnavlinkselected";
	        }
        }

        if( content != null )
        {
            // expand left or right depending on screen resolution
            if( Screen.AvailableWidth < (src.offsetLeft + (content.style.width.substring(0,3) - 1 ) + 1) || m_mastheadWidth < (src.offsetLeft + (content.style.width.substring(0,3) - 1 ) + 1) )
            {
                content.style.left  = src.offsetLeft - content.style.width.substring(0,3) - 1 + src.offsetWidth;
            }
            else
            {
                content.style.left = src.offsetLeft + "px";
            }
	        content.style.top = src.offsetTop + src.offsetHeight - 3 + "px";		
	        content.style.display = "block";
        }
    }
}


function SubNavEventInActive( src )
{
    if( !m_timeoutDelay )
    {
        m_timeoutDelay = setTimeout( "SubNavEventInActiveClose()",500 );
    }
}

function SubNavEventInActiveClose()
{   
    if( m_tabContentDiv )
    {
	    var src = getRawObject( m_tabContentDiv );
        if( src )
        {
            var link = getRawObject( m_tabContentDiv + "link" );
	        var content = getRawObject( m_tabContentDiv + "content" );
        	
	        if( src.className == "subnavlinkcontainerselected" )
            {
                src.className = "subnavlinkcontainer";
	        }
            else
            {
                src.className = "subnavlinkcontainernomenu";
	        }
        	
	        if( link != null )
	        {
	            if( link.className == "subnavlinkselected" )
	            {
		            link.className = "subnavlink";
		        }
		        else
		        {
		            link.className = "subnavlinknomenu";
		        }
	        }
        	
	        if( content != null )
	        {
		        content.style.display = "none";
	        }
	        m_tabContentDiv = null;
	    }
	}
}
// ---------------------------------------------------
// End Bind Secondary Tabs
// ---------------------------------------------------
		
// ---------------------------------------------------
// Start Render Sub Navigation Links
// ---------------------------------------------------
function renderSubNavLinks()
{   
    var pwidth = (m_subNavLinkWidth != null) ? ("style=\"width:" + m_subNavLinkWidth + "px;\"") : "";
    document.write( "<div " + pwidth + "><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" height=\"22\" align=\"right\"><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>" );
        
    }
    if( m_buyonlineMessage )
    {
        document.write( "<td ><img src=\"" + m_imgPfx + "/images/global/masthead/secondary_sep.gif\" alt=\"\"></td><td>" );
        renderBuyOnline();
        document.write( "</td>" );
    }
    document.write( "<td>&nbsp;</td>" );
    document.write( "</tr></table></div>" );        
}
// ---------------------------------------------------
// End Render Sub Navigation Links
// ---------------------------------------------------

// ---------------------------------------------------
// Start Render Language toggle 
// ---------------------------------------------------
function renderLanguageToggle()
{ 
    document.write( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" height=\"10\" align=\"right\"><tr>" );
    document.write( "<td align=\"left\" valign=\"middle\"><a href=\"" + m_langSelectorUrl + "\"><img src=\"" + m_imgPfx + "/images/global/brand/icons/" + m_langSelectorIcon + ".gif\" border=\"0\"  alt=\"\"></a></td>" );
    document.write( "<td align=\"left\" valign=\"middle\" nowrap=\"true\"><a class=\"lnk_crumb\" href=\"" + m_langSelectorUrl + "\">" + m_langSelectorCaption + "</a></td>" );
    document.write( "</tr></table>" );
}
// ---------------------------------------------------
// End Render Language toggle
// ---------------------------------------------------


// ---------------------------------------------------
// Start Menu Definition
// ---------------------------------------------------
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.IsSelectedTab  = false;

    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            = 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 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;
}


function mhLink( text, href, icon, extra, isFilter )
{
    href = mhFixupLink( href, extra );

    this.Text            = text;
    this.Href            = href;
    this.Icon            = icon;
    this.IsFilter       = isFilter;
}


function addPnLink( text, href, icon )
{
    if( !m_pnlinks )
    {
        m_pnlinks = new Array();
    }
    
    m_pnlinks[m_pnlinks.length] = new mhLink( text, href, icon, "&~ck=pn" );
}

// ---------------------------------------------------
// End Menu Definition
// ---------------------------------------------------

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;
}

// 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;
}

function menuGoto( url )
{
	if ( m_anchorClicked )
	{
		return;
	}
	m_anchorClicked	= true;
	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 )
{
	window.open( url );
	return false;
}


// 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;
}



// -------------------------------------------------------------
// client-side footer
// -------------------------------------------------------------

function writeFooterLine()
{
	//chk this
     //document.write( "<td nowrap=\"1\"><div class=\"mhsep\"></div></td>" );
   	document.writeln( "<tr><td nowrap=\"1\" class=\"mhLine\" height=\"1\" width=\"1\"></td></tr>" );
	//document.writeln( "<tr><td bgcolor=\"" + color + "\" ><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" alt=\"\" border=\"0\" width=\"1\" height=\"1\" /></td></tr>" );
}

function writeFooterStart()
{
	var width = ( m_mhFixed ? "728" : "100%" );
	document.write( "<table style=\"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>" );
	document.write( "</table>" );
}

function writeFooterMid()
{
	var width	= ( m_mhFixed ? "728" : "100%" );
	//chk this
	document.write( "<table width=\"" + width + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ededed\">" );
	
	//-- RW: Change to move country selector
	if( typeof(m_localeSelector) != "undefined" )
	{
	    document.writeln( "<tr><td colspan=\"2\" style=\"background-color:#ffffff;border-top: 1px solid #efefef\"><div style=\"width:720px;position:relative;left:178px;padding:0px;\">" + m_localeSelector + "</div></td></tr>" );
	}
	document.write( "<tr><td colspan=\"2\"><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" /></td></tr>" );	
}

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\" width=\"7\" height=\"4\" alt=\"\" border=\"0\"></a></td><td style=\"padding-right:6px;\" valign=\"middle\"><a href=\"#mastheadtop\"><span class=\"para\">" + m_gototop + "</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>" );
}

function writeFooterEnd()
{
	var width	= ( m_mhFixed ? "728" : "100%" );
	
	document.write( "<table width=\"" + width + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#ededed\">" );
	document.write( "<tr><td colspan=\"2\" class=\"bcbg\"><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\">" );
	document.write( m_birdseed );
	document.write( "</td><td><table><tr><td valign=\"middle\"><img src=\"" + m_imgPfx + "/images/global/brand/ui/arrow_top.gif\" width=\"7\" height=\"4\" alt=\"\" border=\"0\"></td><td style=\"padding-right:6px;\" valign=\"middle\"><a href=\"#mastheadtop\"><span class=\"para\">" + m_gototop + "</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>" );
}

function writeFooter()
{
	writeFooterStart();
	writeFooterEnd();
}


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 GetScreen()
{
	this.Width = screen.width;
	this.Height = screen.height;
	this.AvailableWidth = screen.availWidth;
	this.AvailableHeight = screen.availHeight;
	this.ColorDepth = screen.colorDepth;
}

function fixup_FragHeight()
{
}

function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++)
    {
        var pair = vars[i].split("=");
        if (pair[0] == variable)
        {
            return pair[1];
        }
    }
}

// ---------------------------------------------------
// Start Render Bread Crumbs
// ---------------------------------------------------
function renderHomepageCrumbs()
{   
    document.write( "<div class=\"para_crumb_43\" style=\"padding-top:4px;\">" );      
    
    document.write("<span style=\"font-weight:bold;\">" + getYouAreHereHome() + ":&nbsp;</span>" );
        
    if( flag )
    {
        document.write( "&nbsp;<img src=\"" + m_imgPfx + "/images/global/masthead/smlflags/" + flag  + ".gif\"  alt=\"" + m_ctryShort + "\" border=\"0\" />&nbsp;&nbsp;");
    }  
    
    document.write( "<span class=\"crumbsel43\">" + m_ctryShort + "</span>" );

    document.write( "</div>" );
}

function getYouAreHereHome()
{
    if ( typeof ( m_youAreHere ) != "undefined" )
    {
        return m_youAreHere;
    }
    return "";
}


	function addOnLoad( fn ) 
	{
	    if ( onloadFired ) 
	    {
	        return;
	    }
	    if( window.onload ) 
	    {
	        if( window.onload != safeLoad ) 
	        {
	            loaded[0] = window.onload;
	            window.onload = safeLoad;
	            loaded[ 1 ] = fn;
	        }
	        else
	        {
	            loaded[ loaded.length + 1 ] = fn;
	        }
        }
	    else
	    {  
	        window.onload = fn; 
        }
	}
	
	function safeLoad() 
	{
	    onloadFired = true;
	    for( var i=0;i<loaded.length;i++ ) 
        {
            if( loaded[i] != undefined )
            {
	            loaded[i](); 
	        }
        }
	}
	
	function getXMLHTTPObj() 
	{
	    var obj = false;
	    /*@cc_on @*/
	    /*@if (@_jscript_version >= 5)
	    try { obj = new ActiveXObject( "Msxml2.XMLHTTP" ); } catch( e ){ try { obj = new ActiveXObject( "Microsoft.XMLHTTP" ); } catch( oc ) { obj = false; } }
	    @end @*/
	    if( !obj && typeof XMLHttpRequest != "undefined" ) 
	    { 
	        try 
	        { 
	            obj = new XMLHttpRequest(); 
            } 
            catch(e) 
            {
                obj = false;
            }
        }
	    if( !obj ) 
	    { 
	        return undefined; 
        }
        return obj;
    } 
    
    
    var hostname                    = document.location.hostname.toLowerCase();
    if ( hostname == "www.ap.dell.com" || hostname == "ap.dell.com" ){document.location.replace ("http://www1.ap.dell.com/content/default.aspx?c=ap&l=en&s=gen");}
    if ( hostname == "www.euro.dell.com" ){document.location.replace ("http://www1.euro.dell.com/content/default.aspx?c=eu&s=gen&l=en");}
    if ( hostname == "www.jp.dell.com" || hostname == "dell.co.jp" || hostname == "jp.dell.com" || hostname == "www.dell.co.jp" ){document.location.replace ("http://www1.jp.dell.com/content/default.aspx?c=jp&l=jp&s=gen");}
    

