var trrscript = typeof(trrscript) == "undefined"?false:trrscript;

function showNodes(node, showNode){
	var i;
	if (node.childNodes) {
		if (node.nodeName=="A"){
			node.setAttribute('trr.show',showNode);}
		else {
			for (i=0; i<node.childNodes.length; i++) {
				showNodes(node.childNodes[i], showNode);}}
	}
	return 0;
}

startList = function() {
	if (document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (document.all && node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
			for (j=0; j<node.childNodes.length; j++) {
				chld = node.childNodes[j];
				if (chld.nodeName=="A" && node.childNodes.length>1) {
					chld.onmouseover=function(e) {
						for (n=0; n<this.parentNode.childNodes.length; n++) {
							var subMenu = this.parentNode.childNodes[n];
							if (subMenu.nodeName=="UL")
							{
								showNodes(subMenu,"1");

								if(document.all) subMenu.style.display = 'block';
								var size = subMenu.clientHeight;
								var top = 0;
								if(document.all)
									top = event.clientY;
								else
									top = (e.pageY - window.pageYOffset);
								top += size;
								if(document.all) subMenu.style.display = '';

								var doc = (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
								var screen = doc.clientHeight;
								if(top > screen) 
								{
									if(subMenu.style.top.indexOf('-')>-1) top += parseFloat(subMenu.style.top);
									if(top > screen)
									{
										if(subMenu.style.top.indexOf('-')>-1) top -= parseFloat(subMenu.style.top);
										subMenu.style.top = (-1*(top - screen)) + 'px';
									}
								}
								else subMenu.style.top = 0 + 'px';
							}
						}
						if (trrscript)
							init();
					}
					chld.onmouseout=function(e) {
						for (n=0; n<this.parentNode.childNodes.length; n++) {
							subMenu = this.parentNode.childNodes[n];
							if (subMenu.nodeName=="UL")
							{
								showNodes(subMenu,"0");
							}
						}
						if (trrscript)
							init();
					}
				}
			}	
		}
	}
}


if (window.onload) {
	var old_win_onload = window.onload;
	window.onload = function(ev) {
		old_win_onload(ev);
		startList();
	};
} 
else
	window.onload = startList;
