/* this object is for creating the topNav. it stores a set of 'sections' - */
function objRootNav(){
	//sections and pages in the root nav.
	this.unselected_class = 'navItem';  //all have the same classes...
	this.selected_class = 'navItemSelected';
	this.sections = new Array();
	
	//adds a new section to the root_nav
	this.addSection = function(page_title,page_URL,css_class,sub_pages){
		//small hack - passes 'undefined' as the css_class param.
		var new_section = new objPage(page_title,page_URL,css_class,sub_pages);
		this.sections.push(new_section);
	}
	//displays the top nav
	this.displayNav = function(){
		nav_output = '';			
		for(var i=0;i<=this.sections.length -1;i++){
			if(this.isInSection(this.sections[i])){ //if current page...
				nav_output += "<li class=\""+ this.selected_class+"\">";
			}else{
				nav_output += "<li class=\""+ this.unselected_class+" "+this.sections[i].css_class+"\">";
			}
			nav_output += "<a  href=\""+ this.sections[i].page_URL+"\">";
			nav_output += this.sections[i].page_title;
			nav_output += "</a></li>";
		}
		document.write(nav_output);
	}
	
	//checks subpages to see ... (this function includes a workaround hack for the Intria nav)
	this.isInSection = function(item){			
		if(location.pathname.substr(1) == item.page_URL){ //if current page...
			isInSection = true;
		}else{ //else
			isInSection = false;
			if(item.page_title != "ABOUT"){//here is the hack for the Intria site - basically just SKIPS the 'about' pages...since the nav is redundant
			if(item.sub_pages != undefined){
				for(var i=0;i<=item.sub_pages.length -1;i++){ //is a subpage of this item
					if(location.pathname.substr(1) == item.sub_pages[i].page_URL){ //if current page...
						isInSection = true;
					}
				}
			}
			} //hack closed.
		}
		return isInSection;
	}
}

/* this object is for creating the subnavs. it stores a set of 'pages' - */
function objSection(page_title,page_URL){
	//section information (uses page object)
	this.section = new objPage(page_title,page_URL);
	
	//subpages
	this.unselected_class = 'sideNavItem';  //all have the same classes...
	this.selected_class = 'sideNavSelected';
	this.sub_pages = new Array();
	
	//add a subPage
	this.addSubPage = function(page_title,page_URL,css_class){					
		var new_page = new objPage(page_title,page_URL,css_class);
		this.sub_pages.push(new_page);					
	}
	
	//display all subPages
	this.displayNav = function(){
		nav_output = '';			
		for(var i=0;i<=this.sub_pages.length -1;i++){
			if(location.pathname.substr(1) == this.sub_pages[i].page_URL){ //if current page...
				nav_output += "<li class=\""+ this.selected_class+"\">";
			}else{
				nav_output += "<li class=\""+ this.unselected_class+"\">";
			}
			nav_output += "<a class=\""+this.sub_pages[i].css_class+"\" href=\""+ this.sub_pages[i].page_URL+"\">";
			nav_output += this.sub_pages[i].page_title;
			nav_output += "</a></li>";
		}
		document.write(nav_output);
	}
}

//any information about a specific page/nav item goes here...

function objPage(page_title,page_URL,css_class,sub_pages){
	this.page_title = page_title;
	this.page_URL = page_URL;
	this.css_class = css_class;
	this.sub_pages = sub_pages;
}