function MenuHandler(){

	var ua = navigator.userAgent.toLowerCase();
	var isMac = navigator.appVersion.toLowerCase().indexOf('mac')+1;
	var isNN6 = ua.indexOf('netscape6')+1;
	var isOpera = ua.indexOf('opera')+1;
	var isSafari = ua.indexOf('safari')+1;
	var isIE = (document.all && !isOpera);
	var mainMenuItem;
	var subMenu = [];
	var subnavItemsCount = [];
	var anchorCharCount = [];
	var items;
	var anchors = [];
	var node;
	var oMenu;
	var index = [];
	var checkit;
	var maxTop;
	var page;
	var menuHeight = 220;	//hard coded menu height including padding and margin.
	var itemHeight = 21;	//hard coded menu item height including padding and margin.
	var offsetTop = 2;
	var c = 0;
	this.navItems = [];
    this.topNav = null;
	var self = this;
	
	//Determines if the object is a top nav element.
	this.isTopNavElement = function(o) {
		return (o && o.className && o.className.indexOf('top')+1);
	}
	
	//Determines if an object is a nav element
	this.isNavElement = function(o) {
		if (!self.topNav) self.topNav = document.getElementById('experience-menu');
		if ((isIE || isOpera) && o.className && o.className.indexOf('top')+1) return false;
		do {
			o = (o.parentNode||'null');
			
		} 
		while (o != 'null' && o != self.topNav);
			
			return (o == self.topNav);
	}
	
	//function to find the current non-text node
	this.findNode = function(n) {	
		if (!n || !n.nodeType) return null;
		while (n.nodeType==3 && n.parentNode) {
		n = n.parentNode;
		}
		return n;
	}
	
	//mouseover for non-standards compliant browsers
	this.itemOver = function(e) {
		if(!this.active){
			this.active = 1;
			o = (isOpera?e.target:e.srcElement);
			if (o && self.isTopNavElement(o)) {			
				this.className = (this.className && this.className.indexOf('hover')+1?this.className:((this.className?'hover '+this.className:'hover')));
			}		
			self.calculate(this.index,this.index2-1);		
		}
		self.checkClearAll();
	}
	
	//mouseout for non-standards compliant browsers
	this.itemOut = function(e) {
		this.active = 0;
		o = (isOpera?e.relatedTarget:e.toElement);
		if (o && !self.isNavElement(o)) {
			this.className = this.className.replace(/hover /g,'');
		}		
	}	
	
	//mouseover for standards compliant browsers
	this.itemOverW3C = function(e) {
		if(!this.active){
			this.active = 1;
			o = self.findNode(e.target);		
			if (!e){ return false;}
			if (!self.isNavElement(o)){return false;}		
			this.className = (this.className && this.className.indexOf('hover')+1?this.className:((this.className?'hover '+this.className:'hover')));
			self.calculate(this.index,this.index2-1);
			if(self.isTopNavElement(o))self.checkClearAll();
		}
	}
	
	//mouseout for standards compliant browsers
	this.itemOutW3C = function(e) {		
		this.active = 0;
		o = self.findNode(e.relatedTarget);
		if (!o){ return false;}
		if (typeof(o.nodeName)=='undefined'){  return false;}
		//if (self.isChildOfIndex(this.menuIndex,o)) return false;
		if (this.className.indexOf('hover')+1) this.className = this.className.replace("hover ","");		
	}
	
	//checks to see if we need to clear the menus and then calls clearAll(); if needed
	this.checkClearAll = function(){		
		if(checkit)clearTimeout(checkit);
	
		checkit = setTimeout(self.clearAll,1000);
	}
	
	//Clears all the menus in case the menu doesn't close on mouseout properly
	this.clearAll = function(e) {
		
			for(i=0;i<self.items.length;i++){
				if(!self.items[i].active){
					self.items[i].className = self.items[i].className.replace(/hover /g,'');
				}
			}		
	}
	
	/* This function calculates the height of the menus and sub menus
	   and re-positions the sub menu based on it's total height */
	this.calculate = function(n,c){		
				
		var menu = document.getElementById('experience-menu'); //nav div container		
		
		var containerTop = self.findPosY(menu);  //find the top of the menu container

		var menuBase = containerTop + menuHeight;  //find the base of the main menu

		var menuTop = self.findPosY(self.items[n]);  //find the top of the main menu item
				
		var newMenuHeight = menuHeight - (menuTop-containerTop);  //determine the new menu height from the new position
		
		var subnavMenuHeight = Number(subnavItemsCount[c])*itemHeight;  //determine subnav height
		/*if the subnav if taller than the given area from the top of the parent li element
		 to the base of the menu then grow the menu upwards past the top of the menu container.*/
		
		//determine if the character length will cause the menu to grow.
		for(x=1;x<anchors[c].length;x++){
			//get the char count of the anchor element			
			if(anchors[c][x]&&anchors[c][x].innerHTML){
				var newLength = anchors[c][x].innerHTML.length;
				
				while(newLength > 46 ){  //use double the max so we don't take the first iteration into account.
					newLength = newLength - 23; // max character length
					subnavMenuHeight += itemHeight-2; //-2px because of border top and bottom
				}										
			}
		}
		/*if the top level item has a sub menu and the sub menu height is greater than 
		the distance from the top of the parent LI to the bottom of the menu then adjust it's position */
		if(self.items[n].className.indexOf('main')+1 && (subnavMenuHeight > newMenuHeight)){							
			subMenu[c][0].style.top =  (newMenuHeight) - subnavMenuHeight+"px";
					
		}
		
	}
	//event handler
	this.addEvent = function ( obj, type, fn1, fn2 )
	{
		if (obj.addEventListener){
		obj.addEventListener( type, fn2, false );
		}
		else if (obj.attachEvent)
		{
			obj["e"+type+fn1] = fn1;
			obj[type+fn1] = function() { obj["e"+type+fn1]( window.event ); }
			obj.attachEvent( "on"+type, obj[type+fn1] );
		}
	}
	
	//worker function used for finding the y co-ordinate of and object
	this.findPosY = function(obj)
	{
		var curtop = 0;
		
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}
	
	//Onclick event handler for non-standards compliant browsers
	this.clickEvent = function(e){				
		o = (isOpera?e.target:e.srcElement);
		if(!self.isTopNavElement(o)){			
			window.location = o.href;
			return true;
		}
		else{
			
			var hasUL = o.parentNode.getElementsByTagName('ul');
						
			if(hasUL.length == 1){
				// Added By Rob 4/12/2006
				window.location = o.href;
				return false;
			}
			else{
				window.location = o.href;
				return true;
			}
		}
		
	}
		
	//Onclick event handler for standards compliant browsers
	this.clickEventW3C = function(e){		
		o = self.findNode(e.target);
		if(!self.isTopNavElement(o)){			
			window.location = o.href;
			return true;
		}
		else{
			
			var hasUL = o.parentNode.getElementsByTagName('ul');
						
			if(hasUL.length == 1){
				// Added By Rob 4/12/2006
				window.location = o.href;			
				return false;
			}
			else{
				window.location = o.href;
				return true;
			}
		}
		
	}	
		
	//initialization
	this.init = function(){
		
		//Collect all the list objects and store them in var items
		self.items = document.getElementById('experience-menu').getElementsByTagName('li');
    	for (var i=0; i<self.items.length; i++) {
      		if (isNN6 || isOpera && self.items[i].className) {
        		self.navItems[self.navItems.length] = self.items[i];
        		self.items[i].menuIndex = self.navItems.length-1;
      		}

			if(self.items[i].className && self.items[i].className.indexOf('main')+1){
				
				//determine if the parent li has a sub ul element
				if(self.items[i].getElementsByTagName('ul')){
					
					//store the subnav <ul> elements to be used later
					subMenu.push(self.items[i].getElementsByTagName('ul'));
					
					//get the <a> elements in the subnavs	
					anchors.push(self.items[i].getElementsByTagName('a'));
					
					//put the number of <a> elements minus the parent <a> element into an array
					subnavItemsCount.push(anchors[c].length-1);
					
					
				}
				//if the parent list item doesn't have a sub menu then add 0 to keep the index relative
				else{
					subMenu.push(0);
					subnavItemsCount.push(0);
				}
				
				c++;
				
			}
			
			self.items[i].index = i;  //index of all the LI elements
			self.items[i].index2 = c;  //index of the top level LI's: there are eight in this case
     	
			//These are the event attachment calls.			
			self.addEvent( self.items[i], 'mouseover', self.itemOver, self.itemOverW3C );
			self.addEvent( self.items[i], 'mouseout', self.itemOut, self.itemOutW3C );			
			self.items[i].onclick = function(){return false;}
			self.addEvent( self.items[i], 'click', self.clickEvent, self.clickEventW3C );
			
			
		}	
	}
}
//instantiate the object and give it to the onload handler
var menuHandler = new MenuHandler();

onloadHandlers[onloadHandlers.length] = 'menuHandler.init()';