﻿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()

//alert(thisFileName);

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]
	        }
        }
    }
}
//alert(thisFileName);	
