// Determine the current page and apply
// a style to navigation elements (links)
// that are referencing the current page

function isdefined(variable) {
 return (typeof(variable) == "undefined")? false: true;
}
function parsePageName(x) {
  // Extract current location only including id=pagenum
  var s = x.lastIndexOf("/");
  if (s == -1) {s = 0;}
  //var e = x.indexOf("&");
  //if (e == -1) {e = x.length;}
  e = x.length;
  return x.substring((s+1),e);
}
function selectVisited()
{
  var thisHref = parsePageName(location.href);
  var nav = document.getElementById('sidebarmenu');
  var links = nav.getElementsByTagName('a');
  //var base = "http://www.cbisonline.com/";
  var base = "";
  var myoutput = "";
  for (var i=0; i<links.length; i++)
  {
  var matchFound = 0;
  var testLink = parsePageName(links[i].href);
    //myoutput += "cmp1: '" + testLink + "' -to- '" + thisHref + "'\n";  
    if (testLink == thisHref) {matchFound = 1;}
	//if (window.navParent) {
	//	     if (testLink == "index.php?" + window.navParent) {matchFound = 2;}
	//}
    //if (isdefined(navParent)) {
     //myoutput += "cmp2: '" + testLink + "' -to- 'page.asp?id=" + navParent + "'\n";
      //if (testLink == "page.asp?id=" + navParent) {matchFound = 2;}
    //}
    if (matchFound > 0) {
      links[i].className += " menuActive";
        //if (matchFound <2) {
        //myhref = links[i].getAttributeNode("href");
        //links[i].removeAttributeNode(myhref); // Remove the link
        //} 
   if (document.all) { // IE uses pE
      links[i].parentElement.className += " menuActive";
     } else { // others use pN
      links[i].parentNode.className += " menuActive";
     }
//alert(myoutput + "BREAK");
      break;
    }
  }
//alert(myoutput) + "NO MATCH";
}