﻿/*
function extractPageName(hrefString) {
    alert(hrefString);
    var arr = hrefString.split('/');
    alert(arr);
    return (arr.length < 2) ? hrefString : arr[arr.length - 2].toLowerCase() + arr[arr.length - 1].toLowerCase();
}
*/
function extractPageName(hrefString) {

        if (hrefString.indexOf('?') >= 0) {
            hrefString = hrefString.substring(0, hrefString.indexOf('?'));
           }

        hrefString = hrefString.substring(hrefString.length, hrefString.lastIndexOf('/') + 1);
        return hrefString;

  }

function setActiveMenu(arr, crtPage) {
    for (var i = 0; i < arr.length; i++) {
    
            if (extractPageName(arr[i].href) == crtPage) {
           
            var p2 = arr[i].parentNode; // gets span tag
            var p1 = p2.parentNode; // gets li tag
            p1.className = "highlight";
            
        }
    }
}

function setPage() {
    hrefString = document.location.href ? document.location.href : document.location;
  
      if (document.getElementById("menu") != null)
       
        setActiveMenu(document.getElementById("menu").getElementsByTagName("a"), extractPageName(hrefString));
  }


  function NewWindow(ref, h, w) {

      if (h == "max") {
          h = screen.height / 1.2;
      }
      if (w == "max") {
          w = screen.width / 1.2;
      }
      var winW = (screen.width - w) / 2;
      var winH = (screen.height - h) / 2;
      var strFeatures = "toolbar=no,status=no,menubar=no,location=no"
      strFeatures = strFeatures + ",scrollbars=yes,resizable=yes,height=" + h + ",width=" + w + ",top=" + winH + ",left=" + winW + ""

      newWin = window.open(ref, "TellObj", strFeatures);
      newWin.opener = top;
  }

