// StaticNav Javascript
// Come up with a one-level deep nav for static news pages, based on the first 'word' of the URL following wp-dyn
// To update the deep links array, execute the following SQL query:
// SELECT ''''||id||','||replace(actualname,'''','\''')||''',' result FROM sitetree WHERE id LIKE '%/%' AND id NOT LIKE '%/%/%' AND (menudisplay IS null OR UPPER(menudisplay) = 'Y') AND actualname is not NULL ORDER BY nodeorder,id;
function getDeepLinks(ancestor)
{
var deep_links ;
if (ancestor == 'sports/')
{
  deep_links = new Array(
  'sports,Sports',
  'sports/scoreboard,Scoreboard',
  'sports/redskins,Redskins',
  'sports/washingtoncapitals,Capitals',
  'sports/washingtonwizards,Wizards',
  'sports/baltimoreorioles,Orioles',
  'sports/dcunited,DC United',
  'sports/washingtonmystics,Mystics',
  'sports/baltimoreravens,Ravens',
  'sports/areaproteams,Area Pro Teams',
  'sports/highschools,High Schools',
  'sports/colleges,Colleges',
  'sports/leaguesandsports,Leagues and Sports',
  'sports/columns,Columnists',
  'sports/features,Features',
  'sports/index,Index'
  ) ;
}
else
{
deep_links = new Array(
'admin/archives,Archives',
'entertainment/outdoors,Test page',
'photo/dayinphotos,Day in Photos',
'food/columns,Columns',
'health/alternativecare,Alternative Care',
'home/buildit,Build It/Fix It',
'print/a1,Front Page',
'sports/scoreboard,Scoreboard',
'style/books,Book World',
'travel/webtravel,Web Travel',
'world/africa,Africa',
'health/childrenyouth,Children & Youth',
'home/furnishings,Furnishings/Design',
'print/image,Front Page Image',
'sports/redskins,Redskins',
'travel/international,International',
'travel/unitedstates,United States',
'world/americas,Americas',
'health/chronicdiseases,Chronic Diseases',
'health/fitness,Fitness',
'home/garden,Garden & Patio',
'home/guides,Guides',
'print/asection,Inside the A Section',
'travel/escapes,Mid-Atlantic',
'world/asia,Asia/Pacific',
'health/healthcare,Health Care Issues',
'home/homelife,Home Life',
'print/nationpolitics,Nation and Politics',
'style/postmagazine,Post Magazine',
'travel/visitorsguide,DC Visitors Guide',
'world/europe,Europe',
'health/men,Men',
'home/neighborhoods,Neighborhoods',
'opinion/editorials,Editorials',
'print/editorials,Editorial Pages',
'style/sundayarts,Sunday Arts',
'health/mentalhealth,Mental Health',
'home/roombyroom,Room by Room',
'print/world,World',
'style/sundaysource,Sunday Source',
'style/television,Television',
'travel/onlinetraveler,Beach Guide',
'world/mideast,Middle East',
'health/nutrition,Nutrition',
'home/columns,Columnists',
'print/business,Business',
'style/weekend,Weekend',
'travel/travelbytopic,Travel by Topic',
'world/columns,Columnists',
'health/seniors,Seniors',
'home/photogalleries,Photo Galleries',
'opinion/opeds,Op-Eds',
'print/metro,Metro',
'sports/specialevent,World Cup',
'style/columns,Columns',
'travel/liveonline,Live Discussions',
'world/search,Search the World',
'health/women,Women',
'home/liveonline,Live Discussions',
'print/sports,Sports',
'travel/photogalleries,Photo Galleries',
'world/issues,Special Reports',
'health/columns,Columns',
'home/index,Index',
'opinion/columns,Columnists',
'print/style,Style',
'style/news,Entertainment News',
'travel/columns,Columns',
'travel/heritage,Heritage Travel',
'world/photogalleries,Photo Galleries',
'health/specials,Special Reports',
'print/archive,Previous Editions',
'world/live,Live Discussions',
'health/liveonline,Live Discussions',
'print/sunday,Sunday Sections',
'world/index,World Index',
'health/photogalleries,Photo Galleries',
'print/community,The Extras',
'style/photogalleries,Photo Galleries',
'health/index,Health Index',
'print/weekly,Weekly Sections',
'style/liveonline,Live Discussions',
'sports/washingtoncapitals,Capitals',
'style/index,Index',
'print/subscription,Subscription Form',
'liveonline/regularhosts,Regular Hosts',
'opinion/letterstotheeditor,Letters to the Editor',
'photo/topstory,Top Story',
'sports/washingtonwizards,Wizards',
'opinion/tolestom,Tom Toles',
'liveonline/messageboards,Message Boards',
'opinion/outlook,Outlook',
'photo/newsvideo,News Video/Audio',
'liveonline/schedule,Weekly Schedule',
'photo/weekinreview,The Week in Review',
'sports/baltimoreorioles,Orioles',
'liveonline/specialevents,Special Events',
'sports/dcunited,United',
'sports/baltimoreravens,Ravens',
'sports/areaproteams,Area Pro Teams',
'liveonline/politics,Politics',
'sports/highschools,High Schools',
'liveonline/nation,Nation',
'sports/colleges,Colleges',
'liveonline/world,World',
'sports/leaguesandsports,Leagues and Sports',
'education/dc,District',
'liveonline/metro,Metro',
'photo/onassignment,On Assignment',
'realestate/buy,BUY',
'sports/columns,Columnists',
'photo/aqphotovoyage,AQ Photo Voyages',
'liveonline/sports,Sports',
'sports/features,Features',
'photo/bestofthepost,Best of the Post',
'liveonline/business,Business',
'sports/index,Index',
'photo/studentwork,Student Work',
'liveonline/tech,Technology',
'liveonline/style,Style',
'liveonline/entertainment,Entertainment',
'liveonline/opinion,Opinion',
'liveonline/travel,Travel',
'liveonline/health,Health',
'liveonline/homeandgarden,Home &amp; Garden',
'education/md,Maryland',
'liveonline/food,Food',
'photo/politics,Politics',
'realestate/sell,SELL',
'photo/entertainment,Entertainment',
'liveonline/education,Education',
'photo/nation,Nation',
'photo/world,World',
'liveonline/postmagazine,Post Magazine',
'photo/business,Business',
'photo/metro,Metro',
'liveonline/realestate,Real Estate',
'photo/sports,Sports',
'photo/style,Style',
'photo/visitorsguide,Visitors Guide',
'liveonline/jobs,Jobs',
'photo/travel,Travel',
'photo/education,Education',
'photo/homeandgarden,Home & Garden',
'photo/health,Health',
'education/va,Virginia',
'photo/liveonline,Live Discussions',
'realestate/rent,RENT',
'education/adulteducation,Adult Education',
'photo/faq,FAQs',
'realestate/own,OWN',
'photo/toolsandresources,Tools &#38; Resources',
'photo/contactus,Contact Us',
'photo/relatedlinks,Related Links',
'education/highereducation,Higher Education',
'business/portfolio,Portfolio',
'education/teachers,Teachers',
'metro/schools,Schools',
'nation/nationalsecurity,National Security',
'politics/fedpage,Federal Page',
'education/parenting,Parenting',
'metro/crime,Crime',
'nation/science,Science',
'politics/elections,Elections',
'metro/government,Government',
'nation/courts,Courts',
'politics/administration,Bush Administration',
'metro/traffic,Traffic',
'nation/columns,Columns',
'politics/congress,In Congress',
'business/markets,Market News',
'education/preschool,Preschool',
'metro/lottery,Lottery',
'nation/states,Search the States',
'politics/polls,Polls',
'technology/washtech,Washtech',
'business/companyresearch,Company Research',
'business/economy,Economy',
'education/kto12,K to 12',
'metro/obituaries,Obituaries',
'nation/specials,Special Reports',
'education/schoolguide,School Guide',
'metro/religion,Religion',
'nation/photogalleries,Photo Galleries',
'politics/liveonline,Live Discussions',
'education/kidspost,KidsPost',
'metro/columns,Columnists',
'nation/liveonline,Live Discussions',
'metro/dc,The District',
'nation/index,Nation Index',
'education/specials,Special Reports',
'education/liveonline,Live Discussions',
'metro/md,Maryland',
'education/photogalleries,Photo Galleries',
'education/index,Education Index',
'metro/va,Virginia',
'metro/specials,Special Reports',
'business/government,Policy',
'business/localbusiness,Metro Business',
'metro/photogalleries,Photo Galleries',
'metro/liveonline,Live Discussions',
'technology/techpolicy,Tech Policy',
'business/industries,Industries',
'metro/index,Metro Index',
'business/personalfinance,Personal Finance',
'technology/govtit,Gov\'t IT',
'business/mutuals,Mutual Funds',
'technology/markets,Markets',
'technology/venturecapital,Venture Capital',
'business/specials,Special Reports',
'technology/columns,Columnists',
'technology/software,Software',
'business/columns,Columnists',
'technology/personaltech,Personal Tech',
'technology/specials,Special Reports',
'business/liveonline,Live Discussions',
'business/index,Business Index',
'technology/jobs,Jobs',
'admin/classifieds,Classifieds',
'admin/help,Help/Feedback',
'admin/newsindex,News Index',
'kids/features,Features',
'kids/newsflash,Newsflash',
'kids/photo,Shutterbug',
'kids/poll,Polling Booth',
'technology/finance,Finance',
'travel/archive,Travel Index');
}
return deep_links ;
}

levelA = new makeArray(
'wp-srv/front.htm,News Home Page',
'wp-dyn/nation,Nation',
'wp-dyn/politics,Politics',
'wp-dyn/world,World',
'wp-dyn/metro,Metro',
'wp-dyn/business,Business',
'wp-dyn/technology,Technology',
'wp-dyn/sports,Sports',
'wp-dyn/style,Style',
'wp-dyn/education,Education',
'wp-dyn/travel,Travel',
'wp-dyn/health,Health',
'wp-dyn/realestate,Real Estate',
'wp-dyn/home,Home &amp; Garden',
'wp-dyn/food,Food',
'wp-dyn/liveonline,Live Discussions',
'wp-dyn/opinion,Opinion',
'wp-srv/weather,Weather',
'wp-dyn/print/weekly,Weekly',
'wp-dyn/digest,News Digest',
'wp-dyn/admin/classifieds,Classifieds',
'wp-dyn/print,Print Edition');

blowOutArray = new Array() ;

/*
var temp = window.location.pathname;
var section = 'nation';
if (temp.indexOf("wp-srv") != -1){
  var start = temp.indexOf("wp-srv") + 7;
  var end = (temp.indexOf("/",start) != -1) ? temp.indexOf("/",start) : temp.length;
  section = temp.substring(start, end);
}
*/
var bgColorLevelA = '#CCCCCC';
var bgColorLevelB = '#333366';
var bgColorLevelC = '#5A6B94';
var fgColorLevelA = '#333366';
var fgColorLevelB = '#FFFFFF';
var fgColorLevelC = '#B6BDCD';

var dotLevelA = '&nbsp;' ;
var dotLevelB = '<img src="http://media.washingtonpost.com/wp-srv/images/yellowdot.gif" width="5" height="6" border="0">' ;

function placeMenuNav(node)
{
  var start = 0;
  var end = (node.indexOf("/", start) != -1) ? node.indexOf("/",start) : node.length;
  var section = node.substring(start, end);
  document.writeln('<IMG SRC="http://media.washingtonpost.com/wp-srv/ssi/navigation/images/jcr_promo_042003.gif" WIDTH="120" HEIGHT="46" BORDER="0" USEMAP="#jcr_news"><BR>');
  document.writeln('<MAP NAME="jcr_news">');
  document.writeln('<AREA SHAPE="rect" COORDS="4,1,33,14" HREF="http://www.washingtonpost.com/wl/jobs/home?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="36,1,54,14" HREF="http://www.washingtonpost.com/wl/jobs/JS_JobSearch?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="63,1,81,14" HREF="http://www.washingtonpost.com/wl/jobs/EU_PostAJob?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="5,16,32,27" HREF="http://www.washingtonpost.com/wp-dyn/cars?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="37,16,52,27" HREF="http://www.washingtonpost.com/wp-dyn/cars/buy?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="59,16,77,27" HREF="http://www.washingtonpost.com/wp-dyn/cars/sell?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="5,30,72,42" HREF="http://www.washingtonpost.com/wp-dyn/realestate/?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="76,30,90,42" HREF="http://www.washingtonpost.com/wp-dyn/realestate/buy/?jcr=news" TARGET="_top" ALT="">');
  document.writeln('<AREA SHAPE="rect" COORDS="99,30,115,42" HREF="http://www.washingtonpost.com/wp-dyn/realestate/sell/?jcr=news" TARGET="_top" ALT="">');
  document.writeln('</MAP>');

  document.writeln('<table width="100%" cellpadding="0" cellspacing="0" border="0">');
  
  blowOutArray = getBlowOutArray(section+"/") ;
  var nodeIsInAry = isInArray(blowOutArray,node) ;
  
  for (var count = 0; count < levelA.length; count++)
  {
    var url = levelA[count].substring(0, levelA[count].indexOf(","));
    var name = levelA[count].substring(levelA[count].indexOf(",") + 1, levelA[count].length);
    var useBgColor = (url.indexOf(section) != -1) ? bgColorLevelB : bgColorLevelA;
    var useFgColor = (useBgColor == bgColorLevelB) ? fgColorLevelB : fgColorLevelA;
    var useDot = ( url.indexOf(section) != -1 && !nodeIsInAry ) ? dotLevelB : dotLevelA;
    document.writeln('<TR><TD BGCOLOR="'+useBgColor+'"><a href="http://www.washingtonpost.com/'+url+'"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="'+useFgColor+'">'+useDot+'<b>'+name+'</b></font></a></TD></TR>');
    if (useBgColor == bgColorLevelB) blowOutNav(section,node);
  }
  document.writeln('<TR>') ;
  document.writeln('<TD BGCOLOR="#CCCCCC"><a href="http://www.washingtonpost.com/wp-adv/archives/front.htm"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="#336699">&nbsp;<b>Archives</b></font></a></TD>') ;
  document.writeln('</TR><TR>') ;
  document.writeln('<TD BGCOLOR="#CCCCCC"><a href="http://www.washingtonpost.com/wp-srv/contents/"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="#336699">&nbsp;<b>Site Index</b></font></a></TD>') ;
  document.writeln('</TR><TR>') ;
  document.writeln('<TD BGCOLOR="#CCCCCC"><a href="http://www.washingtonpost.com/wp-dyn/admin/help/"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="#336699">&nbsp;<b>Help / Feedback</b></font></a></TD>') ;
  document.writeln('</TR>') ;
  document.writeln('</table>') ;
  document.writeln('<TABLE WIDTH="120" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD><IMG SRC="http://media.washingtonpost.com/wp-srv/images/120_cap.gif" WIDTH="120" HEIGHT="6" BORDER="0"></TR></TABLE>');
}

function blowOutNav(section,node)
{
  useBgColor = bgColorLevelC;
  useFgColor = fgColorLevelC;
  for (var count = 0; count < blowOutArray.length; count++)
  {
    var url = blowOutArray[count].substring(0,blowOutArray[count].indexOf(","));
    var name = blowOutArray[count].substring(blowOutArray[count].indexOf(",") + 1, blowOutArray[count].length);
    if (url.indexOf(section) == 0)
    {
        if ( url == node )
        document.writeln('<TR><TD BGCOLOR="'+useBgColor+'">'+dotLevelB+'<a href="http://www.washingtonpost.com/wp-dyn/'+url+'"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="'+fgColorLevelB+'"><b>'+name+'</b></font></a></TD></TR>');
        else
        document.writeln('<TR><TD BGCOLOR="'+useBgColor+'"><a href="http://www.washingtonpost.com/wp-dyn/'+url+'"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="'+useFgColor+'">&nbsp;<b>'+name+'</b></font></a></TD></TR>');
    }
  }
}

function makeArray()
{
  for(var count = 0; count < makeArray.arguments.length; count++)
    this[count] = makeArray.arguments[count];
  this.length = count;
}

function getBlowOutArray(section)
{
  var deepLinks = getDeepLinks(section) ;
  var boAry = new Array() ;
  var i = 0 ;
  for (var count=0; count<deepLinks.length; count++)
  {
    if ( deepLinks[count].indexOf(section) == 0 )
  {
    boAry[i] = deepLinks[count] ;
    i++ ;
    }
  }
  return boAry ;
}

function isInArray(ary,item)
{
  for (var count=0; count<ary.length; count++)
  {
    if ( ary[count].indexOf(item+",") == 0 )
    return true ;
  }
  return false ;
}

// this is for the "navigate to sections" dropdowns on the new article template
function placeDropDownNav(loc)
{
	var formName = "topSections";
	if (loc==null)
	{	loc = "top";	}
	if (loc=="bottom")
	{	var formName = "bottomSections";	 }
	
	var agt=navigator.userAgent.toLowerCase()
	
	// for MAC browsers only
	if ( document.getElementById && agt.indexOf("mac")!=-1 )
	{
		//alert("true");
		document.write('<form name="'+formName+'" style="display: inline;">');
		document.write('<table cellpadding="0" cellspacing="0" border="0">');
	}
	else
	{
		//alert("false");
		document.write('<form name="'+formName+'">');
		document.write('<table cellpadding="0" cellspacing="0" border="0" align="top">');
	}
	
	//document.write('<form name="'+formName+'">');
	//document.write('<table cellpadding="0" cellspacing="0" border="0">');
	document.write('<tr><td width="5" height="5"><SPACER TYPE="BLOCK" WIDTH="5" HEIGHT="5"></td></tr>');
	document.write('<tr><td valign="top" align="middle"><select name="sections">');
	document.write('<option value="nope">Navigate to Sections');
	
	// add jobs, cars and realestate first:
	document.writeln('<option value=http://www.washingtonpost.com/wl/jobs/home>Jobs');
	document.writeln('<option value=http://www.washingtonpost.com/wp-dyn/cars/>Cars');
	document.writeln('<option value=http://www.washingtonpost.com/wp-dyn/realestate/>Real Estate');
	document.writeln('<option>--------------------');
	
	
	for (var count = 0; count < levelA.length; count++)
  {
		var url = levelA[count].substring(0, levelA[count].indexOf(","));
    var name = levelA[count].substring(levelA[count].indexOf(",") + 1, levelA[count].length);
		document.writeln('<option value=http://www.washingtonpost.com/'+url+'>'+name);
	}
	
	// add jobs, cars and realestate first:
	document.writeln('<option>--------------------');
	document.writeln('<option value=http://www.washingtonpost.com/wp-adv/archives/>Archives');
	document.writeln('<option value=http://www.washingtonpost.com/wp-srv/contents/>Site Index');
	document.writeln('<option value=http://www.washingtonpost.com/wp-dyn/admin/help/>Help/Feedback');
	document.write('</select>');
	document.write('&nbsp;&nbsp;<A href="javascript:leapto(\''+formName+'\');"><img src="http://media.washingtonpost.com/wp-srv/images/go_front.gif" border="0" width="29" height="17" align="absMiddle"></a>');
	document.write('</td></tr>');
	document.write('<tr><td width="5" height="5"><SPACER TYPE="BLOCK" WIDTH="5" HEIGHT="5"></td></tr><span></form></span>');
  document.write('</table>');
}