function DoNothing() {
		//Do Nothing
}

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.isMac   = false;  // Macintosh
  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;
  }
  
  s = "Macintosh";
  if ((i=ua.indexOf(s)) >= 0){
  	this.isMac = true;
	  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;
  }
  
}
//71?
var browser = new Browser();
//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------
var activeButton = null;
var MENU_STYLE_DROP;
var MENU_STYLE_SLIDE;
MENU_STYLE_DROP = 0;
MENU_STYLE_SLIDE = 1;

function setMenuOpen(placeholderID, menuID) {
	//Set the coordinates of the menu to the placeholder and show
	var placeholder = document.getElementById(menuId);
	var menu = document.getElementById(menuId);
	menu.style.left = placeholder.style.left;
	menu.style.top = placeholder.style.top;
	menu.style.visibility = "visible";
	
}

function getSource(evt) {
  /* This function is used to determine which element raised the event.  
  ** Note the added check for the nodeType == 3.  This allows us to ensure that
  ** we are refering to the containing element, not the hyperlinked text within 
  ** a containing element.
  ** Refer to http://www.oreillynet.com/javascript/jvdhtmlckbk/solution.csp?day=4
  ** LRR 02/25/2005
  */
    var elem = null; 
    evt = (evt) ? evt : ((window.event) ? event : null);
    if (evt) {
       elem = (evt.target) ? evt.target : 
        ((evt.srcElement) ? evt.srcElement : null);
       if (elem.nodeType == 3) {
           elem = elem.parentNode;
       }
    }
    return elem;
}


//function slideButtonClick(event, menuId) {
//	return fcnClick(event, menuId, MENU_STYLE_SLIDE);
  
//}

//function buttonClick(event, menuId) {
	//return fcnClick(event, menuId, MENU_STYLE_DROP);
//}

function ButtonClick(event, menuId, mnuStyle) {
	var button;
  button = getSource(event);
  // Blur focus from the link to remove that annoying outline.
  if (button.blur) { // LRR - Note: we need to do this check to avoid bombing in Firefox
    button.blur();
  }
  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.
  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
  	if(button.menu!=null){
    	if (button.menu.isInitialized == null)
    		menuInit(button.menu);
  	}
  }
  
  // Set mouseout event handler for the button, if not already done.
  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;

  // Exit if this button is the currently active one.
  if (button == activeButton)
    return false;

  // Reset the currently active button, if any.
  if (activeButton != null)
    resetButton(activeButton);

  // Activate this button, unless it was the currently active one.
  if (button != activeButton) {
    depressButton(button, mnuStyle);
    activeButton = button;
  }
  else
    activeButton = null;

  return false;
}

function pButtonMouseover(event, menuId, mnuStyle) {
	//alert("in ButtonMouseover");
	var button;
  if(!(browser.isMac&&browser.isIE)){
		// Activate this button's menu if no other is currently active.
		if (activeButton == null) {
		  ButtonClick(event, menuId, mnuStyle);
		  return;
		 }
  }
  // Find the target button element.
  button = getSource(event);
  // If any other button menu is active, make this one active instead.
  if (activeButton != null && activeButton != button){
    ButtonClick(event, menuId, mnuStyle);
  }
}

function slideButtonMouseover(event, menuId) {
	pButtonMouseover(event, menuId, MENU_STYLE_SLIDE);
}

function buttonMouseover(event, menuId) {
	//alert("ok 1 - buttonMouseover")
	pButtonMouseover(event, menuId, MENU_STYLE_DROP);

}

function depressButton(button, mnuStyle) {

  var x = 0, y = 0;

  // Update the button's style class to make it look like it's
  // depressed.
  button.className += " menuButtonActive";

  // Set mouseout event handler for the button, if not already done.
  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;
  if(button.menu!=null){
	  if (button.menu.onmouseout == null)
	    button.menu.onmouseout = buttonOrMenuMouseout;

    // If this is a vertical menu then the submenu will slide out to the right
    // Else this is a horizontal menu and the submenu slides down
    if (mnuStyle == MENU_STYLE_SLIDE) { /* Check for vertical menu with horizontal slide */
	    x = button.offsetWidth;
    } 
    if (!(x>0)) {
	    y = button.offsetHeight;
    }
    x+=getPageOffsetLeft(button);
    y+=getPageOffsetTop(button); 

    button.menu.style.left = x + "px";
	  button.menu.style.top  = y + "px";
	  button.menu.style.visibility = "visible";
  }
}

function resetButton(button) {

  // Restore the button's style class.

  removeClassName(button, "menuButtonActive");

  // Hide the button's menu, first closing any sub menus.

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";
  }
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover(event) {

  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {

  var item, menu, x, y;

	var btbutton = getSource(event);
  
  // Find the target item element and its parent menu element.
  /*if (browser.isIE)
    item = getContainerWith(window.event.srcElement, "A", "menuItem");
  else
    item = event.currentTarget;
  menu = getContainerWith(item, "DIV", "menu");
*/

item = getContainerWith(btbutton, "A", "menuItem");

menu = getContainerWith(item, "DIV", "menu");

//alert("menu=" + menu.id + " and item=" + item);

  // Close any active sub menu and mark this one as active.

  if (menu.activeItem != null)
    closeSubMenu(menu);
  menu.activeItem = item;

  // Highlight the item element.

  item.className += " menuItemHighlight";

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
	
	if(item.subMenu!=null){
    	if (item.subMenu.isInitialized == null)
    		menuInit(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;
	  }
	  // [END MODIFIED]
  }
  // Get position for submenu based on the menu item.

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(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.
	if (item.subMenu) {
		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(menu) {

  if (menu == null || menu.activeItem == null)
    return;

  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";
	menu.activeItem.subMenu = null;
  }
  removeClassName(menu.activeItem, "menuItemHighlight");
  menu.activeItem = null;
  
}

// [MODIFIED] Added for activate/deactivate on mouseover. Handler for mouseout
// event on buttons and menus.

function buttonOrMenuMouseout(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == 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(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

// [END MODIFIED]

//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------

function menuInit(menu) {

  var itemList, spanList;
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  // For IE, replace arrow characters.

  if (browser.isIE) {
	 // alert("about to set lineHeight for " + menu);
	  
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName(spanList[i], "menuItemArrow")) {
        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(spanList[j], "menuItemText"))
        textEl = spanList[j];
      if (hasClassName(spanList[j], "menuItemArrow"))
        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(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(node, className))
      return node;
    node = node.parentNode;
  }
  return node;
}

function hasClassName(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;
	list = el.className.split("_");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

	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(" ");
	
	var j=0;
	for (i = 0; i < curList.length; i++){
		if (curList[i] != name){
			newList[j]=curList[i];
			j++;
			//newList.push(curList[i]);
		}
	}
	el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the y coordinate of an element relative to the page.

  y = el.offsetTop;
  
  if (el.offsetParent != null)
  
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

/* WINDOW MANAGEMENT FUNCTIONS */
/* We need this var to ensure that each window is (relatively) unique to avoid cross-browser issues.  - LRR/02.28.2005 */
var winNum=Math.floor(Math.random() * 100);

function PopOpen(url) {
  /* This function opens the url in a smaller pop-up window */
		var popUpWin;
		winNum+=1;
		popUpWin=window.open(url,"win" + winNum,"width=550,height=600,status=yes,resizable=yes,location=yes,directories=yes,menubar=yes,toolbar=yes,scrollbars=yes,top=50,left=100");
		popUpWin.focus();
		
		return;
}

function SetOpenerLocation(url) {
	if (opener) {
		opener.location = url;
		//CloseWindow();	
	} else {
		//document.location = url;
		OpenFullWindow(url);
	}			
}
	
function OpenFullWindow(url) {
	/* This function opens the url in a full-size window */
	var fullWin;
	winNum+=1;
	fullWin=window.open(url,"win" + winNum,"height=400,width=600,status=yes,resizable=yes,location=yes,directories=yes,menubar=yes,toolbar=yes,scrollbars=yes,top=50,left=50");
	fullWin.focus();
	
	return;
}

function CloseWindow() {
	/* Close the Current Window */
	window.close();
}

/* SHOW_RANDOM FUNCTIONS */
function GetRandomNumber(n) {
    // Return a random number between 0 and n
		return Math.round(Math.random()*n);	
}

function PickOne() {
	// Randomly select and return one of the incoming arguments
	if (PickOne.arguments.length > 0) {
		return arguments[GetRandomNumber(PickOne.arguments.length-1)];
	} else {
			return -1;
	}
}

function ShowElement(elemID) {
	var elem = document.getElementById(elemID);
	elem.style.display = "block";
}

function HighlightLinks() { 
	/* Highlight any links that equate to the current page.
		 Here, we only want to modify links that are in the left menu
	 	 so we check for the className == menu* and container == TD/menubar_v 
	*/
	u = decodeURI(document.URL); 
	u = u.replace(/\\/g,""); 
	u = u.replace(/\//g,""); 
	t = document.all.tags("a"); 
	n = t.length; 
	for (var i=0; i < n; ++i ) { 
		x = t[i]; 
		if (x.className.indexOf("menu") >= 0) {
			menu = getContainerWith(x, "TD", "menubar_v");
			if (menu) {
				h = decodeURI(x.href); 
				h = h.replace(/\//g,""); 
				if ( h == u ) { 
					x.style.color="CC0000"; 
				}
			}
		}
	} 
} 