<!--

function doRedirect(id){
    //alert(id);
    location.replace(id);
    
}


var arrNavTemplate = new Array
var arrNavClass = new Array
var arrNavClassOn = new Array
var arrDivStyle = new Array
var arrNavBGOff = new Array
var arrNavBGOffOn = new Array
var arrNavBGOn = new Array
var arrNavBGOnOn = new Array
var arrLeftNav_leftShadow = new Array
var arrLeftNav_leftShadowOn = new Array
var arrLeftNav_rightShadow = new Array
var arrLeftNav_rightShadowOn = new Array
var arrLeftNav_topShadow = new Array
var arrLeftNav_topShadowOn = new Array
var arrLeftNav_btmShadow = new Array
var arrLeftNav_btmShadowOn = 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 width=\"257\" id=\"topLevitemID\" valign=\"top\" class=\"##navClass##\" onMouseOver=\"document.getElementById('topLevitemID').style.backgroundColor='##BGCLASS##';this.style.cursor='pointer';\" onMouseOut=\"document.getElementById('topLevitemID').style.backgroundColor='##BGCLASS##';this.style.cursor='auto';\">"
arrNavTemplate[2] +=  "			<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"257\" onClick=\"doRedirect('linkID');\">"
arrNavTemplate[2] +=  "				<tr>"
arrNavTemplate[2] +=  "					<td id=\"leftNavTopShadowitemID\" class=\"##leftNav_topShadow##\" onMouseOver=\"setOpacity(3,itemID);\" onMouseOut=\"setOpacity(10,itemID);\"><img src=\"images/spacer.gif\" width=\"258\" height=\"4\" border=\"0\" /></td>"
arrNavTemplate[2] +=  "				</tr>"
arrNavTemplate[2] +=  "				<tr>"
arrNavTemplate[2] +=  "					<td valign=\"top\">"
arrNavTemplate[2] +=  "						<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"257\">"
arrNavTemplate[2] +=  "							<tr>"
arrNavTemplate[2] +=  "								<td width=\"5\" id=\"leftNavLeftShadowitemID\" class=\"##leftNav_leftShadow##\" onMouseOver=\"setOpacity(3, itemID);\" onMouseOut=\"setOpacity(10,itemID);\"><img src=\"images/spacer.gif\" width=\"5\" height=\"21\" border=\"0\" /></td>"
arrNavTemplate[2] +=  "								<td width=\"247\" id=\"leftNavLinkAreaitemID\" onMouseOver=\"setOpacity(3, itemID);\" onMouseOut=\"setOpacity(10, itemID);\">"
arrNavTemplate[2] +=  "									<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"248\">"
arrNavTemplate[2] +=  "										<tr>"
arrNavTemplate[2] +=  "											<td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:2px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td>"
arrNavTemplate[2] +=  "										</tr>"
arrNavTemplate[2] +=  "									</table>"
arrNavTemplate[2] +=  "								</td>"
arrNavTemplate[2] +=  "								<td width=\"5\" id=\"leftNavRightShadowitemID\" class=\"##leftNav_rightShadow##\" onMouseOver=\"setOpacity(3, itemID);\" onMouseOut=\"setOpacity(10, itemID);\"><img src=\"images/spacer.gif\" width=\"5\" height=\"21\" border=\"0\" /></td>"
arrNavTemplate[2] +=  "							</tr>"
arrNavTemplate[2] +=  "						</table>"
arrNavTemplate[2] +=  "					</td>"
arrNavTemplate[2] +=  "				</tr>"
arrNavTemplate[2] +=  "				<tr>"
arrNavTemplate[2] +=  "					<td id=\"leftNavBtmShadowitemID\" class=\"##leftNav_btmShadow##\" onMouseOver=\"setOpacity(3, itemID);\" onMouseOut=\"setOpacity(10, itemID);\"></td>"
arrNavTemplate[2] +=  "				</tr>"
arrNavTemplate[2] +=  "			</table>"
arrNavTemplate[2] +=  "		</td>"
arrNavTemplate[2] +=  "	</tr>"



//styles
arrNavClass[2] = "leftNavItem"
arrNavClassOn[2] = "leftNavItem_On"

//over bgcolor on the OFF items
arrNavBGOff[2] = "#f1f1f1"
//over bgcolor on the ON items
arrNavBGOffOn[2] = "#ffffff"
//out bgcolor on off items
arrNavBGOn[2] = "#e7e7e7"
//out bgccolor on ON items
arrNavBGOnOn[2] = "#ffffff" 

//leftshadow states
arrLeftNav_leftShadow[2] = "leftNav_leftShadow"
arrLeftNav_leftShadowOn[2] = "leftNav_leftShadowOn"

//rightshadow states
arrLeftNav_rightShadow[2] = "leftNav_rightShadow"
arrLeftNav_rightShadowOn[2] = "leftNav_rightShadowOn"

//topshadow states
arrLeftNav_topShadow[2] = "leftNav_topShadow"
arrLeftNav_topShadowOn[2] = "leftNav_topShadowOn"

//bottomshadow states
arrLeftNav_btmShadow[2] = "leftNav_btmShadow"
arrLeftNav_btmShadowOn[2] = "leftNav_btmShadowOn"

//third level nav template
arrNavTemplate[3] =  "<tr>"
arrNavTemplate[3] += "	<td class=\"##navClass##\"><a href=\"##fileName##\">##pageTitle##</a></td>"
arrNavTemplate[3] += "</tr>"

//styles
arrNavClass[3] = "thirdLevelItem"
arrNavClassOn[3] = "thirdLevelItem_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




//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]
	        }
        }
    }
}





pageFound = false
isTopLevelPage = false
navParent = ""
navLevel = 2
navLevels = 4
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]
            
            strTopRow = "				<tr>";
            strTopRow +=  "					<td id=\"leftNavTopShadow" + subNavId[thisCatIndex][i] + "\" class=\"##leftNav_topShadow##\" onMouseOver=\"setOpacity(3," + subNavId[thisCatIndex][i] + ");\" onMouseOut=\"setOpacity(10," + subNavId[thisCatIndex][i] + ");\"><img src=\"images/spacer.gif\" width=\"258\" height=\"4\" border=\"0\" /></td>";
            strTopRow +=  "				</tr>";

            strSpacer= "			<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"257\" onClick=\"doRedirect('linkID');\">"
            strSpacerReplacer = strSpacer + "				<tr>"
            strSpacerReplacer += "					<td height=\"3\" style=\"background-color: #ffffff;\"><img src=\"\/images\/spacer.gif\" width=\"1\" height=\"3\"></td>"
            strSpacerReplacer += "				</tr>"
            
            strEmpty = "";
            
           
            //if top level and not the first top level
            
            if(subNavParent[thisCatIndex][i]== ""){
                
                //otherwise, loop through left nav array, build new array of second levels, and in nav
                myCounter =0
                arrId = new Array
	            for(w=0;w<subNavFileName[thisCatIndex].length;w++){
	                //alert(subNavTitle[thisCatIndex][s] + "\n" + s);
	                if(subNavInNav[thisCatIndex][w]==1 && subNavParent[thisCatIndex][w]==""){
	                    arrId[myCounter] = subNavId[thisCatIndex][w]
	                    myCounter +=1
	                }
	            }
	            //id of first item in second level nav
                var firstId = (arrId[0]).toLowerCase();
                
                strTopRow =  "				<tr>"
                strTopRow +=  "					<td id=\"leftNavTopShadowitemID\" class=\"##leftNav_topShadow##\" onMouseOver=\"setOpacity(3,itemID);\" onMouseOut=\"setOpacity(10,itemID);\"><img src=\"images/spacer.gif\" width=\"258\" height=\"4\" border=\"0\" /></td>"
                strTopRow +=  "				</tr>"
                
                if(subNavId[thisCatIndex][i] != firstId){   
		            thisNavString = thisNavString.replace(strSpacer, strSpacerReplacer);
		        } else {
		             //for very first item, the large white space gets replaced by nothing, the top shadow also gets removed
		            thisNavString = thisNavString.replace(strTopRow, strEmpty);
		        }
		        
			} 
            
            //add padding to top item when top item is on (shadow has been removed)
            myCounter =0
            arrFileName = new Array
	        for(w=0;w<subNavFileName[thisCatIndex].length;w++){
	            //alert(subNavTitle[thisCatIndex][s] + "\n" + s);
	            if(subNavInNav[thisCatIndex][w]==1 && subNavParent[thisCatIndex][w]==""){
	                arrFileName[myCounter] = subNavFileName[thisCatIndex][w]
	                myCounter +=1
	            }
	        }
	        //filename of last second level item in left nav
            var firstFileName = (arrFileName[0]).toLowerCase();
            var lastFileName = (arrFileName[arrFileName.length-1]).toLowerCase();
            
            //goddamn you matt and your freaky button states
            if(firstFileName==subNavFileName[thisCatIndex][i].toLowerCase()){
                //alert("do something");
                //first one
                //pad top
                strFindString = "										<tr>"
			    strFindString +="											<td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:2px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td>"
			    strFindString +=  "										</tr>"
			    
			    strReplaceString = "										<tr>"
			    strReplaceString +="											<td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:5px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td>"
			    strReplaceString +=  "										</tr>"
			    
			    thisNavString  = thisNavString.replace(strFindString, strReplaceString);
                
            }
            
            //adjust spacing for first and last items
            if(thisFileName==firstFileName && thisFileName==subNavFileName[thisCatIndex][i].toLowerCase()){
                
                strFinder = "										<tr>"
			    strFinder +="											<td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:2px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td>"
			    strFinder +=  "										</tr>"
			    
			    strReplacer = "<tr><td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:0px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td></tr>"
    
			    thisNavString  = thisNavString.replace(strFinder, strReplacer);
                
            } else {
			    //(last item)
			    strFinder = "										<tr>"
			    strFinder +="											<td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:2px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td>"
			    strFinder +=  "										</tr>"
			    
			    strReplacer = "<tr><td width=\"248\" valign=\"top\" align=\"left\" id=\"linkcontaineritemID\" style=\"padding-left: 12px;padding-right: 8px;padding-top:2px;\"><a href=\"##fileName##\" id=\"leftNavBoxLinkitemID\">##pageTitle##</a></td></tr>"
			    strReplacer += "<tr><td valign=\"top\"><img src=\"\/images\/spacer.gif\" width=\"1\" height=\"3\"></td></tr>"
			    
			    
			    thisNavString  = thisNavString.replace(strFinder, strReplacer);
			}
			
            
			thisNavString = thisNavString.replace("##pageTitle##", subNavTitle[thisCatIndex][i]);
			thisNavString = thisNavString.replace("##fileName##", subNavFileName[thisCatIndex][i]);
			thisNavString = thisNavString.replace(/itemID/g, subNavId[thisCatIndex][i]);
			thisNavString = thisNavString.replace(/linkID/g, subNavFileName[thisCatIndex][i]);
			
			
			if (openToNextLevel) {
				thisNavString = thisNavString.replace("##navClass##", arrNavClassOn[level]);
				thisNavString = thisNavString.replace("##leftNav_leftShadow##", arrLeftNav_leftShadowOn[level]);
				thisNavString = thisNavString.replace("##leftNav_rightShadow##", arrLeftNav_rightShadowOn[level]);
				
				//if not the first item, add the shadow to the top of the item
				if(i>0){
				    thisNavString = thisNavString.replace("##leftNav_topShadow##", arrLeftNav_topShadowOn[level]);
				}
				thisNavString = thisNavString.replace("##leftNav_btmShadow##", arrLeftNav_btmShadowOn[level]);
				thisNavString = thisNavString.replace("##BGCLASS##", arrNavBGOffOn[level]);
				thisNavString = thisNavString.replace("##BGCLASS##", arrNavBGOnOn[level]);
			} else {
				thisNavString = thisNavString.replace("##navClass##", arrNavClass[level]);
				thisNavString = thisNavString.replace("##leftNav_leftShadow##", arrLeftNav_leftShadow[level]);
				thisNavString = thisNavString.replace("##leftNav_rightShadow##", arrLeftNav_rightShadow[level]);
				//if not the first item, add the shadow to the top of the item
				if(i>0){
				    thisNavString = thisNavString.replace("##leftNav_topShadow##", arrLeftNav_topShadow[level]);
				}
				thisNavString = thisNavString.replace("##leftNav_btmShadow##", arrLeftNav_btmShadow[level]);
				thisNavString = thisNavString.replace("##BGCLASS##", arrNavBGOff[level]);
				thisNavString = thisNavString.replace("##BGCLASS##", arrNavBGOn[level]);
			}	
			
			//third level information
            var lastItemNum = subNavFileName[thisCatIndex].length -1
            
		    lastItem = subNavTitle[thisCatIndex][lastItemNum];
		    lastItemFileName = subNavFileName[thisCatIndex][lastItemNum];
		   
            strFind = lastItem + "</a></td>";
            strFind +="</tr>";
            
        
            //this will add 4 pixels to the bottom of a third level set
			strReplace =  lastItem + "</a></td>";
            strReplace +="            </tr>";
            strReplace +="			  <tr><td valign=\"top\"><img src=\"images/spacer.gif\" border=\"0\" height=\"4\"></td></tr>";
			
		    //remove bottom shadow of bottom nav item
		    //first find id of last item in second level (in nav also)
		    myCounter=0;
		    arrIds = new Array;
		    for(s=0;s<subNavFileName[thisCatIndex].length;s++){
		        //alert(subNavTitle[thisCatIndex][s] + "\n" + s);
		        if(subNavInNav[thisCatIndex][s]==1 && subNavParent[thisCatIndex][s]==""){
		            arrIds[myCounter] = subNavId[thisCatIndex][s];
		            myCounter +=1;
		        }
		    }
		    
		    //id of last second level item in left nav
		    var last2ndLevel = (arrIds[arrIds.length-1])
			
			strBottomFind1 ="<tr>"
            strBottomFind1 +=  "					<td id=\"leftNavBtmShadow" + last2ndLevel + "\" class=\"leftNav_btmShadow\" onMouseOver=\"setOpacity(3, " + last2ndLevel + ");\" onMouseOut=\"setOpacity(10, " + last2ndLevel + ");\"></td>"
            strBottomFind1 +=  "				</tr>" 
            
            strBottomFind2 ="<tr>"
            strBottomFind2 +=  "					<td id=\"leftNavBtmShadow" + last2ndLevel + "\" class=\"leftNav_btmShadowOn\" onMouseOver=\"setOpacity(3, " + last2ndLevel + ");\" onMouseOut=\"setOpacity(10, " + last2ndLevel + ");\"></td>"
            strBottomFind2 +=  "				</tr>" 
			
			
			//wipe out the bottom shadow, wheter state is on or off (see strings above)
			thisNavString = thisNavString.replace(strBottomFind1, strEmpty);
			thisNavString = thisNavString.replace(strBottomFind2, strEmpty);
			
           	navStr += thisNavString;
			
			//this will add some extra space to the last item of a third level set
		    if(subNavParent[thisCatIndex][lastItemNum] == subNavParent[thisCatIndex][i] && subNavId[thisCatIndex][i] == subNavId[thisCatIndex][lastItemNum]){
		        navStr = navStr.replace(strFind, strReplace);
		    }	
		   
		    
			// 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 j=0;j<subNavFileName[thisCatIndex].length;j++){
		if (thisFileName == subNavFileName[thisCatIndex][j].toLowerCase()){
			pageFile = subNavFileName[thisCatIndex][j]
			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 k=0;k<subNavFileName[thisCatIndex].length;k++){
		if (whichPageFile.toLowerCase() == subNavFileName[thisCatIndex][k].toLowerCase()){
			thisParentId = subNavParent[thisCatIndex][k]
		}
	}	
	//now get parent
	if (thisParentId != -1){
		for(var l=0;l<subNavFileName[thisCatIndex].length;l++){
			if (thisParentId == subNavId[thisCatIndex][l].toLowerCase()){
				strParentFileName = subNavFileName[thisCatIndex][l]
			}
		}
	}		
	
	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]
	        }
        }
    }
}
//-->	