// Morten's JavaScript Tree Menu Tracking Script
// version 2.3.2-macfriendly, dated 2002-06-10
// http://www.treemenu.com/
// Copyright (c) 2001-2002, Morten Wang & contributors
// All rights reserved.

// This software is released under the BSD License which should accompany
// it in the file "COPYING".  If you do not have this file you can access
// the license through the WWW at http://www.treemenu.com/license.txt

//sm- mtmtrack() is called at least twice during page loading
// 1st at the end of the html page (page loaded, but not images, css etc)
// and again in the window onload() (after all images etc also loaded).
// If it runs successfully the first time the second time the call is ignored.
var mtmtrack_done = false;

function mtmtrack() {
  if (mtmtrack_done) return; //already done
  if ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3 && navigator.userAgent.indexOf("Opera") == -1) || (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4) || (navigator.appName == "Opera" && parseInt(navigator.appVersion) >= 5)) {
    //alert("tracking!!")
    var MTMCodeFrame = "trvHeader";
    if (parent) {
      for (var i = 0; i < parent.frames.length; i++) {
        if (parent.frames[i].name == MTMCodeFrame && parent.frames[i].MTMLoaded) {
          setTimeout("mtmtrack_delayed(" + i + ")", 100);
          mtmtrack_done = true;
          break;
        }
      }
    }
  }
}

function mtmtrack_delayed(frameRef) {
  parent.frames[frameRef].MTMTrack = true;
  var menuitemId = parent.frames[frameRef].MTMDisplayMenu()
  setTimeout("mtmtrack_onclick('sub" + menuitemId + "','" + frameRef + "')", 200)
  //mtmtrack_onclick("sub" + menuitemId, frameRef)
}

function mtmtrack_onclick(itemId, frameRef) {
  //sm 2010 - run menuitem onclick function to open sub menus
  var menuitem = parent.trvMenu.document.getElementById(itemId)
  if (menuitem && menuitem.onclick) {
    var func = menuitem.onclick
    func(null)
    //redraw menu
    parent.frames[frameRef].MTMTrack = true;
    parent.frames[frameRef].MTMDisplayMenu() 
  }
}