// JavaScript Document

	 
	       function addListeners(eventObject) {
	  // alert(eventObject.type + " just got fired. \n It was fired by " + eventObject.target); uncomment to see event happening
	
	
	clearPage();
	
	//var wtf = readCookie('tmodLoc')
	//if (wtf) {
	//	showContent(readCookie('tmodLoc'));
	//} else {
	
		if(location.hash!="") {
			loc = location.hash;
			
			showContent(loc.substring(1,loc.length));
		} else {
			showContent("main");
		}

		 	
//	}

	  }
	  

      function addEvent(elm, evType, fn, useCapture) 
      // cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
      // By Scott Andrew modified by Veronica Noone
      {
        if (elm.addEventListener) {  
		//if browser supports the w3c spec that call 
          elm.addEventListener(evType, fn, useCapture); 
		  //for the load it becomes  window.addEventListener('load', addListeners, false); 
		  //for the keyup it becomes textarea.addEventListener('keyup', aKeyWasPressed, false); 
          return true; 
        } else if (elm.attachEvent) {
		//if IE's attacheEvent is supported then use that
		  var evType = "on" + evType; //add "on" to event i.e. onload instead of load
          elm.attachEvent(evType, fn); 
		//  return r;  //returns elm.attachEvent(onwhatever, addListeners) and makes the call
        } else {
		//if the browser doesn't support either - assign the event listener to the element using onwhatever (replaces any other event handlers that were attached
          elm['on' + evType] = fn; //window.onwhatever = addListeners;
        }
      }
	 
	 
	  function clearPage(){
		 //initialize page
		 
		 //set up array to hold content areas
		 //could loop... this was easier in a pinch
		  content = new Array();
			content[0] = "SubNav1";
			content[1] = "SubNav2";
			content[2] = "SubNav3";
			content[3] = "SubNav4";
			content[4] = "SubNav5";
			content[5] = "SubNav6";
			content[6] = "SubNav7";
			content[7] = "SubNav8";
			content[8] = "SubNav9";
			content[9] = "SubNav10";
			content[10] = "SubNav11";
			content[11] = "SubNav12";
			content[12] = "main";
			content[13] = "SubSubNav1";
			content[14] = "SubSubNav2";
			content[15] = "SubSubNav3";
			content[16] = "SubSubNav4";

		//loop through and hide them all
		for(i=0;i<content.length;i++){
		//alert(content[i]);
		document.getElementById(content[i]).style.display = 'none';
		}
		
	  }
	  
	  function showContent(s){
		  clearPage();
		  //alert(s);
		  document.getElementById(s).style.display = 'block';
			// alert("create cookie");
			//createCookie('tmodLoc',s,1);
	  }
	  
	  
	  
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

	  
	 
	
	  
	 addEvent(window, 'load', addListeners, false); //Call the addEvent function passing parameters for addEventListener function
