  // Grab the location of the page
  var locationStr = document.location.href;

  // Remove the hostname and protocol

  var re = new RegExp(".*" + document.location.hostname +"/", "g");

  locationStr =locationStr.replace(re,"/");
  // Remove any query string on the url

  //var q_start = locationStr.indexOf("?");

  //if (q_start>0) {

   //  locationStr = locationStr.substring(0,q_start);

   //}

  re = new RegExp("index.html");
  locationStr = locationStr.replace(re,"");
  if (locationStr.indexOf("WORKAREA")) {
    var r1 = new RegExp(".*WORKAREA/.*?/unsecure","g");
    locationStr = locationStr.replace(r1,"");
    r1 = new RegExp(".*WORKAREA/.*?/secure","g");
    locationStr = locationStr.replace(r1,"");
    if (locationStr.indexOf("WORKAREA")) {
      r1 = new RegExp(".*WORKAREA/.*?/","g");
      locationStr = locationStr.replace(r1,"/");
    }
  }
   var startPath = new Array();

function buildLinkArray(){
    var submenu = document.getElementById("subMenu");
    var li = submenu.getElementsByTagName("li");
    var alert_txt = "";
        for(var i=0;i<li.length;i++){
                var aTag = li[i].getElementsByTagName("a")[0];
                var aURL = aTag.getAttribute("href");
                var re = new RegExp(".*//.*?/", "g");
                aURL =aURL.replace(re,"/");
                re = new RegExp("index.html");
                aURL = aURL.replace(re,"");
                var aID = aTag.getAttribute("id");
                aID = aID.replace(/i/,"");
                 // startPath[aID] = aURL;
                    startPath[aURL] = aID;
                // already stored in Array above, alert for debug
                alert_txt += aID+" = "+ aURL;
        }
}


          // startPath["2-4-3"] = locationStr;

        //DEBUGGING BY FORCING A URL STRING
        //  locationStr = "/us/CreditCard/";
          var img_active = new Array();
          var img_lvl = new Array();
          
          if (arrow_color == "#660099") {
            // Image links

            img_active[1] = "/images/global/nexgen08/arrow_down.gif";
            img_active[2] = "/images/global/nexgen08/arrow_down_center.gif";
            img_active[3] = "/images/global/nexgen08/arrow_down_center.gif";
  
            img_lvl[1] = "/images/global/nexgen08/arrow_right.gif";
            img_lvl[2] = "/images/global/nexgen08/arrow_right_center.gif";
            img_lvl[3] = "/images/global/nexgen08/arrow_right_center.gif";
          } else {
            img_active[1] = "/images/global/nexgen08/arrow_down_blue.gif";
            img_active[2] = "/images/global/nexgen08/arrow_down_blue_center.gif";
            img_active[3] = "/images/global/nexgen08/arrow_down_blue_center.gif";

            img_lvl[1] = "/images/global/nexgen08/arrow_right_blue.gif";
            img_lvl[2] = "/images/global/nexgen08/arrow_right_blue_center.gif";
            img_lvl[3] = "/images/global/nexgen08/arrow_right_blue_center.gif";
          }

          function startUp() {
            var menu_id = "";
              menu_id = startPath[locationStr];
		if (menu_id == null){
                   //alert("menu_ID: " + menu_id + " " + locationStr);
		   if ((document.getElementById('m1') != null) && (document.getElementById('m2') == null)){ 
			hideShow('m1')
			return;
		   }
                }
              if (typeof menu_id == 'undefined') {return};

	    if (menu_id != null){
            if (document.getElementById("m" +menu_id+"-0")) {
               //alert("m"+menu_id+"-0");
               //alert(document.getElementById("m"+menu_id+"-0"));
               try {hideShow("m"+menu_id); } catch (e) {};
            }
            do {
              hLink(menu_id);
              var ind = menu_id.lastIndexOf("-");
              if (ind >= 0) {
                menu_id = menu_id.substring(0,ind);
		// alert("menu_id:"+menu_id);	
                hideShow("m"+menu_id);
                hLink(menu_id);
              }
            } while (ind >= 0);
	    }

          }

          function hideMenuAll (menuElement) {
          return;
            var myChildren = menuElement.getElementsByTagName("ul");
            for (var loop=0;loop>myChildren.length;loop++) {
              myChildren[loop].style.display="none";
            }
          }

          function hLink(item) {
            if (item) {
                document.getElementById("i"+item).style.fontWeight="bold";
                if (arrow_color == "#660099") {
                  document.getElementById("i"+item).style.color="#660099";
                } else {
                  document.getElementById("i"+item).style.color="#0099CC";
                }
            }
          }

          function hideShow (item) {
            var l = document.getElementById(item);
            if (l.className == "menuNav") {
              try {
              var img = document.getElementById(item+"-image");
              var navlvl=1;
              if (img.src.indexOf("center")>0) { navlvl=2; };
              img.src=img_active[navlvl];
              } catch (error) {}
              l.className = "menuActive";
              if (l.getElementsByTagName("ul")[0]){
                  l.getElementsByTagName("ul")[0].style.display="block";
              }
            } else {
              try {
              var img = document.getElementById(item+"-image");
              var navlvl=1;
              if (img.src.indexOf("center")>0) { navlvl=2; };
              img.src=img_lvl[navlvl];
              } catch (error) {}
              l.className ="menuNav";
              if (l.getElementsByTagName("ul")[0]){
                  l.getElementsByTagName("ul")[0].style.display="none";
              }
            }
          }
