var maxitems = 3000; // How many items are allowed to show
var menuwidth='165' //default menu width
var menubgcolor='#BBEDE3'  //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 bIsopera=!(!window.opera);

function showMore(obj, e)
{

	if(!e&&event) e = event;
	var 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);
	try {
		ensureSize(mo);
	} catch(err) {  }
	clearhide();
	hideMore();
	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, " ");
	if(obj.textContent) return obj.textContent.replace(/\s+/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 ensureSize(obj)
        {
              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 = (5*maxlength)+22;
              }
              var rs = findChildByNode(obj, "TABLE").rows;
              if(ns6)
                    for(var i=0; i<rs.length; i++)
                          rs[i].firstChild.style.paddingRight = "3px";
              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;
              var defaultheight = (rs.length * rheight);//obj.scrollHeight - (obj.scrollHeight % rheight);
              maxheight = maxheight - (maxheight % rheight);
              if(maxheight>(rheight*maxitems))
                    maxheight = (rheight*maxitems);
                
              if(ie4) 
              {
                  maxheight++;
                  defaultheight++;
              }
                 
              if((obj.offsetHeight>maxheight) || (defaultheight>maxheight))
              {
                    //obj.style.height = maxheight + "px";
                    obj.style.overflow="auto";
              }
              else 
              {
                 //obj.style.height = defaultheight + "px";
                 obj.style.overflow="auto";
              }
                  
              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";
}
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 clearbrowseredge(obj, whichedge, dropmenuobj)
{
	var edgeoffset = 0;
	if (whichedge=="rightedge"){
		var windowedge = (ie4 && !window.opera) ? (iecompattest().scrollLeft+iecompattest().clientWidth-15) : (window.pageXOffset+window.innerWidth-15);
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth;
	}else{
		var topedge = (ie4 && !window.opera) ? iecompattest().scrollTop : window.pageYOffset;
		var windowedge = (ie4 && !window.opera) ? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
		var maxheight = (windowedge - dropmenuobj.y - (ie4 ? 7 : 14));
		maxheight = (dropmenuobj.firstChild.offsetHeight * maxitems)<maxheight?(dropmenuobj.firstChild.offsetHeight * maxitems):maxheight;
		alert(maxheight);
		
		while(maxheight%dropmenuobj.firstChild.offsetHeight > 0)
			maxheight--;
		if(ie4) maxheight++;
		
		dropmenuobj.className = "menunoscroll";
		dropmenuobj.style.height = "";
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;
		//if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
		//	alert("Move Up");
			//edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight;
		//alert(dropmenuobj.firstChild.offsetHeight);
		if (dropmenuobj.offsetHeight > maxheight) //up no good either?
		{
			//alert(dropmenuobj.style.height);
			dropmenuobj.className = "menuscroll";
			dropmenuobj.style.height = maxheight + "px";
		}
			//alert("Move Down");
			//edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge;
		//}
	}
	return edgeoffset;
}

function populatemenu(what)
{
	if (ie4||ns6)
		dropmenuobj.innerHTML=what.join("");
}

function dropdownmenu(obj, e, menunum)
{
	if(window.event)
		event.cancelBubble = true;
	else if (e.stopPropagation)
		e.stopPropagation();

	var menu = document.getElementById("ansList"+menunum);	
	
	try {
	if(lastMenu&&lastMenu.style)
		showhide(lastMenu.style, e, "visible", "hidden");
	} catch(err) { }
	
	try {
		clearhidemnu();
	} catch(err) { }
	
	if(ie4||ns6)
	{
		showhide(menu.style, e, "visible", "hidden");
		menu.x=getposOffset(obj, "left");
		menu.y=getposOffset(obj, "top");
		menu.style.left=menu.x-clearbrowseredge(obj, "rightedge", menu)+"px";
		menu.style.top=menu.y-clearbrowseredge(obj, "bottomedge", menu)+obj.offsetHeight+"px";
	}
	lastMenu = menu;
	return clickreturnvalue();
}*/
/*function dropdownmenu(obj, e, menucontents, menuwidth)
{
	if (window.event)
		event.cancelBubble=true;
	else if (e.stopPropagation)
		e.stopPropagation();

	clearhidemenu();
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv;
	populatemenu(menucontents);

	if (ie4||ns6)
	{
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth);
		dropmenuobj.x=getposOffset(obj, "left");
		dropmenuobj.y=getposOffset(obj, "top");
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px";
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";
	}

	return clickreturnvalue()
}*/

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;
