<!--
//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2006-2007 by eoVision, L.L.C. All Rights Reserved.
// This file is used by permission.
//*****************************************************************************
var target=null;
var starttimer = null;
var stoptimer = null;

var browser = navigator.userAgent.toLowerCase();
function toggleFormElements(show, d){
	if (!document.all || browser.indexOf('opera')>-1){
		return;
	}
	if (!document.forms)
		return;
	for (var x=0; x<document.forms.length; x++){
		var f=document.forms[x];
		for(var i=0;i<f.elements.length;i++){
			var el = f.elements[i];
			if (f.elements[i].tagName=='SELECT' && (show || hitTest(f.elements[i], d))){
				el.style.visibility=(show)?"inherit":"hidden";
			}
		}
	}
}

function hitTest(s, d){
	var top;
	var o;
	var selTop;
	var selHeight;
	if (!d){
		return 0;
	}
	o=d.firstChild;
	top=0;
	while (o.offsetParent){
		top += o.offsetTop;
		o = o.offsetParent;
	}
	
	selTop=0;
	selHeight=s.offsetHeight;
	while (s.offsetParent){
		selTop += s.offsetTop;
		s = s.offsetParent;
	}
	if (top < (selTop+selHeight) && (top+d.firstChild.offsetHeight) > selTop)
		return 1;
	return 0;
}

function windowHeight() {
	var height;
	if (window.innerHeight){
		height = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		height = document.documentElement.clientHeight;
	} else {
		height = document.body.clientHeight;
	}
	if (window.pageYOffset)
		return height + window.pageYOffset;
	if (document.documentElement && document.documentElement.scrollTop)
		return height + document.documentElement.scrollTop;
	return height + document.body.scrollTop;
}

function findX(o,d){
	var liLeft = 0;
	
	if (o.x)
		return o.x;
		
	while (o.offsetParent){
		liLeft += o.offsetLeft;
		o = o.offsetParent;
	}
	return liLeft-5;
}

function findY(o,d){
	var winY, curY, liTop = 0;
	var divHeight;
	
	if (o.y)
		return o.y+20;
		
	divHeight = o.offsetHeight * d.firstChild.childNodes.length;

	while (o.offsetParent){
		liTop += o.offsetTop;
		o = o.offsetParent;
	}
	
	winY = windowHeight();
	curY = (liTop + divHeight) - winY;
	
	if (curY > 0){
		liTop -= (curY + 20);
		if (browser.indexOf('opera')>-1)
			liTop -= 10;
	}
	else
		liTop -= 5;
	return liTop+20;
}

function menuoff(li){
	if (stoptimer)
    	clearTimeout(stoptimer);
	if (starttimer)
		clearTimeout(starttimer);
	stoptimer = setTimeout('hide()', 300);
}

function menuon(li){
	if (starttimer)
		clearTimeout(starttimer);
	target=li;
	starttimer = setTimeout('show("' + li.id + '")', 10);
}

function loadMenu(o,d){
	var items = menu_array[o];
	var ul = document.createElement("UL");
	
	if (d.firstChild)
		d.removeChild(d.firstChild);
	d.appendChild(ul);
	for(var i=0;i<items.length; i++){
		var li, a;
		if ( items[i] == null )
			continue;		
		li = document.createElement("LI");
		ul.appendChild(li);
		a = document.createElement("A");
		a.href = items[i].Link;
		a.innerHTML = items[i].Name;
		a.onmouseover=stopTimer;
		li.appendChild(a);
	}
}

function show(o){
	var d;
	if (stoptimer)
		clearTimeout(stoptimer);
	d = document.getElementById('sub-div');
	loadMenu(o,d);
	d.style.top="" + findY(target,d) + "px";
	d.style.left="" + findX(target,d) + "px";
	d.className='submenu-sh';
	toggleFormElements(0, d);
}

function hide(){
	var d = document.getElementById('sub-div');
	if (d.firstChild)
		d.removeChild(d.firstChild);
	d.className='submenu';
	toggleFormElements(1);
}
function stopTimer(){
	if (stoptimer) clearTimeout(stoptimer);
	if (starttimer) clearTimeout(starttimer);
}
function initmenus(){
	if(!document.getElementById)
		return;
	var d = document.getElementById('sub-div');
	var m = document.getElementById('navigation');
	
	if (m && d){
		d.onmouseover=stopTimer;
		d.onmouseout=new Function("menuoff(this.parentNode);");
		for(var i=0;i<m.childNodes.length; i++){
			var c = m.childNodes[i];
			if(c.nodeType == 1 && c.firstChild.tagName == 'A' && menu_array[c.id] != null ){
				c.firstChild.onmouseover=new Function("menuon(this.parentNode);");
				c.firstChild.onmouseout=new Function("menuoff(this.parentNode);");
			}
			
		}
	}
}
initmenus();
//-->