function styleToggle(b) {  for (var i = 0; i< b.form.length; i++) {   if (b.form[i].name == b.name) {    b.form[i].parentNode.style.fontWeight = b.form[i].checked? 'bold' : '';   }  {    b.form[i].parentNode.style.color = b.form[i].checked? '#993300' : '';   }} }  
function clearValue(field) {
  field.value="";}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function addEvent(elm, evType, fn, useCapture)
// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
// By Scott Andrew
{
  if (elm.addEventListener) {
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent) {
    var r = elm.attachEvent('on' + evType, fn);
    return r;
  } else {
    elm['on' + evType] = fn;
  }
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function showSection() {
  if(document.getElementById("breadcrumbs")) {
    var breadcrumbURL = document.getElementById("breadcrumbs").getElementsByTagName("a");
    if (breadcrumbURL.length > 1) {
      //var sectionURL = breadcrumbURL[1].pathname;
      var sectionURL = breadcrumbURL[1].href;
    } else {
      var sectionURL = location.href;
    }
  }
  if(document.getElementById("leftnav")) {
    var menuList = document.getElementById("leftnav").getElementsByTagName("li");
    for(var i = 0; i < menuList.length; i++) {
      if(menuList[i].childNodes) {
        if(menuList[i].childNodes.length > 0) {
          var menuItem = menuList[i].childNodes[0];
          //var menuItemURL = menuItem.pathname;
          var menuItemURL = menuItem.href;
          
          if(sectionURL == menuItemURL) {
            //found section from breadcrumbs in the menu
            if(breadcrumbURL.length > 1) {
              //sub-section,content,below content - open sub menu
              P7_swapClass(0,menuItem.parentNode.id,'open','closed','li');
              
              //highlight any sub-section within the current section
              var menuSubList = menuList[i].getElementsByTagName("li");
              for(var j = 0; j < menuSubList.length; j++) {
                if(menuSubList[j].childNodes) {
                  if(menuSubList[j].childNodes.length > 0) {
                    var menuSubItemURL = menuSubList[j].getElementsByTagName("a")[0];
                    if(location.href == menuSubItemURL) {
                      //found sub-section matching current URL
                      menuSubList[j].className = "subnav2active";
                    }
                    if(breadcrumbURL.length > 2) {
                      if(breadcrumbURL[2].href == menuSubItemURL) {
                        //found sub-section matching breadcrumb URL
                        menuSubList[j].className = "subnav2active";
                      }
                    }
                  }
                }
              }
            } else {
              //section - close sub menu items and highlight
              menuItem.style.backgroundColor = '#2862AB';
              menuItem.style.color = '#fff';
              menuItem.style.fontWeight = 'bold';
            } // end if
          } // end if
        } // end if
      } // end if
    } // end for
  } // end if
} //end function

addEvent(window, 'load', showSection, false);
addEvent(window, 'load', externalLinks, false);