// 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||','||actualname FROM sitetree@ftlink WHERE id LIKE '%/%' AND id NOT LIKE '%/%/%' AND (menudisplay IS null OR UPPER(menudisplay) = 'Y') ORDER BY id;
deepLinks = new makeArray(
'business/columns,Columnists','business/companyresearch,Company Research','business/index,Business Index','business/industries,Industries','business/liveonline,Live Online','business/markets,Market News','business/mutuals,Mutual Funds','business/personalfinance,Personal Finance','business/portfolio,Portfolio','business/realestate,Real Estate','business/specials,Special Reports','business/technology,Technology',
'education/distancelearning,Distance Learning','education/highereducation,Higher Education','education/index,Education Index','education/kto12,K-12','education/learning,Learning','education/liveonline,Live Online','education/metroschools,Metro Schools','education/parenting,Parenting','education/politics,Politics','education/preschool,Preschool','education/specials,Trends & Debates','education/teachers,Teachers',
'health/alternativecare,Alternative Care','health/childrenyouth,Children & Youth','health/chronicdiseases,Chronic Diseases','health/columns,Columns','health/fitness,Fitness','health/healthcare,Health Care Issues','health/index,Health Index','health/liveonline,Live Online','health/men,Men','health/mentalhealth,Mental Health','health/nutrition,Nutrition','health/photogalleries,Photo Galleries','health/seniors,Seniors','health/specials,Special Reports','health/women,Women',
'home/buildit,Build It/Fix It','home/columns,Columnists','home/furnishings,Furnishings/Design','home/garden,Garden & Patio','home/homelife,Home Life','home/index,Index','home/liveonline,Live Online','home/neighborhoods,Neighborhoods','home/photogalleries,Photo Galleries','home/roombyroom,Room by Room',
'kids/brainfood,Brainfood','kids/features,Features','kids/newsflash,Newsflash','kids/photo,Shutterbug','kids/poll,Polling Booth',
'metro/columns,Columnists','metro/crime,Crime','metro/dc,The District','metro/government,Government','metro/index,Metro Index','metro/liveonline,Live Online','metro/lottery,Lottery','metro/md,Maryland','metro/obituaries,obituaries','metro/photogalleries,Photo Galleries','metro/religion,Religion','metro/schools,Schools','metro/specials,Special Reports','metro/traffic,Traffic','metro/va,Virginia',
'nation/columns,Columns','nation/courts,Courts','nation/index,Nation Index','nation/liveonline,Live Online','nation/nationalsecurity,National Security','nation/photogalleries,Photo Galleries','nation/science,Science','nation/specials,Special Reports','nation/states,Search the States',
'opinion/columns,Columnists','opinion/editorials,Editorials','opinion/letterstotheeditor,Letters to the Editor','opinion/outlook,Outlook',
'print/a1,Front Page','print/archive,Previous Editions','print/asection,Inside the A Section','print/business,Business','print/community,Communities','print/editorials,Editorials','print/image,Front Page Image','print/metro,Metro','print/nationpolitics,Nation and Politics','print/sports,Sports','print/style,Style','print/subscription,Subscription Form','print/sunday,Sunday Sections','print/weekly,Weekly Sections','print/world,World',
'sports/areaproteams,Area Pro Teams','sports/colleges,Colleges','sports/columns,Columnists','sports/features,Features','sports/highschools,High Schools','sports/index,Index','sports/insidesports,Inside Sports','sports/leaguesandsports,Leagues and Sports','sports/liveonline,Live Online','sports/photogalleries,Photo Galleries','sports/redskins,Redskins',
'style/books,Book World','style/columns,Columnists','style/comics,Comics','style/contests,Contest','style/crosswords,Crosswords','style/food,Food','style/home,Home','style/index,Index','style/liveonline,Live Online','style/photogalleries,Photo Galleries','style/postmagazine,Post Magazine','style/sundayarts,Sunday Arts','style/television,Television','style/weekend,Weekend',
'travel/columns,Columns','travel/escapes,Mid-Atlantic','travel/heritage,Heritage Travel','travel/international,International','travel/liveonline,Live Online','travel/photogalleries,Photo Galleries','travel/seasonal,Ski Guide','travel/travelbytopic,Travel by Topic','travel/unitedstates,United States','travel/visitorsguide,Visitors Guide',
'world/africa,Africa','world/americas,Americas','world/asia,Asia/Pacific','world/columns,Columnists','world/europe,Europe','world/exussr,Former USSR','world/index,World Index','world/live,Live Online','world/mideast,Middle East','world/photogalleries,Photo Galleries','world/search,Search the World','world/specials,Special Reports');

levelA = new makeArray(
'wp-srv/front.htm,News Home Page',
'wp-dyn/digest,News Digest',
'wp-dyn/nation,Nation',
'wp-dyn/world,World',
'wp-dyn/metro,Metro',
'wp-dyn/business,Business',
'wp-dyn/washtech,Technology',
'wp-dyn/sports,Sports',
'wp-dyn/style,Style',
'wp-dyn/education,Education',
'wp-dyn/travel,Travel',
'wp-dyn/health,Health',
'wp-dyn/home,Home Garden',
'wp-dyn/opinion,Opinion',
'wp-srv/weather,Weather',
'wp-dyn/weekly,Weekly',
'wp-dyn/admin/classifieds,Classifieds',
'wp-dyn/print,Print Edition',
'wp-adv/archives,Archives',
'wp-srv/contents,Site Index',
'wp-dyn/admin/help,Help');

/*
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 = '#336699';
var fgColorLevelA = '#333366';
var fgColorLevelB = '#FFFFFF';
var fgColorLevelC = '#CCCCCC';

function placeNav(node){
	var start = 0;
	var end = (node.indexOf("/", start) != -1) ? node.indexOf("/",start) : node.length;
	var section = node.substring(start, end);
	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;
		document.writeln('<TR><TD BGCOLOR="'+useBgColor+'"><a href="http://washingtonpost.com/'+url+'"><font size="-2" face="verdana, ms sans serif, arial" class="nodec" color="'+useFgColor+'">&nbsp;<b>'+name+'</b></font></a></TD></TR>');
		if (useBgColor == bgColorLevelB) blowOutNav(section);
	}
}

function blowOutNav(section){
	useBgColor = bgColorLevelC;
	useFgColor = fgColorLevelC;
	for (var count = 0; count < deepLinks.length; count++){
		var url = deepLinks[count].substring(0,deepLinks[count].indexOf(","));
		var name = deepLinks[count].substring(deepLinks[count].indexOf(",") + 1, deepLinks[count].length);
		if (url.indexOf(section) == 0){
			document.writeln('<TR><TD BGCOLOR="'+useBgColor+'"><a href="http://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;
}
