<!--

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\" id=\"leftNav\">";
arrNavTemplate[2] += "    	<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" height=\"100%\">";
arrNavTemplate[2] += "          <tr>";
arrNavTemplate[2] += "              <td valign=\"top\" class=\"##navClass##\"><a href=\"##fileName##\">##pageTitle##</a></td>";
arrNavTemplate[2] += "</tr>";
arrNavTemplate[2] += "</table>";
arrNavTemplate[2] += "</td>";
arrNavTemplate[2] += "</tr>";

//styles
arrNavClass[2] = "secondLevelItemOff"
arrNavClassOn[2] = "secondLevelItemOn"

//third level nav template
arrNavTemplate[3] =  "<tr>";
arrNavTemplate[3] += "  <td class=\"##navClass##\"><a href=\"##fileName##\">##pageTitle##</a></td>";
arrNavTemplate[3] += "</tr>";

//styles
arrNavClass[3] = "thirdLevelItemOff"
arrNavClassOn[3] = "thirdLevelItemOn"


//============================================================================================//
//============================================================================================//
// 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) {
			
                myCounter =0
                arrItemName = new Array
                arrLastId = new Array
                for(w=0;w<subNavFileName[thisCatIndex].length;w++){
    	            
                    if(subNavInNav[thisCatIndex][w]!="0" && subNavParent[thisCatIndex][w]!="" && subNavId[thisCatIndex][i] == subNavParent[thisCatIndex][w]){
                        //build array of third levels that are children of current second level
                        arrItemName[myCounter] = subNavTitle[thisCatIndex][w]
                        arrLastId[myCounter] = subNavId[thisCatIndex][w]
                        myCounter +=1
    	                
                    } 
                }
               
                var lastItemName = arrItemName[arrItemName.length-1];
                var lastItemId = arrLastId[arrLastId.length-1];
                        
                       
			
				thisNavString = thisNavString.replace("##navClass##", arrNavClassOn[level]) 
			} else {
				thisNavString = thisNavString.replace("##navClass##", arrNavClass[level])
			}	
			
			//here we need to find the end of the child pages, and append the solid line to the bottom
			
		
            
            strFind = lastItemName + "</a></td>";
            strFind +="</tr>";       
    
	        strReplace =  lastItemName + "</a><!----></td>";
            strReplace +="</tr>";
            strReplace +="<tr>";
            strReplace +="	<td valign=\"top\"><img src=\"newImages/leftnavSectionOnBtm.gif\" height=\"1\" width=\"240\" /></td>";
            strReplace +="</tr>";
            
            
          
            
           
            if(typeof lastItemName != "undefined"){
                navStr = navStr.replace(strFind, strReplace);
            }
	               
		    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
				getSubs(subNavId[thisCatIndex][i], level+1)
				//add bottom row to 3rd levels
				if(level==3){
				    //navStr = navStr + thisSpecialString;
				} else {
				    //figure if has kiddies
				    hasKids = false;
				    //if id number occurs more than once, there must be kids
				    theCounter =0;
				    
				    for(var k=0;k<subNavFileName[thisCatIndex].length;k++){
				        if(subNavParent[thisCatIndex]!=""){
				            if(subNavId[thisCatIndex][i]==subNavParent[thisCatIndex][k] && subNavInNav[thisCatIndex][k] ==1){
				                theCounter +=1;
				            }
				        }
				    }
				    
				    if(theCounter>0){
				        hasKids = true;
				      
				    }
				    
				    
				    
				    if(!hasKids){
				        //alert(navStr);
				        strFinder = subNavTitle[thisCatIndex][i] +"</a></td></tr></table>";
                        strFinder += "</td>";
                        strFinder += "</tr>";
                        
                        strReplacer = subNavTitle[thisCatIndex][i] +"</a></td></tr></table>";
                        strReplacer += "    </td>";
                        strReplacer += "</tr><tr><td valign=\"top\" height=\"1\" width=\"240\"><img src=\"/newImages/leftnavSectionOnBtm.gif\" height=\"1\" width=\"240\"></td></tr>";
    		
				        navStr = navStr.replace(strFinder, strReplacer)
				    }
				}
			}else {
			    
			    //if(level==3){
			    //    navStr = navStr.replace("navOnBottom_on2.gif", "navOnBottom.gif")
			    //    
			    //}
			}	
		}
	}	
	
}

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]
	        }
        }
    }
}
//-->	