<!--

var arrNavTemplate = new Array
var arrNavClass = new Array
var arrNavClassOn = new Array
var arrDivStyle = new Array
var arrNavBottomClass = new Array
var arrNavBottomClassOn = new Array
var arrBulletClass = new Array
var arrBulletClassOn = new Array
var arrLeftCornerClass = new Array
var arrLeftCornerClassOn = new Array
var arrLeftTileClass = new Array
var arrLeftTileClassOn = new Array
var arrArrowClass = new Array
var arrArrowClassOn = 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 id=\"2rowstart\">";
arrNavTemplate[2] += "    <td valign=\"top\" align=\"right\">";
arrNavTemplate[2] += "    	<table border=\"0\" width=\"235\" cellpadding=\"0\" cellspacing=\"0\">";
arrNavTemplate[2] += "          <tr>";
arrNavTemplate[2] += "              <td width=\"223\" valign=\"top\" >";
arrNavTemplate[2] += "              	<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"##navClass##\">";
arrNavTemplate[2] += "              		<tr>";
arrNavTemplate[2] += "              			<td valign=\"top\">";
arrNavTemplate[2] += "              				<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
arrNavTemplate[2] += "              					<tr>";
arrNavTemplate[2] += "              						<td valign=\"top\" height=\"100%\">";
arrNavTemplate[2] += "              							<table border=\"0\" height=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background: url(images/##navLeftTileClass##.gif); background-repeat: repeat-y;\">";
arrNavTemplate[2] += "              								<tr>";
arrNavTemplate[2] += "              									<td valign=\"top\"><img src=\"images/##navBulletClass##.gif\" width=\"15\" height=\"10\"></td>";
arrNavTemplate[2] += "              								</tr>";
arrNavTemplate[2] += "              								<tr>";
arrNavTemplate[2] += "              									<td valign=\"top\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\"></td>";
arrNavTemplate[2] += "              								</tr>";
arrNavTemplate[2] += "              								<tr>";
arrNavTemplate[2] += "              									<td valign=\"bottom\"><img src=\"images/##navLeftCornerClass##.gif\" height=\"7\" width=\"6\"></td>";
arrNavTemplate[2] += "              								</tr>";
arrNavTemplate[2] += "              							</table>";
arrNavTemplate[2] += "              						</td>";
arrNavTemplate[2] += "              						<td valign=\"middle\" style=\"padding-left: 4px;\"><a href=\"##fileName##\">##pageTitle##</a></td>";
arrNavTemplate[2] += "              					</tr>";
arrNavTemplate[2] += "              				</table>";
arrNavTemplate[2] += "              			</td>";
arrNavTemplate[2] += "              		</tr>";
arrNavTemplate[2] += "              		<tr>";
arrNavTemplate[2] += "              			<td valign=\"top\"><img border=\"0\" src=\"\/images\/##navBottomClass##.gif\"></td>";
arrNavTemplate[2] += "              		</tr>";
arrNavTemplate[2] += "              	</table>";
arrNavTemplate[2] += "    			<td width=\"12\" valign=\"top\"><img src=\"images/##navArrowClass##.gif\" width=\"12\" height=\"21\"></td>";
arrNavTemplate[2] += "			</tr>";
arrNavTemplate[2] += "		</table>";
arrNavTemplate[2] += "	</td>";
arrNavTemplate[2] += "</tr>";

//styles
arrNavClass[2] = "leftNav"
arrNavClassOn[2] = "leftNavOn"
arrNavBottomClass[2] = "navOnBottom"
arrNavBottomClassOn[2] = "navOnBottom_On2"
arrBulletClass[2] = "list_item-off"
arrBulletClassOn[2] = "list_item-on"
arrLeftCornerClass[2] = "leftnav_corner-off"
arrLeftCornerClassOn[2] = "leftnav_corner-on"
arrLeftTileClass[2] = "leftnav_left_tile-off"
arrLeftTileClassOn[2] = "leftnav_left_tile-on"
arrArrowClass[2] = "navOnRight-off"
arrArrowClassOn[2] = "navOnRight-on"



//third level nav template
arrNavTemplate[3] =  "<tr>";
arrNavTemplate[3] += "  <td valign=\"top\" style=\"padding-left: 31px;\">";
arrNavTemplate[3] += "      <div class=\"thirdNavDiv\">";
arrNavTemplate[3] +="           <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"187\">";
arrNavTemplate[3] +="               <tr>";
arrNavTemplate[3] +="                   <td valign=\"top\" width=\"13\"><img src=\"/images/spacer.gif\" width=\"13\" height=\"1\"></td>";
arrNavTemplate[3] +="                   <td valign=\"top\" style=\"padding-top: 5px;\"width=\"11\"><img src=\"/images/lnav_arrow.gif\" width=\"6\" height=\"5\"></td>";
arrNavTemplate[3] +="                   <td valign=\"top\" width=\"\"><a class=\"##navClass##\" href=\"##fileName##\">##pageTitle##</a></td>";
arrNavTemplate[3] +="                   <td valign=\"top\" width=\"7\"><img src=\"/images/spacer.gif\" width=\"7\" height=\"1\"></td>";
arrNavTemplate[3] +="               </tr>";
arrNavTemplate[3] +="               <tr>";
arrNavTemplate[3] +="                   <td valign=\"top\" colspan=\"4\"><img src=\"/images/spacer.gif\" width=\"13\" height=\"4\"></td>";
arrNavTemplate[3] +="               </tr>";
arrNavTemplate[3] +="           </table>";
arrNavTemplate[3] += "      </div>";
arrNavTemplate[3] +="  </td>";
arrNavTemplate[3] +="</tr>";

//styles
arrNavClass[3] = "third"
arrNavClassOn[3] = "third_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


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]) 
				thisNavString = thisNavString.replace("##navBottomClass##", arrNavBottomClassOn[2])
				thisNavString = thisNavString.replace("##navBulletClass##", arrBulletClassOn[2])
				thisNavString = thisNavString.replace("##navLeftCornerClass##", arrLeftCornerClassOn[2])
				thisNavString = thisNavString.replace("##navLeftTileClass##", arrLeftTileClassOn[2])
				thisNavString = thisNavString.replace("##navArrowClass##", arrArrowClassOn[2])
			} else {
				thisNavString = thisNavString.replace("##navClass##", arrNavClass[level])
				thisNavString = thisNavString.replace("##navBottomClass##", "navOffBottom")
				thisNavString = thisNavString.replace("##navBulletClass##", arrBulletClass[2])
				thisNavString = thisNavString.replace("##navLeftCornerClass##", arrLeftCornerClass[2])
				thisNavString = thisNavString.replace("##navLeftTileClass##",arrLeftTileClass[2])
				thisNavString = thisNavString.replace("##navArrowClass##", arrArrowClass[2])
			}	
			
			
			thisNavString = thisNavString.replace("##navBottomClass##", arrNavBottomClass[2])
			
			
			//here we need to find the end of the child pages, and append the curved line to the bottom
			//biggest hack in the hstory of the planet. i hate myself
			
            var lastItemNum = subNavFileName[thisCatIndex].length -1
            
		    lastItem = subNavTitle[thisCatIndex][lastItemNum];
		    lastItemFileName = subNavFileName[thisCatIndex][lastItemNum];
		    
            strFind = lastItem + "</a></td>";
            strFind +="                   <td valign=\"top\" width=\"7\"><img src=\"/images/spacer.gif\" width=\"7\" height=\"1\"></td>";
            strFind +="               </tr>";
            strFind +="               <tr>";
            strFind +="                   <td valign=\"top\" colspan=\"4\"><img src=\"/images/spacer.gif\" width=\"13\" height=\"4\"></td>";
            strFind +="               </tr>";
            strFind +="           </table>";
            strFind += "      </div>";
            strFind +="  </td>";
            strFind +="</tr>";
            
            strFind2 = "               <tr>";
            strFind2 +="                   <td valign=\"top\" colspan=\"4\"><img src=\"/images/spacer.gif\" width=\"13\" height=\"4\"></td>";
            strFind2 +="               </tr>";
            strFind2 +="           </table>";
            strFind2 +="      </div>";
            strFind2 +="  </td>";
            strFind2 +="</tr>";
            strFind2 +="<tr id=\"2rowstart\">";
            
            strReplace2 = "               <tr>";
            strReplace2 +="                   <td valign=\"top\" colspan=\"4\"><img src=\"/images/spacer.gif\" width=\"13\" height=\"4\"></td>";
            strReplace2 +="               </tr>";
            strReplace2 +="           </table>";
            strReplace2 +="      </div>";
            strReplace2 +="  </td>";
            strReplace2 +="</tr>";
            strReplace2 += "<tr><td valign=\"top\" style=\"padding-left:31px;\"><img border=0 src=\"/images/testbtm.gif\" width=\"187\" height=\"4\"></td></tr>";
            strReplace2 +="<tr id=\"2rowstart\">";
            
    
			strReplace =  lastItem + "</a></td>";
            strReplace +="                   <td valign=\"top\" width=\"7\"><img src=\"/images/spacer.gif\" width=\"7\" height=\"1\"></td>";
            strReplace +="               </tr>";
            strReplace +="               <tr>";
            strReplace +="                   <td valign=\"top\" colspan=\"4\"><img src=\"/images/spacer.gif\" width=\"13\" height=\"4\"></td>";
            strReplace +="               </tr>";
            strReplace +="           </table>";
            strReplace += "      </div>";
            strReplace +="  </td>";
            strReplace +="</tr>";
            strReplace += "<tr><td valign=\"top\" style=\"padding-left:31px;\"><img border=0 src=\"/images/testbtm.gif\" width=\"187\" height=\"4\"></td></tr>";
           	navStr += thisNavString;
           
		    if(subNavParent[thisCatIndex][lastItemNum] == subNavParent[thisCatIndex][i] && subNavId[thisCatIndex][i] == subNavId[thisCatIndex][lastItemNum]){
		        navStr = navStr.replace(strFind, strReplace);
		    }
			
			if(navStr.indexOf(strFind2)!=-1){
			    navStr = navStr.replace(strFind2, strReplace2);
			}
			
		
		
			// 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){
				        navStr = navStr.replace(/navOnBottom_On2.gif/g, "navOnBottom.gif")
				    }
				}
			}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]
	        }
        }
    }
}
//-->	