<!--

var arrNavTemplate = new Array
var arrNavClass = new Array
var arrNavClassOn = new Array
var arrDivStyle = new Array

//============================================================================================//
// Create templates for each level of navigation below. The index is the navigation level     //
// i.e. arrNavTemplate[2] is the html template for the 2nd level                              //
//																							  //
// dynamic variables are:																	  //
//			##fileName##	=	url to link to												  //
//			##pageTitle##	=	name to show in navigation									  //
//			##navClass##	=	CSS class to replace										  //
//============================================================================================//


//start with an index of 2
arrNavTemplate[2] ="<tr>";
arrNavTemplate[2] += "  <td valign=\"top\" bgcolor=\"#f7f2e5\" width=\"167\" height=\"1\"><img src=\"images/##divStyle##\" width=\"167\" height=\"1\"></td>";
arrNavTemplate[2] += "</tr>";
arrNavTemplate[2] +=  "<tr>";
arrNavTemplate[2] += "	<td valign=\"top\" width=\"167\">";
arrNavTemplate[2] += "		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"167\" class=\"##navClass##\">";
arrNavTemplate[2] += "      	<tr>";
arrNavTemplate[2] += "          	<td valign=\"top\"><img src=\"images/spacer.gif\" width=\"1\" height=\"9\" /></td>";
arrNavTemplate[2] += "          </tr>";
arrNavTemplate[2] += "          <tr>";
arrNavTemplate[2] += "              <td valign=\"top\" width=\"167\">";
arrNavTemplate[2] += "                  <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"167\">";
arrNavTemplate[2] += "              		<tr>";
arrNavTemplate[2] += "          				<td valign=\"top\" width=\"5\"><img src=\"images/spacer.gif\" width=\"5\" height=\"1\" /></td>";
arrNavTemplate[2] += "      					<td valign=\"top\" id=\"nav_arrow\" width=\"11\" style=\"padding-top:1px;\"><img src=\"images/##navClass##.gif\" width=\"11\" height=\"10\" /></td>";
arrNavTemplate[2] += "    						<td valign=\"top\" width=\"135\"><a href=\"##fileName##\">##pageTitle##</a></td>";
arrNavTemplate[2] += "    						<td valign=\"top\" width=\"16\"><img src=\"images/spacer.gif\" width=\"16\" height=\"1\" /></td>";
arrNavTemplate[2] += "    					</tr>";
arrNavTemplate[2] += "    				</table>";
arrNavTemplate[2] += "    			</td>";
arrNavTemplate[2] += "    		</tr>";
arrNavTemplate[2] += "    		<tr>";
arrNavTemplate[2] += "				<td valign=\"top\"><img src=\"images/spacer.gif\" width=\"1\" height=\"9\" /></td>";
arrNavTemplate[2] += "			</tr>";
arrNavTemplate[2] += "		</table>";
arrNavTemplate[2] += "	</td>";
arrNavTemplate[2] += "</tr>";


//2nd level styles
arrNavClass[2] = "lnav"
arrNavClassOn[2] = "lnav_on"
//this is the style for the divider line between 2nd level items
arrDivStyle[2] = "lnav_div.gif"


//third level nav template
arrNavTemplate[3] ="<tr>";
arrNavTemplate[3] +="	<td valign=\"top\" width=\"167\">";
arrNavTemplate[3] +="		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"167\" class=\"##navClass##\">";
arrNavTemplate[3] +="       	<tr>";
arrNavTemplate[3] +="           	<td valign=\"top\" width=\"20\"><img src=\"images/spacer.gif\" width=\"20\" height=\"1\" /></td>";
arrNavTemplate[3] +="               <td valign=\"top\" id=\"sub_bull\" width=\"6\" style=\"padding-top:5px;\"><img src=\"images/lnav_bull.gif\" width=\"6\" height=\"3\" /></td>";
arrNavTemplate[3] +="               <td valign=\"top\" width=\"131\"><a href=\"##fileName##\" class=\"##navClass##\">##pageTitle##</a></td>";
arrNavTemplate[3] +="           	<td valign=\"top\" width=\"11\"><img src=\"images/spacer.gif\" width=\"11\" height=\"1\" /></td>";
arrNavTemplate[3] += "      	</tr>";
arrNavTemplate[3] +="  		</table>";
arrNavTemplate[3] +="	</td>";
arrNavTemplate[3] +="</tr>";
arrNavTemplate[3] +=  "<tr>";
arrNavTemplate[3] += "	<td valign=\"top\" class=\"##navClass##\"><img src=\"images/spacer.gif\" width=\"1\" height=\"10\" /></td>";
arrNavTemplate[3] += "</tr>";
//styles
arrNavClass[3] = "sub"
arrNavClassOn[3] = "sub_on"

//fourth level nav template
//arrNavTemplate[4] =  "<tr>";
//arrNavTemplate[4] += "  <td valign=\"top\">";
//arrNavTemplate[4] += "      <div class=\"##navClass##\">";
//arrNavTemplate[4] +="      <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"265\">";
//arrNavTemplate[4] +="          <tr>";
//arrNavTemplate[4] +="              <td valign=\"top\" width=\"40\"><img src=\"/images/spacer.gif\" width=\"40\" height=\"1\"></td>";
//arrNavTemplate[4] +="              <td valign=\"middle\" width=\"7\" height=\"11\"><img src=\"/images/lnav_arrow.gif\" width=\"7\" height=\"7\"></td>";
//arrNavTemplate[4] +="              <td valign=\"top\" width=\"178\" height=\"11\"><a class=\"##navClass##\" href=\"##fileName##\">##pageTitle##</a></td>";
//arrNavTemplate[4] +="              <td valign=\"top\" width=\"40\"><img src=\"/images/spacer.gif\" width=\"40\" height=\"1\"></td>";
//arrNavTemplate[4] +="          </tr>";
//arrNavTemplate[4] +="      </table>";
//arrNavTemplate[4] += "      </div>";
//arrNavTemplate[4] +="  </td>";
//arrNavTemplate[4] +="</tr>";
//arrNavTemplate[4] +="<tr>";
//arrNavTemplate[4] +="  <td valign=\"top\" width=\"265\" height=\"6\"><img src=\"/images/spacer.gif\" width=\"265\" height=\"6\"></td>";
//arrNavTemplate[4] +="</tr>";
//styles
//arrNavClass[4] = "fourth"
//arrNavClassOn[4] = "fourth_on"


//============================================================================================//
//============================================================================================//
// DO NOT EDIT BELOW THIS LINE UNLESS YOU INTEND ON CHANGING FUNCTIONALITY					  //
//============================================================================================//
//============================================================================================//


//testing variables
//thisCatIndex = 2
//thisFileName = "services-jri-health-services-lev-3-one-4-3.asp"
//end testing variables

pageFound = false
isTopLevelPage = false
navParent = ""
navLevel = 2
navStr = ""
strPagePath = ""
var arrPagePath = new Array

//hard coded for press release pages navigation
if (isPressPage){
	thisFileName = "News-Events.asp"
	thisCatIndex = 4
}	

if (typeof thisCatIndex != "undefined"){

	//see if this is a top level landing page (ie About, Services, etc). If so we are only showing the second level
	//for that section. no need to look for 3rd, 4th, etc...
	
	for(var i=0; i<mainNavFileName.length; i++){
		if (thisFileName == mainNavFileName[i].toLowerCase()){
			isTopLevelPage = true
		}
	}

	if (typeof subNavFileName[thisCatIndex] != "undefined"){
		//get the path of the current page from the parent level
		strPagePath = getPagePath()
		if (strPagePath != ""){
			arrPagePath = strPagePath.split("/")
		}
		
		//get the sub navigation for this top level
		getSubs(navParent, navLevel)
	}
}	
//======================================//
//		write out the navigation		//
//======================================//	
//document.write(navStr)





 
function getSubs(thisParent, level){
var navLevels = 3
	for(var i=0;i<subNavFileName[thisCatIndex].length;i++){
		openToNextLevel = false
		
		if (subNavInNav[thisCatIndex][i] != "0" && subNavParent[thisCatIndex][i] == thisParent){
			//check to see if the page we are looking at is in the page path
			for (var j=0;j<arrPagePath.length;j++){
				if (arrPagePath[j].toLowerCase() == subNavFileName[thisCatIndex][i].toLowerCase()){
					openToNextLevel = true
				}	
			}
		
			//get html template for this level and write out navigation HTML
			thisNavString = arrNavTemplate[level]
            
            
            //CO2 in left nav cuases line-height issues...which of course differ in ff and ie
            if(subNavTitle[thisCatIndex][i].indexOf("CO2") != -1){
			    thisNavString = thisNavString.replace("<td valign=\"top\" id=\"nav_arrow\" width=\"11\" style=\"padding-top:1px;\">", "<td valign=\"top\" id=\"nav_arrow\" width=\"11\" style=\"padding-top:3px;\">");
			    thisNavString = thisNavString.replace("<td valign=\"top\" id=\"sub_bull\" width=\"6\" style=\"padding-top:5px;\">", "<td valign=\"top\" id=\"sub_bull\" width=\"6\" style=\"padding-top:8px;vertical-align:top;line-height:12px;\">");
			}
			//replace CO2 with CO<sub>2</sub>
			thisNavString = thisNavString.replace("##pageTitle##", subNavTitle[thisCatIndex][i].replace(/CO2/g, "CO<sub style=\"vertical-align:bottom;font-size:8px;padding:0px;margin:0px;\">2</sub>"));
			
			thisNavString = thisNavString.replace("##fileName##", subNavFileName[thisCatIndex][i])
			
			//alert(thisNavString);
			
			if (openToNextLevel) {
				thisNavString = thisNavString.replace(/##navClass##/g, arrNavClassOn[level]) 
			} else {
				thisNavString = thisNavString.replace(/##navClass##/g, arrNavClass[level])
			}	
			
			//draw the div line between 2nd levels
	
			if(level==2 && i>0){
			    thisNavString = thisNavString.replace(/##divStyle##/g, arrDivStyle[level]);
			}

			navStr += thisNavString
			
			// if this isn't a top level landing page and this page is at least one level deeper then get children
			if (!isTopLevelPage && openToNextLevel){
				//get next level
				if (level < navLevels){
					getSubs(subNavId[thisCatIndex][i], level+1)
				}	
				
			}	
			
			
		}
	}	
	
}

function getPagePath(){
	pageFile = ""
	strPagePath = ""
	for(var i=0;i<subNavFileName[thisCatIndex].length;i++){
		if (thisFileName == subNavFileName[thisCatIndex][i].toLowerCase()){
			pageFile = subNavFileName[thisCatIndex][i]
			strPagePath = pageFile
		}
	}
	safety = 0	//used to stop runaway loop. never more than 10 levels of nav
	while(pageFile != "" && safety < 10){
		pageFile = getParent(pageFile)	
		if (pageFile != ""){
			strPagePath = pageFile + "/" + strPagePath
		}
		safety += 1
	}
	return strPagePath
}

//returns the parent file name of a given navigation file
function getParent(whichPageFile){
	var thisParentId = -1
	strParentFileName = ""
	//get parentId
	for(var i=0;i<subNavFileName[thisCatIndex].length;i++){
		if (whichPageFile.toLowerCase() == subNavFileName[thisCatIndex][i].toLowerCase()){
			thisParentId = subNavParent[thisCatIndex][i]
		}
	}	
	//now get parent
	if (thisParentId != -1){
		for(var i=0;i<subNavFileName[thisCatIndex].length;i++){
			if (thisParentId == subNavId[thisCatIndex][i].toLowerCase()){
				strParentFileName = subNavFileName[thisCatIndex][i]
			}
		}
	}		
	
	return strParentFileName
}




function stripHTML(strHTML){
    var re = new RegExp;
    re = /<(.|\n)+?>/gi;
    return strHTML.replace(re, "");
    return strHTML
						
}
function getPageTitle(){
    found = false
	
    //first check main navs
    if (typeof mainNavFileName != "undefined"){
        for(i=0;i<mainNavFileName.length;i++){
	        if (thisFileName == mainNavFileName[i].toLowerCase()) {
		        found = true
		        return stripHTML(mainNavTitle[i])
	        }
	        if (found){
		        break;
	        }	
        }
    }	
    //if not found, check sub nav's
    if (!found){
        if (typeof subNavFileName != "undefined"){
	        for(i=0;i<mainNavFileName.length;i++){
		        for(j=0;j<subNavFileName[i].length;j++){
										
			        if (thisFileName == subNavFileName[i][j].toLowerCase()) {
				        found = true
				        foundIndex = i
				        return stripHTML(subNavTitle[i][j])
				        break
			        }
					
		        }
		        if (found){
			        break
		        }	
	        }
        }
    }
}
//reset these variables from swNavigationPages to take querystrings into account
var thisPrimaryNav = ''
var thisParentId = ''
var thisPageId = ''
thisPage=document.URL
//figure out what category we are in
thisCatIndex = -1
arrThisPage = thisPage.split("/")
thisFileName = arrThisPage[arrThisPage.length -1]
thisFileName = thisFileName.toLowerCase()
if (thisFileName.indexOf('?') != -1){	//there is a querystring
    arrThisFileName = thisFileName.split("?")
    thisFileName = arrThisFileName[0]
}
//first check main nav's
for (i=0;i<mainNavFileName.length;i++){
    currentFileName = mainNavFileName[i]
    currentFileName = currentFileName.toLowerCase()
    if(thisFileName == currentFileName){
        thisCatIndex = i
        thisPrimaryNav = currentFileName
    }
    //now check sub nav's
    for (j=0;j<subNavFileName[i].length;j++){
        currentFileName = subNavFileName[i][j]
        if (typeof currentFileName != 'undefined'){
	        currentFileName = currentFileName.toLowerCase()
	        if(thisFileName == currentFileName){
		        thisCatIndex = i	
		        thisPrimaryNav = mainNavFileName[i]
		        thisParentId = subNavParent[i][j]
		        thisPageId = subNavId[i][j]
		        thisPageTitle = subNavTitle[i][j]
	        }
        }
    }
}
//-->	
