
//*****************************************************************************
// Do not remove this notice.
//
// 
// 
//*****************************************************************************

//----------------------------------------------------------------------------
// Code to determine the browser and version.
//----------------------------------------------------------------------------

var timer_down

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------

var activeButton_down = null;

function buttonClick_down(event, menuId) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
  var button_down;

  // Get the target button element.

  if (browser.isIE)
    button_down = window.event.srcElement;
  else
    button_down = event.currentTarget;

  // Blur focus from the link to remove that annoying outline.

  button_down.blur();

  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.

  if (button_down.menu == null) {
    button_down.menu = document.getElementById(menuId);
    if (button_down.menu.isInitialized == null)
      menuInit_down(button_down.menu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button_down.onmouseout == null)
    button_down.onmouseout = buttonOrMenuMouseout_down;

  // Exit if this button is the currently active one.

  if (button_down == activeButton_down)
    return false;

  // [END MODIFIED]

  // Reset the currently active button, if any.

  if (activeButton_down != null)
    resetButton_down(activeButton_down);

  // Activate this button, unless it was the currently active one.

  if (button_down != activeButton_down) {
    depressButton_down(button_down);
    activeButton_down = button_down;
  }
  else
    activeButton_down = null;

  return false;
}

function buttonMouseover_down(event, menuId) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
	ClearTimer(1);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
 var button_down;

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Activates this button's menu if no other is currently active.
if (event!='t')
	{
  if (activeButton_down == null) {
    buttonClick_down(event, menuId);
    return;
  }

  // [END MODIFIED]

  // Find the target button element.

  if (browser.isIE)
    button_down = window.event.srcElement;
  else
    button_down = event.currentTarget;

  // If any other button menu is active, make this one active instead.

  if (activeButton_down != null && activeButton_down != button_down)
    buttonClick_down(event, menuId);
	}
}

function depressButton_down(button_down) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
  var x, y;

  // Update the button's style class to make it look like it's
  // depressed.

  button_down.className += " menuButtonActive_down";
  
  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button_down.onmouseout == null)
    button_down.onmouseout = buttonOrMenuMouseout_down;
  if (button_down.menu.onmouseout == null)
    button_down.menu.onmouseout = buttonOrMenuMouseout_down;

  // [END MODIFIED]

  // Position the associated drop down menu under the button and
  // show it.

  x = getPageOffsetLeft_down(button_down);
  y = getPageOffsetTop_down(button_down) + button_down.offsetHeight;

  // For IE, adjust position.

  if (browser.isIE) {
    x += button_down.offsetParent.clientLeft;
    y += button_down.offsetParent.clientTop;
  }
  x += button_down.offsetWidth - 5;
  y -= button_down.offsetHeight;

  button_down.menu.style.left = x + "px";
  button_down.menu.style.top  = y + "px";
  button_down.menu.style.visibility = "visible";
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover_down(event) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith_down(window.event.srcElement, "DIV", "menu_down");
  else
    menu = event.currentTarget;
	
  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu_down(menu);
}

function menuItemMouseover_down(event, menuId) {

  var item, menu, x, y;
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
	
  // Find the target item element and its parent menu element.

  if (browser.isIE)
    item = getContainerWith_down(window.event.srcElement, "A", "menuItem_down");
  else
    item = event.currentTarget;
  menu = getContainerWith_down(item, "DIV", "menu_down");

  // Close any active sub menu and mark this one as active.

  if (menu.activeItem != null)
    closeSubMenu_down(menu);
  menu.activeItem = item;

  // Highlight the item element.

  item.className += " menuItemHighlight_down";

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.isInitialized == null)
      menuInit_down(item.subMenu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the sub menu, if not already done.

  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout_down;

  // [END MODIFIED]

  // Get position for submenu based on the menu item.
	
  x = getPageOffsetLeft_down(item) + item.offsetWidth - 5;
  y = getPageOffsetTop_down(item);
  
  // Adjust position to fit in view.

  var maxX, maxY;

  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  if (browser.isIE) {
    maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
      (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
    maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
      (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));

  // Position and show the sub menu.

  item.subMenu.style.left = x + "px";
  item.subMenu.style.top  = y + "px";
  item.subMenu.style.visibility = "visible";

  // Stop the event from bubbling.

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
}

function closeSubMenu_down(menu) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------

  if (menu == null || menu.activeItem == null)
	  return;

  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu_down(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";
    menu.activeItem.subMenu = null;
	
  }  
  removeClassName_down(menu.activeItem, "menuItemHighlight_down");
  menu.activeItem = null;
  
}

// [MODIFIED] Added for activate/deactivate on mouseover. Handler for mouseout
// event on buttons and menus.

function buttonOrMenuMouseout_down(event) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
  var el;

  // If there is no active button, exit.

  if (activeButton_down == null)
    return;

  // Find the element the mouse is moving to.

  if (browser.isIE)
    el = window.event.toElement;
  else if (event.relatedTarget != null)
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);

  // If the element is not part of a menu, reset the active button.

  if (getContainerWith_down(el, "DIV", "menu_down") == null) {
  timer_down = setTimeout('reset_down()',800);	
  }
}

function ClearTimer_down(menuId){
	if (activeButton_down != null) {reset_down(menuId)}
	clearTimeout(timer_down);
    timer_down = null;
	}
	
function reset_down()
{	
	resetButton_down(activeButton_down);
    activeButton_down = null;
}

function resetButton_down(button_down) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
  // Restore the button's style class.
removeClassName_down(button_down, "menuButtonActive_down");
  
  // Hide the button's menu, first closing any sub menus.

  if (button_down.menu != null) {
   closeSubMenu_down(button_down.menu);
   button_down.menu.style.visibility = "hidden";
  }
}

//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------

function menuInit_down(menu) {

  var itemList, spanList;
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  // For IE, replace arrow characters.

  if (browser.isIE) {
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName_down(spanList[i], "menuItemArrow_down")) {
        spanList[i].style.fontFamily = "Webdings";
        spanList[i].firstChild.nodeValue = "4";
      }
  }

  // Find the width of a menu item.

  itemList = menu.getElementsByTagName("A");
  if (itemList.length > 0)
    itemWidth = itemList[0].offsetWidth;
  else
    return;

  // For items with arrows, add padding to item text to make the
  // arrows flush right.

  for (i = 0; i < itemList.length; i++) {
    spanList = itemList[i].getElementsByTagName("SPAN");
    textEl  = null;
    arrowEl = null;
    for (j = 0; j < spanList.length; j++) {
      if (hasClassName_down(spanList[j], "menuItemText_down"))
        textEl = spanList[j];
      if (hasClassName_down(spanList[j], "menuItemArrow_down"))
        arrowEl = spanList[j];
    }
    if (textEl != null && arrowEl != null)
      textEl.style.paddingRight = (itemWidth
        - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
  }

  // Fix IE hover problem by setting an explicit width on first item of
  // the menu.

  if (browser.isIE) {
    w = itemList[0].offsetWidth;
    itemList[0].style.width = w + "px";
    dw = itemList[0].offsetWidth - w;
    w -= dw;
    itemList[0].style.width = w + "px";
  }

  // Mark menu as initialized.

  menu.isInitialized = true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------

function getContainerWith_down(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName_down(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName_down(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName_down(el, name) {
//----------------------------------------------------------------------------------------------------------------------------------------------------
	clearTimeout(timer_down);
    timer_down = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------
  var i, curList, newList;
  
  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name) newList[i] = curList[i];
  	el.className = newList.join(" ");
}

function getPageOffsetLeft_down(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft_down(el.offsetParent);

  return x;
}

function getPageOffsetTop_down(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop_down(el.offsetParent);

  return y;
}
