var maxitems = 12; // How many items are allowed to show
var menuwidth='225' //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)
{
		try
		{
			if(!e&&event) e = event;
			var mo = obj.parentNode;
			while(mo&&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);
			try 
			{
				ensureSize(mo);
			} 
			catch(ex)
			{
			}
			clearhide();
			hideMore();
			showhide(mo.style, e, "visible", "hidden", "");
			mo.onmouseover = clearhide;
			mo.onmouseout = delayhidemenu2;
				//lastMenu = mo;
			//alert(mo.style.visibility);
			//alert('g');
			
			obj.className = 'dropdownBox3';
			//obj.setAttribute("class", "dropDownBox3"); 
			return clickreturnvalue();
	}
	catch(e)
	{
	}
}
function getText(obj)
{
	try
	{
		if(obj.innerText) return obj.innerText.replace(/\s+/gi, " ");
		if(obj.textContent) return obj.textContent.replace(/\s+/gi, " ");
		return obj.innerText;
	}
	catch(e)
	{
	}
}
function findChildByNode(obj, node)
{
		try
		{
			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;
		}
		catch(e)
		{
		}
}


function ensureSize(obj)
{
	try
	{
		if(!obj.style.width)
		{
			var maxlength = 10;
			var robj = findChildByNode(obj, "TABLE").rows;
			for(var i=0; i<robj.length; i++)
				if(getText(robj[i]).length>maxlength)
					maxlength = getText(robj[i]).length;
			obj.style.width = (7*maxlength)+20 + "px";
			//obj.style.cssText+="width:" + ((7*maxlength)+20) + "px;";
		}
		var rs = findChildByNode(obj, "TABLE").rows;
		var rc;
		if(ns6)
		{
			for(var i=0; i<rs.length; i++)
			{
				rc = rs[i].firstChild;
				if(rc.nodeName=="#text")
					rc = rc.nextSibling;
				rc.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;
	}
	catch(e)
	{
	
	}
}
function showAll(obj)
{
	try
	{
		var ret = "";
		for(kid in obj)
			ret+=kid+" ";
		return ret;
	}
	catch(e)
	{

	}
}

function clearhide()
{
	try
	{
		if(disID)
			clearTimeout(disID);
		disID = null;

	}
	catch(e)
	{
	}
}


function hideMore()
{
	try
	{
		//alert("hiding");
		for(var kid in menuArr)
			if(menuArr[kid]&&menuArr[kid].style&&menuArr[kid].style.visibility=="visible")
				menuArr[kid].style.visibility="hidden";

	}
	catch(e)
	{
	}
}

function delayhidemenu2(obj)
{
	try
	{
		obj.className = 'dropdownBox2';
		disID = setTimeout("hideMore()", disappeardelay);
	}
	catch(e)
	{
	}
}
function listAll(obj)
{
	try
	{
		var ret = "";
		for(kid in obj)
			ret+=kid+" ";
		return ret;
	}
	catch(e)
	{
	}
}

function getposOffset(what, offsettype)
{
	try
	{
		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;
	}
	catch(e)
	{
	}
		
}


function showhide(obj, e, visible, hidden, menuwidth)
{
	try
	{
		if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
			obj.visibility=visible;
		else if (e.type=="click")
			obj.visibility=hidden;
	}
	catch(e)
	{
	}
}

function iecompattest()
{
	try
	{
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	}
	catch(e)
	{
	}
}


function clickreturnvalue()
{
	try
	{
		if (ie4||ns6)
			return false;
		return true;
	}
	catch(e)
	{
	}
}

function contains_ns6(a, b)
{
	try
	{
		while (b.parentNode)
			if ((b = b.parentNode) == a)
				return true;
		return false;
	
	}
	catch(e)
	{
	}
}


function hidemenu2(e)
{
	try
	{
		if(lastMenu&&lastMenu.style) {
			lastMenu.style.visibility="hidden";
			return true;
		}
		return false;
	}
	catch(e)
	{
	}
}


function hidemenu(e)
{
	try
	{
		if(hidemenu2(e)) return;
		if (typeof dropmenuobj!="undefined")
		{
			if (ie4||ns6)
				dropmenuobj.style.visibility="hidden";
		}
	}
	catch(e)
	{
	}
}

function delayhidemenu()
{
	try
	{
		if (ie4||ns6)
			delayhide=setTimeout("hidemenu()",disappeardelay);
	}
	catch(e)
	{
	}
}

function clearhidemenu()
{
	try
	{
		if (typeof delayhide!="undefined")
			clearTimeout(delayhide);
	}
	catch(e)
	{
	}
}

if (hidemenu_onclick=="yes")
	document.onclick=hidemenu;
