document.writeln('<link rel="stylesheet" href="http://www.washingtonpost.com/wp-srv/globalnav/styles/globalNav.css"></link>');
document.writeln('<link rel="stylesheet" href="http://www.washingtonpost.com/wp-srv/globalnav/styles/globalNavJS.css"></link>');

function openWin(url)
{ 
	var navWin = window.open(url,"NewWin", "scrollbars,toolbar=false,menubar=false,resizable=false,width=740,height=595,top=0,right=1000"); 
}

var GlobalNavigation = function()
{
	this.channel = '';
	this.timesThrough = 0;
	this.components = 0;
	this.setChannel( 'news' );
}
GlobalNavigation.LOGO = 1 << 0;
GlobalNavigation.REGISTRATION = 1 << 1;
GlobalNavigation.PRINT_EDITION = 1 << 2;
GlobalNavigation.NAV_BAR = 1 << 3;
GlobalNavigation.SEARCH_BAR = 1 << 4;
GlobalNavigation.LINKS = 1 << 5;
GlobalNavigation.COPYRIGHT = 1 << 6;
GlobalNavigation.WIDE = 1 << 7;

GlobalNavigation.prototype.setChannel = function( c )
{
	this.channel = c;
	/* Jobs is its own beast */
	if( this.channel == 'jobs' )
	{
		this.components = GlobalNavigation.LOGO 
						+ GlobalNavigation.PRINT_EDITION
						+ GlobalNavigation.NAV_BAR
						+ GlobalNavigation.COPYRIGHT
						;
	}
	else if( this.channel == 'jobs970' )
	{
		this.components = GlobalNavigation.LOGO 
						+ GlobalNavigation.PRINT_EDITION
						+ GlobalNavigation.NAV_BAR
						+ GlobalNavigation.COPYRIGHT
						+ GlobalNavigation.LINKS
						+ GlobalNavigation.WIDE
						;
	}
	else if( this.channel == 'realestate970' )
	{
		this.components = GlobalNavigation.LOGO 
						+ GlobalNavigation.PRINT_EDITION
						+ GlobalNavigation.NAV_BAR
						+ GlobalNavigation.COPYRIGHT
						+ GlobalNavigation.WIDE
						;
	}
	else if( this.channel == 'article970' || this.channel == 'photo970')
	{
		this.components = GlobalNavigation.LOGO 
						+ GlobalNavigation.REGISTRATION
						+ GlobalNavigation.PRINT_EDITION
						+ GlobalNavigation.NAV_BAR
						+ GlobalNavigation.COPYRIGHT
						+ GlobalNavigation.LINKS
						+ GlobalNavigation.SEARCH_BAR
  						+ GlobalNavigation.WIDE
						;
	}
	
	else if( this.channel == 'merchandise')
   {
       this.components = GlobalNavigation.LOGO
                       + GlobalNavigation.REGISTRATION
                       + GlobalNavigation.PRINT_EDITION
                       + GlobalNavigation.NAV_BAR
                       + GlobalNavigation.COPYRIGHT
                       + GlobalNavigation.LINKS
                         + GlobalNavigation.WIDE
                       ;
   } 
	else if( this.channel == 'weather' || this.channel == 'stockpoint')
	{
		this.components = GlobalNavigation.LOGO 
						+ GlobalNavigation.REGISTRATION
						+ GlobalNavigation.PRINT_EDITION
						+ GlobalNavigation.NAV_BAR
						+ GlobalNavigation.COPYRIGHT
						+ GlobalNavigation.LINKS
						+ GlobalNavigation.SEARCH_BAR
						;
	}   
	else
	{
		this.components = GlobalNavigation.LOGO 
						+ GlobalNavigation.REGISTRATION
						+ GlobalNavigation.PRINT_EDITION
						+ GlobalNavigation.NAV_BAR
						+ GlobalNavigation.COPYRIGHT
						+ GlobalNavigation.LINKS
						+ GlobalNavigation.SEARCH_BAR
						+ GlobalNavigation.WIDE
						;
	}
	/* Remove search bar from the following channels */
	if( ( this.channel == 'cars' ) ||
      ( this.channel == 'realestate' ) ||
      ( this.channel == 'warrenbrown' ) ||
      ( this.channel == 'nosearch' ) ||
      ( this.channel == 'classifieds' ) 
    )
	{
		this.components = ( this.components ^ ( GlobalNavigation.SEARCH_BAR ) );
	}
}

GlobalNavigation.prototype.render = function()
{
	this.timesThrough++;
	if( this.timesThrough == 1 )
	{
		return this.getTopNav();
	}
	else if( this.timesThrough == 2 )
	{
		return this.getBottomNav();
	}
	else
	{
		return "";
	}
}
GlobalNavigation.prototype.getTopNav = function()
{
	var out = "";
	if( ( this.components & GlobalNavigation.WIDE ) != GlobalNavigation.WIDE )
	{
		out += '<style type="text/css">';
		out += '.globalNav {width:970px;}';
    out += '.globalNav .features {width:200px;}'
    out += '.globalNav .classifieds {width:170px;float:left;background-color:#5B87B8;}';
		out += '</style>';
	}
	out += '<div id="topNav" class="globalNav">';
	out += this.getLogoBar();
	if( ( this.components & GlobalNavigation.NAV_BAR ) == GlobalNavigation.NAV_BAR ) out += this.getNavBar();
	if( ( this.components & GlobalNavigation.SEARCH_BAR ) == GlobalNavigation.SEARCH_BAR ) out += this.getGrayBar();
	out += '</div>';
	out += '<div style="clear:both"></div>';
	return out;
}
GlobalNavigation.prototype.getBottomNav = function()
{
	doc = document.location.href
	if (doc.indexOf("wl/jobs/JS_Login") != -1) top.window.focus();
	var out = "";
	out +=' <div style="clear:both"></div>';
	out += '<div id="bottomNav" class="globalNav">';
	if( ( this.components & GlobalNavigation.SEARCH_BAR ) == GlobalNavigation.SEARCH_BAR ) out += this.getGrayBar();
	if( ( this.components & GlobalNavigation.COPYRIGHT ) == GlobalNavigation.COPYRIGHT ) out += this.getBottomStrip();
	if( ( this.components & GlobalNavigation.LINKS ) == GlobalNavigation.LINKS ) out += this.getPlethoraOfLinks();
	out += '</div>';
	return out;
}
GlobalNavigation.prototype.getLogoBar = function ()
{
	var out = "";
	out += '	<div class="logoBar">';
	if( ( this.components & GlobalNavigation.LOGO ) == GlobalNavigation.LOGO ) out += this.getWPLogo();
	else out += '<div class="logo"><b></b></div>';
	if( ( this.components & GlobalNavigation.REGISTRATION ) == GlobalNavigation.REGISTRATION ) out += this.getRegistration();
	else out += '<div class="registration"><b></b></div>';
	if( ( this.components & GlobalNavigation.PRINT_EDITION ) == GlobalNavigation.PRINT_EDITION ) out += this.getPrintEdition();
	else out += '<div class="printEdition"><b></b></div>';
	out += '	</div>';
	return out;
}
GlobalNavigation.prototype.getNavBar = function ()
{
	var out = "";
	out += '	<div class="navBar" style="clear:both; background:#5B87B8; height:21px; overflow:hidden;">';
    out += '<img src="http://media.washingtonpost.com/wp-srv/ssi/globalnav/gr/nav_all_760x21_v2.gif" border="0" width="760" height="21" usemap="#wpnav"><map name="wpnav"><area shape="rect" coords="1,1,41,20" href="http://www.washingtonpost.com/" alt="News"><area shape="rect" coords="43,1,97,21" href="http://www.washingtonpost.com/wp-dyn/content/politics/" alt="Politics"><area shape="rect" coords="99,1,158,21" href="http://www.washingtonpost.com/wp-dyn/content/opinions/" alt="Opinions"><area shape="rect" coords="161,1,208,21" href="http://www.washingtonpost.com/wp-dyn/content/sports/" alt="Sports"><area shape="rect" coords="211,1,295,21" href="http://www.washingtonpost.com/wp-dyn/content/artsandliving/" alt="Arts &amp; Living"><area shape="rect" coords="302,1,372,21" href="http://www.washingtonpost.com/wp-dyn/content/liveonline/" alt="Discussions"><area shape="rect" coords="375,1,463,21" href="http://www.washingtonpost.com/wp-dyn/content/photo/" alt="Photos &amp; Video"><area shape="rect" coords="466,1,532,21" href="http://www.washingtonpost.com/wp-dyn/content/artsandliving/cityguide/" alt="City Guide"><area shape="rect" coords="536,1,609,21" href="http://www.washingtonpost.com/wp-srv/admin/classifieds/" alt="Classifieds"><area shape="rect" coords="611,1,646,21" href="http://www.washingtonpost.com/wl/jobs/home" alt="Jobs"><area shape="rect" coords="648,1,685,21" href="http://www.washingtonpost.com/wp-dyn/content/cars/" alt="Cars"><area shape="rect" coords="687,1,759,21" href="http://www.washingtonpost.com/wp-dyn/content/realestate/" alt="Real Estate"></map>';
	out +='</div>';
	return out;
};
GlobalNavigation.prototype.getWPLogo = function ()
{
	var out = "";
	out += '		<div class="logo"><a href="http://www.washingtonpost.com/?nav=globaltop"><img src="http://media.washingtonpost.com/wp-srv/article/pieces/wpLogo.gif" width="250" height="42" border="0" alt="" /></a></div>';
	return out;
}
GlobalNavigation.prototype.getRegistration = function ()
{
	if( typeof Registration == 'undefined' )
	{
		return '<div class="registrationFiller"><b></b></div><div class="registration"><b></b></div>';
	}
	var reg = new Registration();
	var out = "";
	out += '		<div class="registrationFiller"><b></b></div>';
	out += '		<div class="registration">';
	if( reg.isSignedIn() )
	{
		out += '			<div id="signedIn">';
		out += '				<div class="greeting">';
		out += '					Hello ' + reg.getUserName() ;
		out += '				</div>';
		out += '				<div class="link">';
		out += '					<a href="/ac2/wp-dyn?node=admin/registration/manage&destination=manage&nextstep=gather">Edit Profile</a>';
		out += '					|';
		out += '					<a href="/ac2/wp-dyn?node=admin/registration/login&destination=logout&nextstep=confirm">Sign Out</a>';
		out += '				</div>';
		out += '			</div>';
	}
	else
	{
		out += '			<div id="signedOut">';
		out += '				<div style="float:left;"></div>';
		out += '				<div class="signIn">';
		out += '				<b><a href="/ac2/wp-dyn?node=admin/registration/register&destination=login&nextstep=gather&application=reg30-globalnav&applicationURL=http://www.washingtonpost.com">Sign In</a></b>';
		out += '				|';
		out += '				<a href="/ac2/wp-dyn?node=admin/registration/register&destination=register&nextstep=gather&application=reg30-globalnav&applicationURL=http://www.washingtonpost.com">Register Now</a>';
		out += '				</div>';
		out += '			</div>';
	}
	out += '		</div>';
	return out;
}
GlobalNavigation.prototype.getPrintEdition = function ()
{
	var out = "";
	out += '		<div class="printEdition">';
	out += '			<a href="http://www.washingtonpost.com/wp-dyn/content/print/?nav=globetop">PRINT EDITION</a> | <a href="http://washpost.com/wpnihomepage?nav=globetop">Subscribe to</a>';
	out += '			<a href="http://washpost.com/wpnihomepage?nav=globetop"><img src="http://media.washingtonpost.com/wp-srv/article/pieces/twpLogo_125x20.gif" width="125" height="20" alt="The Washington Post" border="0" style="position:relative;top:4px;"/></a>';
	out += '		</div>';
	return out;
}
GlobalNavigation.prototype.getChannels = function ()
{
	var out = "";
	out += '		<div class="channels">';
	out += '		</div>';
	return out;
}
GlobalNavigation.prototype.getFeatures = function ()
{
	var out = "";
	out += '		<div class="features">';
	out += '		</div>';
	return out;
}
GlobalNavigation.prototype.getClassifieds = function()
{
	var out = "";
	out += '		<div class="classifieds">';

	out += '		</div>';
	return out;
}
GlobalNavigation.prototype.getGrayBar = function()
{	

	var out = "";
	var formName = "";
	typeof alreadyCalled == 'undefined'?formName = "searchform1":formName ="searchform2";
	var alreadyCalled = true;
	var ie = document.getElementById?true:false;
	ie ? formSize=27 : formSize=24 ;
	out += '	<div class="grayBar">';
	out += '		<table width="760" cellpadding="0" cellspacing="0" border="0">';
	out += '		<tr>';
	out += '			<td class="headerFormat"><div style="padding-left:8px;position:relative;top:2px;">SEARCH: </div></td>';
	out += '			<FORM name="'+formName+'" action="http://www.washingtonpost.com/cgi-bin/search99.pl" method="post" style="margin-top:0px;margin-bottom:0px;display:inline;" />';
	out += '			<td valign="middle"><INPUT type="hidden" value="news" name="searchsection" /><div style="position:relative;top:2px;"><INPUT type="radio" name="searchdatabase" value="news" checked /></div></td>';
	out += '			<td class="labelFormat"><div style="position:relative;top:2px;">News</div></td>';
	out += '			<td><div style="position:relative;top:2px;"><INPUT type="radio" name="searchdatabase" value="websearch" /></div></td>';
	out += '			<td class="labelFormat"><div style="position:relative;top:2px;padding-right:10px;">Web</div></td>';
	out += '			<td valign="top"><INPUT size="'+formSize+'" name="keywords" style="position:relative;top:2px;"></td>';
	out += '			<td><div style="padding-left:8px;position:relative;top:2px;"><INPUT name="" type="image" alt="Search" src="http://media.washingtonpost.com/wp-srv/article/pieces/articleIcon_go_22x22.gif" /></div></td>';
	out += '			</FORM>';
	// out += '			<td><div style="padding-left:10px;position:relative;top:2px;"><img src="http://www.washingtonpost.com/wp-srv/article/pieces/articleIcon_yahoo_165x15.gif" border="0" width="165" height="15"></div></td>';
	out += '			<td><div style="padding-left:10px;position:relative;top:2px;"><img src="http://www.washingtonpost.com/wp-srv/google/googlenav.gif" border="0" width="141" height="22" alt="Powered by Google"/></div></td>' ;
	out += '			<td align="center"><span class="topEmailed"><a href="http://www.washingtonpost.com/wp-srv/mostemailed/index.html"><b>Top 20 E-mailed Articles</b></a></span></td>';
	out += '		</tr>';
	out += '		</table>';
	out += '	</div>';
	return out;
}
GlobalNavigation.prototype.getBottomStrip = function()
{
	var nowDate = new Date();
	var thisYear = nowDate.getFullYear();
	var out = "";
	out+='<div class="bottomStrip">';
	out+='&copy; <a href="http://www.washingtonpost.com/wp-srv/interact/longterm/talk/copy.htm?nav=globebot">Copyright</a> 1996-'+thisYear ;
	out+=' ';
	out+='The Washington Post Company';
	out+='&nbsp; | &nbsp;';
	out+='<a href="http://www.washingtonpost.com/wp-srv/interact/longterm/talk/members.htm?nav=globebot">User Agreement and Privacy Policy</a>';
	out+='&nbsp; | &nbsp;';
	out+='<a href="http://www.washingtonpost.com/wp-srv/contents/permissions.htm?nav=globebot">Rights and Permissions</a>';
    out+='&nbsp; | &nbsp;';
	out+='<a href="http://www.washingtonpost.com?nav=globebot">Home</a>';
	out+='</div>';
	return out;
}
GlobalNavigation.prototype.getPlethoraOfLinks = function()
{
	var out = "";
	out+='	<div class="plethoraOfLinks">';
	out+='	<a href="http://www.washingtonpost.com/"><strong>washingtonpost.com:</strong></a>';
	out+='	<nobr><a href="javascript:openWin(\'http://www.washingtonpost.com/wp-srv/admin/help/popup/frame_page.html\')"><em>Contact Us</em></a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-srv/contents/aboutsite.htm"><em>About Us</em></a></nobr> |';
	out+='	<nobr><a href="javascript:document.JobsAtWPNI.submit()">Work at washingtonpost.com</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-adv/mediakit/adinfo/">Advertise</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-adv/mediakit/mediacenter/front.htm">Media Center</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-srv/contents/">Site Index</a></nobr> |';
    out+='	<nobr><a href="http://topics.washingtonpost.com/wp-srv/topics/">Site Map</a></nobr> |';
	out+='	<nobr><a href="http://pqasb.pqarchiver.com/washingtonpost/">Archives</a></nobr><br/>';
	out+='	<nobr><a href="http://www.washingtonpost.com/ac2/wp-dyn?node=admin/email">E-mail Newsletters</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-dyn/rss/">RSS Feeds</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-srv/contents/devices.htm">Wireless Access</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-srv/headlines/">Our headlines on your site</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/wp-srv/guide/setashome.htm">Make Us Your Homepage</a></nobr> |';
	out+='	<nobr><a href="http://www.mywashingtonpost.com/">mywashingtonpost.com</a></nobr>';
	out+='	<br/><strong>The Washington Post:</strong>';
	out+='	<nobr><a href="http://washpost.com/wpnihomepage">Subscribe</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/subscriberservices">Subscriber Services</a></nobr> |';
	out+='	<nobr><a href="http://adsite.washpost.com/">Advertise</a></nobr> |';
	out+='	<nobr><a href="http://ee.washpost.com/index.jsp">Electronic Edition</a></nobr> |';
	out+='	<nobr><a href="http://www.washingtonpost.com/buyphotos">Online Photo Store</a></nobr>';
	out+='	<!--nobr><a href="http://washingtonpoststore.com/">Online Store </a></nobr-->';
	out+='	<br/><strong>The Washington Post Company:</strong>';
	out+='	<nobr><a href="http://washpost.com/">Information</a></nobr> |';
	out+='	<nobr><a href="http://www.washpostco.com/index.htm">Other Post Co. Websites </a></nobr>';
	out+='	</div>';
	return out;
}
var _gn = new GlobalNavigation();
function placeChannelNav( channel )
{
	if( channel != null ) _gn.setChannel( channel );
	document.writeln( _gn.render() );
}

// THE FOLLOWING CODE PLACES A UNIVERSAL PERSISTENT COOKIE RESIDENT ON USERS' MACHINES
var upc_url = new String(document.location.href) ;

// if (upc_url.indexOf(".washingtonpost.com") > -1)
if (upc_url.indexOf(".washingtonpost.com") > -1)
{
  c = document.cookie; 
  var pos = c.indexOf("WPNIUCID"); 
  if (pos == -1) 
  {
    d = new Date(); 
    i = "WPNI"+ d.getTime() +"."+ Math.round(Math.random()*10000); 
    d.setTime(d.getTime() + 31104000000); 
    document.cookie = "WPNIUCID="+ i + 
                      "; expires="+ d.toGMTString() + 
                      "; path=/"+ 
                      "; domain=.washingtonpost.com";
  }
}
