if (PG == undefined) var PG = {}; // Make sure the base namespace exists.

PG = Object.extend(PG, { 	
 	topLevelParent : undefined,
 	
 	sectionMappingCode: undefined,
 		
 	topnavids :  [1,469,85,13,51,42,28,35,1000000 ],
 	
 	
 	subnavids : { 1 : [100, 258, 999000, 999001,999002,999004,999005,999006,999007,999008,999009],
 				  469 : [100,48,122,103,298,115,114,113,147],
 				  85 : [454,455,52,409],
 				  13 : [66,61,63,49,142,143,144,358,134,451],
 				  51 : [34,30,441,314,37,46,140],
 				  42 : [348,65,254,237,388,325,437,44],
 				  28 : [96,431,68,185,432,433,407,334],
 				  35 : [192,110,109,108,999010,353],
 				  1000000 : [999077,999079,999081,429]
 				  },
 	
 	inside_section_ids : [451,103,52,134,49] , 
 	
 	inside_section_subnavids : { 451: [136,132,275,139],
 								 103: [183,181,176,178],
 								 52: [53,56,57,54,55,58,59],
 								 49: [365,361,362,364,363],
 								 134: [449,135,169,450]
 								 },
 	
	  	
 	sections :  { 1: {"Name" : "" , "parent" : 1 , "URL" : "/"},
					100: {"Name" : "Breaking News" , "parent" : 1 , "URL" : "/breaking/"},
					258: {"Name" : "Weather" , "parent" : 1 , "URL" : "/weather/"},
					999000: {"Name" : "Traffic" , "parent" : 1 , "URL" : "/transportation/"},
					999001: {"Name" : "Event Guide" , "parent" : 1 , "URL" : "/events/"},
					999002: {"Name" : "Dining Guide" , "parent" : 1 , "URL" : "/diningguide/"},
					999003: {"Name" : "Explore Pittsburgh Map" , "parent" : null , "URL" : "#"},
					999004: {"Name" : "PG Store" , "parent" : 1 , "URL" : "/pgstore/"},
					999005: {"Name" : "Lottery" , "parent" : 1 , "URL" : "/lottery/"},
					999006: {"Name" : "Posted" , "parent" : 1 , "URL" : "http://posted.post-gazette.com"},
					999007: {"Name" : "Chats" , "parent" : 1 , "URL" : "/chat/"},
					999008: {"Name" : "Wireless" , "parent" : 1 , "URL" : "/pda/"},
					999009: {"Name" : "RSS" , "parent" : 1 , "URL" : "/rss/"},
					469: {"Name" : "News" , "parent" : null , "URL" : "/news/"},
					155: {"Name" : "Brian O'Neill" , "parent" : 469 , "URL" : "/columnists/"},
					153: {"Name" : "Tony Norman" , "parent" : 469 , "URL" : "/columnists/"},
					154: {"Name" : "Reg Henry" , "parent" : 469 , "URL" : "/columnists/"},
					152: {"Name" : "Ruth Ann Dailey" , "parent" : 469 , "URL" : "/columnists/"},
					100: {"Name" : "Breaking News" , "parent" : 469 , "URL" : "/breaking/"},
					48: {"Name" : "US & World" , "parent" : 469 , "URL" : "/nationworld/"},
					122: {"Name" : "Obituaries" , "parent" : 469 , "URL" : "/obituaries/"},
					103: {"Name" : "Politics" , "parent" : 469 , "URL" : "/politics/"},
					183: {"Name" : "Editorials" , "parent" : 103 , "URL" : "/politics/editorials.asp"},
					181: {"Name" : "Local" , "parent" : 103 , "URL" : "/politics/local.asp"},
					176: {"Name" : "Nation" , "parent" : 103 , "URL" : "/politics/nation.asp"},
					178: {"Name" : "State" , "parent" : 103 , "URL" : "/politics/state.asp"},
					298: {"Name" : "Education" , "parent" : 469 , "URL" : "/localnews/education/"},
					115: {"Name" : "Science" , "parent" : 469 , "URL" : "/healthscience/science.asp"},
					114: {"Name" : "Health" , "parent" : 469 , "URL" : "/healthscience/health.asp"},
					113: {"Name" : "Environment" , "parent" : 469 , "URL" : "/healthscience/environment.asp"},
					147: {"Name" : "Transportation" , "parent" : 469 , "URL" : "/transportation/"},
					85: {"Name" : "Local" , "parent" : null , "URL" : "/localnews/"},
					454: {"Name" : "State" , "parent" : 85 , "URL" : "/news/state/"},
					455: {"Name" : "Region" , "parent" : 85 , "URL" : "/news/region/"},
					409: {"Name" : "Pittsburgh 250" , "parent" : 85 , "URL" : "/pgh250/"},
					427: {"Name" : "Opinion 250" , "parent" : 409 , "URL" : "/community/"},
					426: {"Name" : "Pittsburgh 250 Eyewitness" , "parent" : 409 , "URL" : "/community/"},
					410: {"Name" : "Sprout Index Page (Community Connections)" , "parent" : 409 , "URL" : "/community/"},
					52: {"Name" : "Neighborhoods" , "parent" : 85 , "URL" : "/neighborhoods/"},
					53: {"Name" : "City" , "parent" : 52 , "URL" : "/neigh_city"},
					56: {"Name" : "East" , "parent" : 52 , "URL" : "/neigh_east/"},
					57: {"Name" : "West" , "parent" : 52 , "URL" : "/neigh_west/"},
					54: {"Name" : "North" , "parent" : 52 , "URL" : "/neigh_north/"},
					55: {"Name" : "South" , "parent" : 52 , "URL" : "/neigh_south/"},
					58: {"Name" : "Washington" , "parent" : 52 , "URL" : "/neigh_washington/"},
					59: {"Name" : "Westmoreland" , "parent" : 52 , "URL" : "/neigh_westmoreland/"},
					392: {"Name" : "High School News Wire" , "parent" : 85 , "URL" : "/hsnw/"},
					429: {"Name" : "Revolution" , "parent" : 85 , "URL" : "/localnews/panorama/"},
					13: {"Name" : "Sports" , "parent" : null , "URL" : "/sports/"},
					66: {"Name" : "Steelers & NFL" , "parent" : 13 , "URL" : "/steelers/"},
					61: {"Name" : "Penguins & NHL" , "parent" : 13 , "URL" : "/penguins/"},
					63: {"Name" : "Pirates & MLB" , "parent" : 13 , "URL" : "/pirates/"},
					49: {"Name" : "High School" , "parent" : 13 , "URL" : "/highschoolsports/"},
					365: {"Name" : "Football" , "parent" : 49 , "URL" : "/highschoolsports/football/"},
					361: {"Name" : "Basketball" , "parent" : 49 , "URL" : "/highschoolsports/basketball/"},
					362: {"Name" : "Soccer" , "parent" : 49 , "URL" : "/highschoolsports/soccer/"},
					364: {"Name" : "Other" , "parent" : 49 , "URL" : "/highschoolsports/other/"},
					363: {"Name" : "Baseball & Softball" , "parent" : 49 , "URL" : "/highschoolsports/baseball/"},
					999041: {"Name" : "2006-07 Sports -- Resource Link" , "parent" : 49 , "URL" : "#"},
					291: {"Name" : "March Madness" , "parent" : 13 , "URL" : "/sports/marchmadness/"},
					123: {"Name" : "Olympics" , "parent" : 13 , "URL" : "/sports/other/"},
					142: {"Name" : "Pitt & Big East" , "parent" : 13 , "URL" : "/sports/pitt/"},
					143: {"Name" : "PSU & Big Ten" , "parent" : 13 , "URL" : "/sports/psu/"},
					144: {"Name" : "WVU" , "parent" : 13 , "URL" : "/sports/wvu/"},
					358: {"Name" : "Hunt & Fish" , "parent" : 13 , "URL" : "/sports/huntingfishing/"},
					134: {"Name" : "More Colleges" , "parent" : 13 , "URL" : "/sports/collegeother/"},
					449: {"Name" : "National" , "parent" : 134 , "URL" : "/sports/collegenational/"},
					135: {"Name" : "Duquesne & A10" , "parent" : 134 , "URL" : "/sports/duquesne/"},
					169: {"Name" : "Robert Morris & NEC" , "parent" : 134 , "URL" : "/sports/rmu/"},
					450: {"Name" : "More District Colleges" , "parent" : 134 , "URL" : "/sports/collegedistrict/"},
					382: {"Name" : "U.S. Open" , "parent" : 13 , "URL" : "/sports/usopen/"},
					451: {"Name" : "More Sports" , "parent" : 13 , "URL" : "/sports/more/"},
					136: {"Name" : "Golf" , "parent" : 451 , "URL" : "/sports/golf/"},
					132: {"Name" : "Motor Sports" , "parent" : 451 , "URL" : "/sports/auto/"},
					275: {"Name" : "Pro Basketball" , "parent" : 451 , "URL" : "/sports/bball/"},
					139: {"Name" : "Other Sports" , "parent" : 451 , "URL" : "/sports/other/"},
					86: {"Name" : "Sports Columnists" , "parent" : 13 , "URL" : "/sports/columnists/"},
					51: {"Name" : "Living" , "parent" : null , "URL" : "/lifestyle/"},
					151: {"Name" : "Samantha Bennett" , "parent" : 51 , "URL" : "/columnists/"},
					436: {"Name" : "Ask Cat" , "parent" : 51 , "URL" : "#"},
					34: {"Name" : "Food" , "parent" : 51 , "URL" : "/food/"},
					30: {"Name" : "Homes & Garden" , "parent" : 51 , "URL" : "/homes/"},
					441: {"Name" : "Special Occasions" , "parent" : 51 , "URL" : "/lifestyle/specialoccasions/"},
					355: {"Name" : "Weddings" , "parent" : 441 , "URL" : "/weddings/"},
					350: {"Name" : "Proms" , "parent" : 441 , "URL" : "#"},
					442: {"Name" : "100th Birthdays" , "parent" : 441 , "URL" : "#"},
					323: {"Name" : "Holidays" , "parent" : 51 , "URL" : "/holidays/"},
					314: {"Name" : "Fashion" , "parent" : 51 , "URL" : "/lifestyle/fashion/"},
					338: {"Name" : "Pets" , "parent" : 51 , "URL" : "/pets/"},
					62: {"Name" : "Linda Fuoco" , "parent" : 338 , "URL" : "/pets/"},
					37: {"Name" : "Travel" , "parent" : 51 , "URL" : "/travel/"},
					243: {"Name" : "David Bear column" , "parent" : 37 , "URL" : "/travel/bear.asp"},
					402: {"Name" : "GDay from Tomorrow" , "parent" : 37 , "URL" : "/gdayfromtomorrow/"},
					46: {"Name" : "Restaurants" , "parent" : 51 , "URL" : "/dining/"},
					140: {"Name" : "Recreation" , "parent" : 51 , "URL" : "/sports/outdoors/"},
					287: {"Name" : "Ski & Snow Sports" , "parent" : 140 , "URL" : "/sports/ski/"},
					42: {"Name" : "A&E" , "parent" : 42 , "URL" : "/ae/"},
					65: {"Name" : "SEEN" , "parent" : 42 , "URL" : "/seen"},
					348: {"Name" : "Celebrities" , "parent" : 42 , "URL" : "/people/"},
					254: {"Name" : "Movies" , "parent" : 42 , "URL" : "/movies/"},
					237: {"Name" : "TV & Radio" , "parent" : 42 , "URL" : "/tv/"},
					331: {"Name" : "Oscar Watch" , "parent" : 42 , "URL" : "#"},
					388: {"Name" : "Music" , "parent" : 42 , "URL" : "/music/"},
					325: {"Name" : "Theater & Dance" , "parent" : 42 , "URL" : "/theater/"},
					326: {"Name" : "In the Wings" , "parent" : 325 , "URL" : "/theater/"},
					437: {"Name" : "Art & Architecture" , "parent" : 42 , "URL" : "/ae/art/"},
					44: {"Name" : "Books" , "parent" : 42 , "URL" : "/books/"},
					28: {"Name" : "Business" , "parent" : null , "URL" : "/businessnews/"},
					96: {"Name" : "Technology" , "parent" : 28 , "URL" : "/technology/"},
					370: {"Name" : "Cybertainment" , "parent" : 96 , "URL" : "/tv/"},
					431: {"Name" : "Business to Business" , "parent" : 28 , "URL" : "/businessnews/b2b/"},
					68: {"Name" : "Personal Business" , "parent" : 28 , "URL" : "/yourbiz/"},
					185: {"Name" : "Auto News" , "parent" : 28 , "URL" : "/autonews/"},
					432: {"Name" : "Opinion" , "parent" : 28 , "URL" : "/businessnews/opinion/"},
					433: {"Name" : "Markets" , "parent" : 28 , "URL" : "/markets/"},
					407: {"Name" : "Workplace" , "parent" : 28 , "URL" : "http://classified.post-gazette.com/jobs/"},
					334: {"Name" : "Top 50" , "parent" : 28 , "URL" : "/businessnews/top50/"},
					381: {"Name" : "Top 50 Best Places to work" , "parent" : 334 , "URL" : "/top50/"},
					35: {"Name" : "Opinion" , "parent" : null , "URL" : "/forum/"},
					192: {"Name" : "Editorials" , "parent" : 35 , "URL" : "/forum/edt/"},
					110: {"Name" : "Letters" , "parent" : 35 , "URL" : "/forum/letters/"},
					109: {"Name" : "Perspectives" , "parent" : 35 , "URL" : "/forum/comm/"},
					108: {"Name" : "PG Columnists" , "parent" : 35 , "URL" : "/columnists/"},
					999076: {"Name" : "Chats" , "parent" : 35 , "URL" : "/chat/"},
					353: {"Name" : "Blogs" , "parent" : 35 , "URL" : "/journals/"},
					1000000: {"Name" : "Media Center" , "parent" : 1000000 , "URL" : "/multimedia/"},
					999077: {"Name" : "Video" , "parent" : 1000000 , "URL" : "/multimedia/"},
					999079: {"Name" : "Audio" , "parent" : 1000000 , "URL" : "/podcast/"},
					999081: {"Name" : "Photo Catalog" , "parent" : 1000000 , "URL" : "/journal/"},
					999010: {"Name" : "Rob Rogers", "parent" : 35,  "URL" :  "/robrogers/"},
					2000000: {"Name" : "Community", "parent" : 1,  "URL" :  "http://community.post-gazette.com/"}

					
				 },
	   
	   
	   		
	   getSection : function(mapCode) {
			if(typeof this.sections[mapCode] == 'undefined'){
					mapCode = 1;
			}
			
			return this.sections[mapCode];
		},
		
	   
	   buildHeaderString : function (mappingCode) {

			var mySection = this.getSection(mappingCode);
			
			if(mySection.Name =="" && mySection.parent == 1 && mappingCode !=1){
				mappingCode = 1;
			}

		    var myHeaderString = "<a href=\""+mySection.URL+"\">" + mySection.Name.toUpperCase() + "</a>";		   
		   	var count =0;
		   	
		   while (mySection.parent != null && mySection.parent != mappingCode && count < 10){
		        count++;
				mappingCode = mySection.parent;
		    	mySection = this.getSection(mySection.parent);
				myHeaderString ="<a href=\""+mySection.URL+"\">" + mySection.Name.toUpperCase() + "</a> / "  + myHeaderString;
					    
			}
				this.topLevelParent = mappingCode;
				return myHeaderString;
		
		},

		getParentTrail : function(mappingCode){
				
				
				var mySection = this.getSection(mappingCode);
				
				var myArray = [];
				var count = 0;
				
				myArray.push(mappingCode);

				while (mySection && mySection.parent != null && mySection.parent != mappingCode && count < 10){
							count++;
					mappingCode = mySection.parent;
					mySection = this.getSection(mappingCode);
					myArray.push(mappingCode);
										
				}
				return myArray;
				
		},
		
		getInsideSection: function(mapCode){
		
			 var myArray = this.getParentTrail(mapCode);
			 
			 myInsideSection = -1;
			 
			 //console.log("parent trail: ");
			myArray.each(function(item) {
			//	console.log(item);
				
				if(PG.inside_section_ids.indexOf(item)!=-1){
				
					myInsideSection = item;
				}
				
		
				
				});
				
			return myInsideSection;
	
		
		
		
		
		},		

		navToSection : function(mapCode) {
			
			var mySection = this.getSection(mapCode);
			window.location.href =  mySection.URL;
			
			
		
		}
		});		