<!--

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										  //
//============================================================================================//



arrNavTemplate[2] =  "  <tr>"
arrNavTemplate[2] +=  "     <td valign=\"top\" style=\"background:url(images/interior_navitem.gif) no-repeat top left;\">"
arrNavTemplate[2] +=  "         <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"197\" style=\"##divStyle##\">"
arrNavTemplate[2] +=  "             <tr>"
arrNavTemplate[2] +=  "	                <td width=\"197\"  valign=\"top\" style=\"padding-left:28px; padding-top:1px;\"><a class=\"##navClass##\" href=\"##fileName##\">##pageTitle##</a></td>"
arrNavTemplate[2] +=  "             </tr>"
arrNavTemplate[2] +=  "         </table>"
arrNavTemplate[2] +=  "     </td>"
arrNavTemplate[2] +=  " </tr>"

//styles
arrNavClass[2] = "item"
arrNavClassOn[2] = "item_on"
//this is the style for the yellow divider line between 2nd level items
arrDivStyle[2] = "border-top:solid 1px #e7e1cb;"



//============================================================================================//
//============================================================================================//
// 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


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){
	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]
            
			thisNavString = thisNavString.replace("##pageTitle##", subNavTitle[thisCatIndex][i])
			thisNavString = thisNavString.replace("##fileName##", subNavFileName[thisCatIndex][i])
			
			if (openToNextLevel) {
				thisNavString = thisNavString.replace("##navClass##", arrNavClassOn[level]) 
			} else {
				thisNavString = thisNavString.replace("##navClass##", arrNavClass[level])
			}	
			
			//draw the yellow div line between 2nd levels
			if(level==2 && i>0){
			    thisNavString = thisNavString.replace("##divStyle##", 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]
	        }
        }
    }
}
//-->	
