function bwSniff03(){  /*BrowserSniff object 20020525*/
  var verMajor = "?", verMinor = "?";
  this.ver=navigator.appVersion;
  this.agent=navigator.userAgent;
  this.dom=document.getElementById?1:0;
  var idxMSIE = this.agent.indexOf("MSIE");
  var idxNN6 = this.agent.indexOf("Netscape6");
  var idxOP = this.agent.indexOf("Opera");
  if (idxMSIE>-1) {
    this.name = "IE";
    verMajor = parseInt(this.agent.substring(idxMSIE + 5));
    verMinor = parseInt(this.agent.substring(idxMSIE + 7));
  } else if (idxNN6>-1) {
    this.name = "NN";
    verMajor = parseInt(this.agent.substring(idxNN6 + 10));
    verMinor = parseInt(this.agent.substring(idxNN6 + 12, idxNN6 + 12 + 1));
  } else if (idxOP>-1) {
    this.name = "OP";
    verMajor = parseInt(this.agent.substring(idxOP + 6));
    verMinor = this.agent.substring(idxOP + 8, idxOP + 8 + 2);
  } else {
    this.name = "?";
  }
  // handy vars
  this.ie = (this.name == "IE");
  this.ie50 = this.agent.indexOf("MSIE 5.0")>-1;
  this.nn = (this.name == "NN");
  this.op = (this.name == "OP");
  this.mac = (this.agent.indexOf("Mac")>-1);
  this.platform = this.mac?"Mac":"PC";
  this.bw = this.name + verMajor + verMinor;
  this.bp = this.bw + "-" + this.platform;
  // CSS pixels
  this.px=this.dom&&!this.op?"px":"";
}
var bw = new bwSniff03()

//debug zone ----------------------------------------------------------------------------
var debug, counter = 0;
//MacIE50, Opera cannot handle debug layers before pageload
//if (!((bw.mac && bw.ie50) || bw.op)) debug = new cDebug();  //'''rem line out to hide debug
function cDebug() {  /* debug box constructor */
  document.write("<div id='debug' style='position:absolute; FONT-FAMILY: Verdana; font-size: 10px; left:10px; top:450px; width:750px; height:100px; background:#cecece;visibility:visible;'>" + "ver: " + bw.ver + "<br>agent: " + bw.agent + "</div>");
  document.write("<div id='debug2' style='position:absolute; FONT-FAMILY: Verdana; font-size: 10px; left:10px; top:530px; width:750px; height:20px; background:#aecece;visibility:visible;'>" + "Browser-Platform: " + bw.bp + "</div>");
  this.box = document.getElementById("debug");
  this.box2 = document.getElementById("debug2");
}
function debugprint(msg) {if (debug) debug.box.innerHTML = msg; }
function debugcount(msg) {if (debug) {counter++; debug.box2.innerHTML = "#" + counter + ":" + msg;}}
function debugtitle(msg) {counter++; document.title = "#" + counter + ":" + msg;}
// ---------------------------------------------------------------------------------

// =================================================================================
// you can do some configuration here
var closeMenuDelay = 600; //msec delay before menu disappears
var clrOver = "#cecece";  //mouseover color
var clrOut = "#ffffff";   //mouseout color
// style bits the 'iStyle' parameter in function menOverTR()
var cSkipColoring = 1;    //skip mouseover coloring
var cPopDown = 2;         //pop first popup downwards
// global vars
var elemCurItem;          //current item (TR) where cursor is at
var elemCurMenuAt;        //current menu (DIV) where cursor is at
//note: cursor change not supported in Opera
var handcursor = bw.nn?"pointer":"hand";
// note: standard array methods push and pop are NOT supported by IE5-Mac!
var stackMenu = [0];      //currently visible DIVs
var stackItem = [0];      //currently visible TRs (treepath)
var stackColored = [0];   //currently colored items
var curLevelAt = 0;       //current level
var fActive = false;    	//user action flag for delay
var closeTimeoutID = 0;		//for delay

// =================================================================================
// internal functions
var bodyMargin = new getBodyMargin();
function getBodyMargin() {
  // read margins once from CSS styles
  // expects (a) ONE stylesheet, (b) BODY rule to be the FIRST!
  // [this function is needed only by IE5-Mac]
  var theRules = new Array(); //document.styleSheets[0] only
  getTheRules();
  function getTheRules() {
  	if (!document.styleSheets) return;      /*Opera*/
  	if (document.styleSheets[0].cssRules)   /*NN6, IE5/Mac*/
  		theRules = document.styleSheets[0].cssRules
  	else if (document.styleSheets[0].rules) /*IE4+/WinMac*/
  		theRules = document.styleSheets[0].rules
  	else return
  }
  // JRR, 20/07/2005
  // Test de l'existence de la propri?t? style avant d'acc?der
  // aux propri?t?s marginLeft et marginTop
  if (theRules.length > 0 && theRules[0].style) {
    this.Left = parseInt(theRules[0].style.marginLeft);
    this.Top = parseInt(theRules[0].style.marginTop);
  } else {
    this.Left = 0;
    this.Top = 0;
  }
}

function getBrowserWindowSize() {
// 20020512: returns object with inner window size and scroll offset
  if (bw.nn) {
    // Netscape
    // scrollbars are NOT taken care off by innerWidth/innerHeight
    this.width = window.innerWidth;
    this.height = window.innerHeight;
    this.scrollX = window.scrollX;  //alternativ: window.pageXOffset
    this.scrollY = window.scrollY;  //alternativ: window.pageYOffset
  } else {
    // other browsers
    // scrollbars are taken care off by clientWidth/clientHeight
    // note: offsetWidth returns a value 4 pixels larger than clientWidth (= 2 x 3D-borders)
    this.width = document.body.clientWidth;
    this.height = document.body.clientHeight;
    this.scrollX = document.body.scrollLeft;
    this.scrollY = document.body.scrollTop;
  }
}

function getAbsoluteOffset(id) {
// 20020511: x/y offsets within page
// PC:  +IE55, +NN60, +NN62
// Mac: +IE50, +IE51, +NN60+
  var offsetX = 0, offsetY = 0;
  var sDepthX = "", sDepthY = "";
  var elem = document.getElementById(id);

  if (elem.offsetParent) {
    // IE55, NN60-level 1, NN62: walk up the object hierarchy
		// MacIE55 is here, too
  	while (elem.offsetParent) {

      offsetX += elem.offsetLeft;
      offsetY += elem.offsetTop;

      // for debug only
      sDepthX += elem.tagName + ":" + elem.offsetLeft + ",";
      sDepthY += elem.tagName + ":" + elem.offsetTop + ",";

      elem = elem.offsetParent;
    }
    // for NN60-level 1 PC: add body offset (is 0 in other browsers, also on Mac)
  	offsetX += document.body.offsetLeft;
   	offsetY += document.body.offsetTop;

		// MacIE50 and MacIE51 need to add the body style offsets
		if (bw.mac && bw.ie) {
 			offsetX += bodyMargin.Left
 			offsetY += bodyMargin.Top
		}


  } else {
    // NN60-level 2ff: elem.offsetParent is Null for layer 2 ff
    // in this case offsetLeft/Top is all we need
    offsetX += elem.offsetLeft;
    offsetY += elem.offsetTop;

    // for debug only
    sDepthX += elem.tagName + ":" + elem.offsetLeft + ",";
    sDepthY += elem.tagName + ":" + elem.offsetTop + ",";
  }
  // build return-struct
  this.x = offsetX;
  this.y = offsetY;
  // for debug only
  this.sDepthX = sDepthX;
  this.sDepthY = sDepthY;
}

// =================================================================================
// event-driven functions
function menOut() {
  // issue: event is triggered *still within* the DIV when cursor is over grey line.
  // solution: onMouseOver="menOver();"
  fActive = false;
  closeTimeoutID = window.setTimeout("closeMenu()", closeMenuDelay);
}
function menOver() {
    window.clearTimeout(closeTimeoutID);
}
function closeMenu() {
  if (fActive) {
    // keep open
    window.clearTimeout(closeTimeoutID);
  } else {
    //ensure style undo for level 1 TR (happens when we mouseOut there)
    //stackitem.1.style error fix:
    if (stackItem[1]) {
      if (stackColored[1]) stackItem[1].style.backgroundColor = clrOut;
    }
    //close all menus above level 2
    curLevelAt = 1;
    for (i = stackMenu.length - 1; i > curLevelAt; i--) {
      stackMenu[i].style.visibility = "hidden";
      stackMenu.length--; //pop not supported by IE5-Mac
      stackItem.length--;
      // uncolor
      if (stackColored[i]) {stackColored[i].style.backgroundColor = clrOut; stackColored[i] = null;}
    }
    // reinit
    stackMenu = [0];
    stackItem = [0];
  }
}

function menOverTR(id_self,id_layer,iStyle) {
  // id_self        id of current table row (= this.id of event)
  // id_layer       id of child div (the layer to be shown)
  // iStyle         composite of style bits (optional), values see above
  var dmsg = ""; //debug
  var x = 0, y = 0;
  var elSelf=document.getElementById(id_self);
  var elLayer=document.getElementById(id_layer);

  fActive = true;

  // get cur menu DIV we're at: it's the next parent DIV. Works fine. Mac too.
  var parent = elSelf;
  while (parent.parentNode) {
    parent = parent.parentNode;
    if (parent.tagName == "DIV") {
      elemCurMenuAt = parent;
      break;
    }
  }

  // get cur level we're at: walk the level stack
  var onStack = false;
  curLevelAt++; //assume we go down
  for (i = 1; i < stackMenu.length; i++) {
    if (stackMenu[i] == elemCurMenuAt) {
      // the current menu is on the stack
      onStack = true;
      curLevelAt = i;
      break;
    }
  }
  // happens only on level 1 change
  if (!onStack) {
    curLevelAt = 1;
    stackMenu[curLevelAt] = elemCurMenuAt;
  }

  // cursor
  if (elemCurItem != elSelf) {
    if (elemCurItem) {elemCurItem.style.cursor = "Default";}
    elSelf.style.cursor = handcursor;
    // store
    elemCurItem = elSelf;
  }
  // colors
  // uncolor prev
  if (stackColored[curLevelAt]) stackColored[curLevelAt].style.backgroundColor = clrOut;
  // color this
  if (iStyle & cSkipColoring) {
    stackColored[curLevelAt] = null;
  } else {
    elSelf.style.backgroundColor = clrOver;
    stackColored[curLevelAt] = elSelf;
  }

  // if we got an item change at the current level
  if (curLevelAt <= stackItem.length) {
    // note: if element is undefined, MacIE quits
    //       so we check explicitly and ensure it's defined
    if (typeof stackItem[curLevelAt] == "undefined") {
      stackItem[curLevelAt] = ""; //is set to elSelf below anyway
    }

    // note: moving cursor between TDs of one TR fires the TR mouseover event (all browsers)!
    //       (not relevant here because we compare TRs)
    if (stackItem[curLevelAt] != elSelf) {
      // cut the upper branch
      for (i = stackMenu.length - 1; i > curLevelAt; i--) {
        stackMenu[i].style.visibility = "hidden";
        stackMenu.length--; //pop not supported by IE5-Mac
        stackItem.length--;
        // uncolor
        if (stackColored[i]) {stackColored[i].style.backgroundColor = clrOut; stackColored[i] = null;}
      }
      // push the new menu onto the stack
      if (elLayer) {
        stackMenu[curLevelAt+1] = elLayer; //push not supported by IE5-Mac
      }
    }
  }
  // update item stack
  stackItem[curLevelAt] = elSelf;

  /*debug*/
  //dmsg += "curLevelAt:" + curLevelAt + ", elemCurMenuAt:" + elemCurMenuAt.id + ", stackMenu[curLevelAt]:" + stackMenu[curLevelAt].id + ", stackMenu.length:" + stackMenu.length + "<br>";
  //dmsg += "Visible Menus: "; for (i = 1; i < stackMenu.length; i++) {dmsg += stackMenu[i].id + ", ";}; dmsg += "<br>";
  //dmsg += "Current Path: "; for (i = 1; i <= curLevelAt; i++) {dmsg += stackItem[i].id + ", ";}; dmsg +=  " stackItem.length:" + stackItem.length + "<br>";

	if (elLayer) {

    // page pos of current element
    var offset = new getAbsoluteOffset(id_self);
    var winSize = new getBrowserWindowSize();

    /*debug*/
    //dmsg += "offset.x=" + offset.x + ", " + offset.sDepthX  + "<br>";
    //dmsg += "offset.y=" + offset.y + ", " + offset.sDepthY  + "<br>";
    //dmsg += "elSelf.offsetWidth=" + elSelf.offsetWidth + "<br>";
    //dmsg += "winSize.height=" + winSize.height + "<br>";
    //dmsg += "elLayer.offsetHeight=" + elLayer.offsetHeight + "<br>";


    // negotiate position
    // compensate the 1-pixel border of tables (class nav)
    var nav_paddingX = -1;
    var nav_paddingY = -1;

    if (iStyle & cPopDown) {
      x = offset.x + nav_paddingX;
      y = offset.y + nav_paddingY + elSelf.offsetHeight;
    } else {
      x = offset.x + nav_paddingX + elSelf.offsetWidth;
      y = offset.y + nav_paddingY;
    }
    // mind window right
    var overlapX = x + elLayer.offsetWidth - winSize.width - winSize.scrollX;
    if (overlapX > 0) {
      //popout left
      x = offset.x + nav_paddingX - 2 * nav_paddingX - elLayer.offsetWidth;
      //x -= (elSelf.offsetWidth + elLayer.offsetWidth) + 2 * nav_paddingX;
    }
    // mind window left
    if (x < winSize.scrollX) x = winSize.scrollX;
    // mind window bottom
    var overlapY = y + elLayer.offsetHeight - winSize.height - winSize.scrollY;
    if (overlapY > 0) {
      //move upwards from here
      y = offset.y - nav_paddingY + elSelf.offsetHeight - elLayer.offsetHeight;
      //old way:  y -= overlapY;    //move upwards, touch ground
    }
    // mind window top
    if (y < winSize.scrollY) y = winSize.scrollY; //but not too far

    // finally realize it
    elLayer.style.zIndex = 20; //ensure on top
    elLayer.style.left = x + bw.px;
    elLayer.style.top = y + bw.px;
    elLayer.style.visibility = "visible";

    /*debug*/
    //dmsg += "elLayer.left/top/width/height: " + elLayer.style.left +"/"+elLayer.style.top+"/"+elLayer.style.width+"/"+elLayer.style.height;

  } else {
    // no layer
  }

  //debugprint(dmsg);
}

