var maxitems = 16; // How many items are allowed to show
var menuwidth='165' //default menu width
var menubgcolor='#EFEFEF'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var lastMenu;
var menuArr = new Array();
var disID;
var ie4=document.all;
var ns6=document.getElementById&&!document.all;
var opera=!(!window.opera);

function showMore(obj, e)
{
	if(!e&&event) e = event;
	var mo = obj;
	if(typeof(mo)=="string")
	{
		mo = document.getElementById(mo);
	}
	else if(typeof(mo)=="object")
	{
		mo = obj.parentNode;	
		
		while(mo&&mo.className != null && mo.className!="NLQ")
			mo = mo.parentNode;
			
		mo = mo.nextSibling;	
		if(mo.nodeName=="#text")
			mo = mo.nextSibling;
	}
	var toadd=true;
	for(var kid in menuArr)
		if(kid==mo) toadd=false;
	if(toadd) menuArr.push(mo);
	mo.style.display = "none";
	try {
		ensureSize(mo);
	} catch(err) { alert(err.message); }
	clearhide();
	hideMore();
	mo.style.display = "";
	showhide(mo.style, e, "visible", "hidden", "");
	mo.onmouseover = clearhide;
	mo.onmouseout = delayhidemenu2;
	//lastMenu = mo;
	//alert(mo.style.visibility);
	return clickreturnvalue();
}
function getText(obj)
{
	if(obj.innerText) return obj.innerText.replace(/\s+/gi, " ").replace(/<[^>]+>/gi, "");
	if(obj.textContent) return obj.textContent.replace(/\s+/gi, " ").replace(/<[^>]+>/gi, "");
	return obj.innerText;
}
function findChildByNode(obj, node)
{
	if(!obj.childNodes) return null;
	for(var i=0; i<obj.childNodes.length; i++)
		if(obj.childNodes[i].nodeName==node)
			return obj.childNodes[i];
	return null;
}
function ensureSizeDiv(obj)
{
	//if(ns6||opera)
		//obj.style.paddingRight = "3px";
}
function ensureSize(obj)
{
	obj.style.display = "";
	if(!obj.style.width)
	{
		var maxlength = 10;
		var robj = findChildByNode(obj, "TABLE");
		if(robj==null) return ensureSizeDiv(obj);
		robj = robj.rows;
		for(var i=0; i<robj.length; i++)
			if(getText(robj[i]).length>maxlength)
				maxlength = getText(robj[i]).length;
		//if(!(ns6||opera)) 
		maxlength += 2;
		var wid = ((5*maxlength)+20);
		obj.style.width = (wid+4) + "px";
		if(!!robj.style)
			robj.style.width = wid + "px";
	}
	var rs = findChildByNode(obj, "TABLE").rows;
		for(var i=0; i<rs.length; i++)
		{
			//window.status = rs[i].firstChild.nodeName;
			if(ns6||opera)
				rs[i].firstChild.style.paddingRight = "3px";
			else
				findChildByNode(rs[i].firstChild, "A").style.paddingRight = "3px";
		}
	//alert(obj.outerHTML);
	//obj.style.cssText+=" overflow:none;";
	var windowedge = (ie4 && !window.opera) ? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
	var rheight = findChildByNode(obj, "TABLE").rows[0].offsetHeight;
	var maxheight = windowedge - obj.offsetTop;
	maxheight = maxheight - (maxheight % rheight);
	if(maxheight>(rheight*maxitems))
		maxheight = (rheight*maxitems);
	//if(ie4)
		maxheight++;
	if(obj.offsetHeight>maxheight)
	{
		obj.style.height = maxheight + "px";
		obj.style.overflow="auto";
	}
	obj.scrollTop = 0;
}
function showAll(obj)
{
	var ret = "";
	for(kid in obj)
		ret+=kid+" ";
	return ret;
}
function clearhide()
{
	if(disID)
		clearTimeout(disID);
	disID = null;
}
function hideMore()
{
	//alert("hiding");
	for(var kid in menuArr)
		if(menuArr[kid]&&menuArr[kid].style&&menuArr[kid].style.visibility=="visible")
		{
			menuArr[kid].style.visibility="hidden";
			menuArr[kid].style.display = "none";
		}
}
function delayhidemenu2()
{
	disID = setTimeout("hideMore()", disappeardelay);
}
function listAll(obj)
{
	var ret = "";
	for(kid in obj)
		ret+=kid+" ";
	return ret;
}

function getposOffset(what, offsettype)
{
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null)
	{
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth)
{
	//if (ie4||ns6)
	//	dropmenuobj.style.left=dropmenuobj.style.top="-500px";
		
	//if (menuwidth!=""){
	//	dropmenuobj.widthobj=dropmenuobj.style;
	//	dropmenuobj.widthobj.width=menuwidth;
	//}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible;
	else if (e.type=="click")
		obj.visibility=hidden;
}

function iecompattest()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function clickreturnvalue(){
	if (ie4||ns6)
		return false;
	return true;
}

function contains_ns6(a, b)
{
	while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
	return false;
}

/*function dynamichide(e)
{
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu();
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu();
}*/

function hidemenu2(e)
{
	if(lastMenu&&lastMenu.style) {
		lastMenu.style.visibility="hidden";
		return true;
	}
	return false;
}
function hidemenu(e)
{
	if(hidemenu2(e)) return;
	if (typeof dropmenuobj!="undefined")
	{
		if (ie4||ns6)
			dropmenuobj.style.visibility="hidden";
	}
}

function delayhidemenu()
{
	if (ie4||ns6)
		delayhide=setTimeout("hidemenu()",disappeardelay);
}

function clearhidemenu()
{
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide);
}

if (hidemenu_onclick=="yes")
	document.onclick=hidemenu;
