	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	Update log:
	Version 1.1 	December, 1st 2005: Critical update for the new Firefox 1.5 browser
	Version 1.2: 	December, 21th 2005 : Mouseover effect when mouse moves outside of a submenu items text
	
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
		
	var top_dhtmlgoodies_menuObj;	// Reference to the menu div
	var top_currentZIndex = 1000;
	var top_liIndex = 0;
	var top_visibleMenus = new Array();
	var top_activeMenuItem = false;
	var top_timeBeforeAutoHide = 1200; // Microseconds from mouse leaves menu to auto hide.
	var top_dhtmlgoodies_menu_arrow = 'images/arrow.gif';
	
	var top_MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;  
	var top_navigatorVersion = navigator.appVersion.replace(/.*?MSIE ([0-9]\.[0-9]).*/g,'$1')/1;
	var top_menuBlockArray = new Array();
	var top_menuParentOffsetLeft = false;
	
	var top_menuActive = true;
	var top_hideTimer = 0;
	
	function top_getTopPos(inputObj)
	{
		
	  var returnValue = inputObj.offsetTop;
	  if(inputObj.tagName=='LI' && inputObj.parentNode.className=='menuBlock1'){
	  	var aTag = inputObj.getElementsByTagName('A')[0];
	  	if(aTag)returnValue += aTag.parentNode.offsetHeight;

	  }	  
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;

	  return returnValue;
	}
	
	function top_getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
	
	function top_showHideSub()
	{

		var attr = this.parentNode.getAttribute('currentDepth');
		if(navigator.userAgent.indexOf('Opera')>=0){
			attr = this.parentNode.currentDepth;
		}
		
		this.className = 'currentDepth' + attr + 'over';
		
		if(top_activeMenuItem && top_activeMenuItem!=this){
			top_activeMenuItem.className=top_activeMenuItem.className.replace(/over/,'');
		}
		top_activeMenuItem = this;
	
		var numericIdThis = this.id.replace(/[^0-9]/g,'');
		var exceptionArray = new Array();
		// Showing sub item of this LI
		var sub = document.getElementById('subOf' + numericIdThis);
		if(sub){
			top_visibleMenus.push(sub);
			sub.style.display='';
			sub.parentNode.className = sub.parentNode.className + 'over';
			exceptionArray[sub.id] = true;
		}	
		
		// Showing parent items of this one
		
		var parent = this.parentNode;
		while(parent && parent.id && parent.tagName=='UL'){
			top_visibleMenus.push(parent);
			exceptionArray[parent.id] = true;
			parent.style.display='';
			
			var li = document.getElementById('dhtmlgoodies_listItem' + parent.id.replace(/[^0-9]/g,''));
			if(li.className.indexOf('over')<0)li.className = li.className + 'over';
			parent = li.parentNode;
			
		}

			
		top_hideMenuItems(exceptionArray);



	}

	function top_hideMenuItems(exceptionArray)
	{
		/*
		Hiding visible menu items
		*/
		var newVisibleMenuArray = new Array();
		for(var no=0;no<top_visibleMenus.length;no++){
			if(top_visibleMenus[no].className!='menuBlock1' && top_visibleMenus[no].id){
				if(!exceptionArray[top_visibleMenus[no].id]){
					var el = top_visibleMenus[no].getElementsByTagName('A')[0];
					top_visibleMenus[no].style.display = 'none';
					var li = document.getElementById('dhtmlgoodies_listItem' + top_visibleMenus[no].id.replace(/[^0-9]/g,''));
					if(li.className.indexOf('over')>0)li.className = li.className.replace(/over/,'');
				}else{				
					newVisibleMenuArray.push(top_visibleMenus[no]);
				}
			}
		}		
		top_visibleMenus = newVisibleMenuArray;		
	}
	
	function top_mouseOverMenu()
	{
		top_menuActive = true;		
	}
	
	function top_mouseOutMenu()
	{
		top_menuActive = false;
		top_timerAutoHide();	
	}
	
	function top_timerAutoHide()
	{
		if(top_menuActive){
			top_hideTimer = 0;
			return;
		}
		
		if(top_hideTimer<top_timeBeforeAutoHide){
			top_hideTimer+=100;
			setTimeout('top_timerAutoHide()',99);
		}else{
			top_hideTimer = 0;
			top_autohideMenuItems();	
		}
	}
	
	function top_autohideMenuItems()
	{
		if(!top_menuActive){
			top_hideMenuItems(new Array());	
			if(top_activeMenuItem)top_activeMenuItem.className=top_activeMenuItem.className.replace(/over/,'');		
		}
	}
	
	
	function top_initSubMenus(inputObj,initOffsetLeft,currentDepth)
	{	
		var subUl = inputObj.getElementsByTagName('UL');
		if(subUl.length>0){
			var ul = subUl[0];
			
			ul.id = 'subOf' + inputObj.id.replace(/[^0-9]/g,'');
			ul.setAttribute('currentDepth' ,currentDepth);
			ul.currentDepth = currentDepth;
			ul.className='menuBlock' + currentDepth;
			ul.onmouseover = top_mouseOverMenu;
			ul.onmouseout = top_mouseOutMenu;
			top_currentZIndex+=1;
			ul.style.zIndex = top_currentZIndex;
			top_menuBlockArray.push(ul);
			var topPos = top_getTopPos(inputObj);
			var leftPos = top_getLeftPos(inputObj)/1 + initOffsetLeft/1;			
			ul = top_dhtmlgoodies_menuObj.appendChild(ul);
			ul.style.position = 'absolute';
			ul.style.left = leftPos + 'px';
			ul.style.top = topPos + 'px';
			var li = ul.getElementsByTagName('LI')[0];

			while(li){
				if(li.tagName=='LI'){	
					li.className='currentDepth' + currentDepth;					
					li.id = 'dhtmlgoodies_listItem' + top_liIndex;
					top_liIndex++;				
					var uls = li.getElementsByTagName('UL');
					li.onmouseover = top_showHideSub;

					if(uls.length>0){
						var offsetToFunction = li.getElementsByTagName('A')[0].offsetWidth+2;
						if(top_navigatorVersion<6 && top_MSIE)offsetToFunction+=15;	// MSIE 5.x fix
						top_initSubMenus(li,offsetToFunction,(currentDepth+1));
					}	
					if(top_MSIE){
						var a = li.getElementsByTagName('A')[0];
						a.style.width=li.offsetWidth+'px';
						a.style.display='block';
					}					
				}
				li = li.nextSibling;
			}
			ul.style.display = 'none';	
			if(!document.all){
				//top_dhtmlgoodies_menuObj.appendChild(ul);
			}
		}	
	}


	function resizeMenu()
	{
		var offsetParent = top_getLeftPos(top_dhtmlgoodies_menuObj);
		
		for(var no=0;no<top_menuBlockArray.length;no++){
			var leftPos = top_menuBlockArray[no].style.left.replace('px','')/1;
			top_menuBlockArray[no].style.left = leftPos + offsetParent - top_menuParentOffsetLeft + 'px';
		}
		top_menuParentOffsetLeft = offsetParent;
	}
	
	/* 
	Initializing menu 
	*/
	function initTopMenu()
	{
		top_dhtmlgoodies_menuObj = document.getElementById('top_menu');
		
		
		var aTags = top_dhtmlgoodies_menuObj.getElementsByTagName('A');
		for(var no=0;no<aTags.length;no++){			

			var subUl = aTags[no].parentNode.getElementsByTagName('UL');
			if(subUl.length>0 && aTags[no].parentNode.parentNode.parentNode.id != 'top_menu'){
				var img = document.createElement('IMG');
				img.src = top_dhtmlgoodies_menu_arrow;
				aTags[no].appendChild(img);				

			}

		}
				
		var mainMenu = top_dhtmlgoodies_menuObj.getElementsByTagName('UL')[0];
		mainMenu.className='menuBlock1';
		mainMenu.style.zIndex = top_currentZIndex;
		mainMenu.setAttribute('currentDepth' ,1);
		mainMenu.currentDepth = '1';
		mainMenu.onmouseover = top_mouseOverMenu;
		mainMenu.onmouseout = top_mouseOutMenu;		

		var mainMenuItemsArray = new Array();
		var mainMenuItem = mainMenu.getElementsByTagName('LI')[0];
		mainMenu.style.height = mainMenuItem.offsetHeight + 2 + 'px';
		while(mainMenuItem){
			
			mainMenuItem.className='currentDepth1';
			mainMenuItem.id = 'dhtmlgoodies_listItem' + top_liIndex;
			mainMenuItem.onmouseover = top_showHideSub;
			top_liIndex++;				
			if(mainMenuItem.tagName=='LI'){
				mainMenuItem.style.cssText = 'float:left;';	
				mainMenuItem.style.styleFloat = 'left';
				mainMenuItemsArray[mainMenuItemsArray.length] = mainMenuItem;
				top_initSubMenus(mainMenuItem,0,2);
			}			
			
			mainMenuItem = mainMenuItem.nextSibling;
			
		}

		for(var no=0;no<mainMenuItemsArray.length;no++){
			top_initSubMenus(mainMenuItemsArray[no],0,2);			
		}
		
		top_menuParentOffsetLeft = top_getLeftPos(top_dhtmlgoodies_menuObj);	
		//window.onresize = resizeMenu;	
		top_dhtmlgoodies_menuObj.style.visibility = 'visible';	
	}