<!--
/* Copyright 2006. Epic Sports, Inc. */
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 swapImg(a,t){
	var img=a.firstChild;
	var s;
	
	s=img.src.replace("-on", "-");
	s=s.replace("-off", "-");
	s=s.replace("-", "-"+t);
	
	img.src=s;
	return false;
}
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 findY(o,d){
	var winY, curY, liTop = 0;
	var divHeight;
	
	if (o.y)
		return o.y;
		
	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;
}

function findX(o,d)
{
	var width = o.offsetWidth;
	var liLeft = 0;
	while (o.offsetParent)
	{
		liLeft += o.offsetLeft;
		o = o.offsetParent;
	}
	return liLeft + width - 35;
}

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 + '")', 300);
}

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;
		if (items[i].IsRes) { a.className = 'priority_catmenu'; }
		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 && menu_array[c.id] != null && c.firstChild != null)
			{
				if (c.firstChild.tagName == 'A')
				{
					c.firstChild.onmouseover=new Function("menuon(this.parentNode);");
					c.firstChild.onmouseout=new Function("menuoff(this.parentNode);");
				}
				else if (c.firstChild.nextSibling != null && c.firstChild.nextSibling.tagName == 'A')
				{
					c.firstChild.nextSibling.onmouseover=new Function("menuon(this.parentNode);");
					c.firstChild.nextSibling.onmouseout=new Function("menuoff(this.parentNode);");
				}
			}
		}
	}
}
initmenus();
//-->