			var DHTML = (document.getElementById || document.all);
			// sld: 08-16-2010: trying to eliminate all javascript that causes top nav to paint subnav (so we don't have errors)
//			var DHTML = null;
		
		
		
		
			// decide which section of the site we are in
			var url = document.location;
			var myPage = new String(url.pathname);
			var aryDir = myPage.split('/');
			var mySection = null;
			// make current section's layer visible, if reasonable to do so				
			if(aryDir[1]) {
				mySection = aryDir[1];	
				myID = aryDir[1] + '_' + aryDir[2];
			}
			
			// reference the number key value of the images and nav layers, based on the section (first dir of the URL)
			var aryLayerName = Array();
			aryLayerName["AboutUs"] = "03";
			aryLayerName["Montana"] = "05";
			aryLayerName["Shop"] = "07";
			aryLayerName["Schedule"] = "09";
			aryLayerName["TeachersParents"] = "11";
			aryLayerName["Support"] = "13";
			
			// array of Nav Layer Objects
			var aryLayerObj = Array();
			
			// array of Img Objects
			var aryImgObj = Array();
			
			
			
			// a reference to the position of the first img object in the navigation
			var x = 0;
			var y = 0;
			
			// keep track of which nav image key is visible
			var curVisibleImgKey = null;
			if(aryLayerName[mySection]) curVisibleImgKey = aryLayerName[mySection];
			
			// keep track of which nav layer is visible
			var curVisibleLayerName = null;
			
			function setReferenceObject() {	
				// get value of x, pronto
				if(DHTML) {
					// a reference to the first img object in the navigation
					var tmp = null;
					count = 0;
					while(!x) {
						tmp = new getObj("imgKey_01");				
						x = findPosX(tmp.obj);
						y = findPosY(tmp.obj);					
						if(!x) setTimeout("var a=1;", 500);
						count++;
						if(count>1000) return;
					}
				} 	
				// preload all other image states into this array, at our luxery
				var myimages=new Array();
				
				// highlight current section
				if(mySection) {
					// make this Section's Layer visible, if we are one sub-page
					sectionKey = null;
					if(aryLayerName[mySection]) {
			
						sectionKey = aryLayerName[mySection];
				
						curVisibleLayerName = 'subNav_' + sectionKey;
						//sld: 12-14-03: currently selected is already visible
						//makeLayerVisible(curVisibleLayerName);	
					
						// make a reference to the currently selected button in images array;
						myimages[sectionKey + 'off'] = '/templates/montanapbs_org/images/img-sets/shared_nav/off/navLine02_' + sectionKey + '.gif';
					}
				}	

				var aryTriangleStates = new Array('off_off', 'off_on', 'on_off');
				var aryTriangleStatesIrreg = new Array('off', 'on');
				var aryMainStates = new Array('on', 'on_line');
				var even = 1;
				for(var i=2; i<15; i++) {
				
					// get handles to all the image objects
					imgKey = '' + i;
					if(imgKey < 10) imgKey = '' + '0' + imgKey;	
					aryImgObj[imgKey] = document.images["imgKey_" + imgKey];


					// loop thru states and preload images
					var mystates;
					if(even) {
						// we have preceding and following triangles
						mystates = aryTriangleStates;
						if(imgKey == '02' || imgKey == '14') {
							mystates = aryTriangleStatesIrreg;
						}
						
					} else {
						// we have the main button
						mystates = aryMainStates;
					}
					
					for(var u in mystates) {
						state = mystates[u];
						myimages[imgKey + state] = '/templates/montanapbs_org/images/img-sets/shared_nav/' + state + '/navLine02_' + imgKey + '.gif';
					}	
					if(even) {
						even = 0;
					} else {
						even = 1;
					}
				}
				
				preloadimages(myimages);
				if(DHTML) {
					// place all of the layers in relation to the first image and get handle to object
					positionLayers(0);	
				}

				// successfully made it thru this function; therefore we definately have javascript; so, report home
				//document.images["checkjavascript"].src='/internal/check-javascript.php';						
			}
			
			function positionLayers(override)
			{		
				// place all of the layers in relation to the first image and get handle to object
				for(var i in aryLayerName) {				
					lyr = 'subNav_' + aryLayerName[i];	
					if(override || !aryLayerObj[lyr]) {
						aryLayerObj[lyr] = setLyr(lyr);
					}				
				}	
				
			}
			function preloadimages(myimages)
			{
			if(document.images) {
				for (var i in myimages){
					src = myimages[i];
					myimages[i] = new Image();
					myimages[i].src = src;
				}
			}
			}
			
			function Toggle(imgKey, mouseState)
			{
			
			// a reference to the main img object in the navigation
			imgKey = '' + imgKey;	
			if(!aryImgObj[imgKey]) {	
				aryImgObj[imgKey] = document.images["imgKey_" + imgKey];
			}
			
			suffix = '_line';
			if(mouseState == 'highlight') {
				mouseState = 'mouseover';
				suffix = '';
			}
			
			if(mouseState == 'mouseover') {
				// un-highlight previous nav objects
				if(curVisibleImgKey && curVisibleImgKey != imgKey) {					
					HighlightNav(curVisibleImgKey, 'off', '');			
				}
				
				// hilight current nav objects
				HighlightNav(imgKey, 'on', suffix);
			
				curVisibleImgKey = imgKey;
			} else if(mouseState == 'mouseout') {	
				if(!aryImgObj[curVisibleImgKey]) {	
					aryImgObj[curVisibleImgKey] = document.images["imgKey_" + curVisibleImgKey];
				} 
				imgObj = aryImgObj[curVisibleImgKey];	
			
				if(imgObj) imgObj.src = '/templates/montanapbs_org/images/img-sets/shared_nav/on/navLine02_' + curVisibleImgKey + '.gif';				
			} 
			}
				
			function HighlightNav(myKey, state, suffix)
			{			
			// get reference to main image	
			myKey = '' + myKey;
			if(!aryImgObj[myKey]) {	
				aryImgObj[myKey] = document.images["imgKey_" + myKey];
			} 
			imgObj = aryImgObj[myKey];	

			// set the source of the main button
			imgObj.src = '/templates/montanapbs_org/images/img-sets/shared_nav/' + state + suffix + '/navLine02_' + myKey  + '.gif';		
			// get the preceding key value
			var preceding_Key = (myKey*1) - 1;
			if(preceding_Key < 10) preceding_Key = '' + '0' + preceding_Key;
			
			// get reference to preceding triangle			
			if(!aryImgObj[preceding_Key]) {	
				aryImgObj[preceding_Key] = document.images["imgKey_" + preceding_Key];
			} 
			preceding_imgObj = aryImgObj[preceding_Key];
			
			// get directory name
			var dir = 'off_' + state;
			if(preceding_Key == '02') dir = state; //'on';
			
			// swap out its image
			preceding_imgObj.src = '/templates/montanapbs_org/images/img-sets/shared_nav/' + dir + '/navLine02_' + preceding_Key + '.gif';
			
			// get the following key value
			var following_Key = (myKey*1) + 1;		
			if(following_Key < 10) following_Key = '' + '0' + following_Key;	
			
			// get reference to following triangle			
			if(!aryImgObj[following_Key]) {					
				//var tmp = new getObj("imgKey_" + following_Key);
				//aryImgObj[following_Key] = tmp.obj;
				aryImgObj[following_Key] = document.images["imgKey_" + following_Key];
			} 
			following_imgObj = aryImgObj[following_Key];
			
			// get directory name
			var dir = state + '_off';
			if(following_Key == '14') dir = state; //'on';
		
			// swap out its image
			following_imgObj.src = '/templates/montanapbs_org/images/img-sets/shared_nav/' + dir + '/navLine02_' + following_Key + '.gif';			
			
			}
			
			
			function makeLayerVisible(lyr) {	
							
				// place the layer in relation to the first image	
				if(!aryLayerObj[lyr]) {
					aryLayerObj[lyr] = setLyr(lyr);
				}
				
				// make layer visible
				aryLayerObj[lyr].style.visibility = 'visible';
			}

			
			
			function showSubNav(lyr) {			
				// sld: 08-16-2010: hide subnav permanently via Lisa's request
//				return;

				// we haven't established dimensions of the image object that we place the layer in relation to, yet
				// or, we do not have a browser capable of dealing with the sub-nav
				if(!x || !DHTML) return;
				
				// make sure the fullprograminfo layer isn't already showing
				if(curVisibleLayerName == lyr) return; 
				
				// hide previously visible layer, if necessary
				closeSubNav();
				
				// make the layer visible
				makeLayerVisible(lyr);
				
				// make note of currently visible layer
				curVisibleLayerName = lyr;
			}


			function getObj(name)
			{
			
			  // sld: added null state
			  //this.obj = null;
			  if (document.getElementById)
			  {  
				  
				// added qualifier (in case sent in bogus element id)
				if (document.getElementById(name)) 
				{
				  this.obj = document.getElementById(name);
				  this.style = document.getElementById(name).style;
				}
			  }
			  else if (document.all)
			  {
				// added qualifier (in case sent in bogus element id)
				if (document.all[name]) 
				{
				  this.obj = document.all[name];
				  this.style = document.all[name].style;
				}
			  }
			  else if (document.layers)
			  {
				// added qualifier (in case sent in bogus element id)
				if (document.layers[name]) 
				{	  
				  this.obj = document.layers[name];
				  this.style = document.layers[name];
				}
			  }
			}


			function repositionLayer() {	
				// get a handle for the referential image
				tmp = new getObj("imgKey_01");				
				x = findPosX(tmp.obj);
				y = findPosY(tmp.obj);	
				
				if(curVisibleLayerName) {				
					aryLayerObj[curVisibleLayerName] = setLyr(curVisibleLayerName);
				}
				
				positionLayers(1);
			}

						 
			function closeSubNav() {
				// hide previously visible layer, if necessary
				if(aryLayerObj[curVisibleLayerName]) aryLayerObj[curVisibleLayerName].style.visibility = 'hidden';
				
				// make note of the currently visible layer nolonger being visible
				curVisibleLayerName = null;
			}
			
						
			function findPosX(obj)
			{
//var str = '';
				var curleft = 0;
				if(obj) {
					if (obj.offsetParent)
					{
						while (obj.offsetParent)
						{
						
//str = str + " id:" + obj.id + ":";							
//str = str + " obj.offsetParent: " + obj.offsetParent;
//str = str + " obj.offsetLeft: " + obj.offsetLeft + "<br>";
					
							curleft += obj.offsetLeft;
							
 							// konqueror is not accounting any offset b/t final table & body objects.						
 							if(obj.id == 'my3rdTableUp' && obj.offsetLeft==0) {
								curleft += 10;		
							}
							obj = obj.offsetParent;
						}
					}
					else if (obj.x)
						curleft += obj.x;
				}	
//document.write(str);				
				return curleft;
			}
		

			function findPosY(obj)
			{	
//var str = '';				
				var curtop = 0;
				var objHeight = 0;
				if(obj) {
					if (obj.offsetParent)
					{
						while (obj.offsetParent)
						{	
//str = str + " id: " + obj.id;							
//str = str + " obj.offsetParent: " + obj.offsetParent;
//str = str + " obj.offsetTop: " + obj.offsetTop + "<br>";							
							curtop += obj.offsetTop; // + obj.offsetTop;
							// konqueror is not accounting any offset b/t final table & body objects.						
 							if(obj.id == 'my3rdTableUp' && obj.offsetLeft==0) {
								curtop += 10;		
							}
							obj = obj.offsetParent;
						}
					}
					else if (obj.y)
					{	
						curtop += obj.y;
					}
				}
//document.write(str);					
				// the height of the image we are referring off of is 20px
				return curtop + 20;
			}

			function php_strstr( haystack, needle, bool ) {
			    var pos = 0;
			
			    haystack += '';
			    pos = haystack.indexOf( needle );
			    if( pos == -1 ){
			        return false;
			    } else{
			        if( bool ){
			            return haystack.substr( 0, pos );
			        } else{
			            return haystack.slice( pos );
			        }
			    }
			}

				
			function setLyr(lyr)
			{	
		                if(!php_strstr(lyr,'subNav_function')) {
					var obj = new getObj(lyr);
					obj.style.top = y + 'px';			
					obj.style.left = x + 'px';
					return obj;
				}
			}

		
			function hideLayers() {
				// or, we do not have a browser capable of dealing with the sub-nav
				if(!DHTML) return;
				
				if(aryLayerName[mySection]) {	// we have a permanently highlighted nav layer (since we are on sub-page)				
					sectionKey = aryLayerName[mySection];
					Toggle(sectionKey, 'highlight');
					showSubNav('subNav_' + sectionKey);
				} else { // we don't have a permanently highlighted nav layer (since we are on home page)
					closeSubNav();
					//UnHighlightNav(oldTDObjNav);
					if(curVisibleImgKey) HighlightNav(curVisibleImgKey, 'off', '');
					//oldTDObjNav = null;
					curVisibleImgKey = null;
				}
			}
			
			
	   function doPopupAtoZOLD() {
		    winURL = 'http://www.pbs.org/cgi-registry/stationfinder/setallcookies.cgir?s=KUSM&address=/inav/sitesa2z/local.html';		
			winName = 'MontanaPBS : Schedule A to Z';
			newWindow = window.open(winURL, winName,'height=540,width=650,scrollbars=yes,status=no');
			newWindow.focus();
		}			
		
	function doPopupAtoZ() {
		var station = "KUSM";
		var url = "http://www.pbs.org/cgi-registry/stationfinder/setallcookies.cgir?s=" + station +
		"&address=/inav/sitesa2z/local.html";
		floater=window.open(url,"sitesa2z",'toolbar=0,location=0,directories=0,scrollbars=1,status=0,menubar=0,resizable=1,height=540,width=650') 
		floater.focus();
	} 	
	function doPopupDTV() {
		
		var url = "/Schedule/DTV/MultiChannel/";
		floater=window.open(url,"sitesa2zzz",'toolbar=0,location=0,directories=0,scrollbars=1,status=0,menubar=0,resizable=1,height=540,width=650') 
		floater.focus();
	} 
	
