function pulldownMenu(strParamMenuRootId,strParamInstanceName)
{
	this.strMenuRootId = strParamMenuRootId;
	this.strInstanceName = strParamInstanceName;

	this.nodeMenuRoot = new Object();

	this.intMenuTimeout = 400;
	
	this.strDebugLogId = '';
	this.nodeDebugLog = new Object();
	this.blnDebug = false;
	


	pulldownMenu.prototype.init = function()
	{
		blnError = this.setRootNode();
		if (!blnError)
		{
			this.setEventHandlers();
		}
		if (this.strDebugLogId!='' && this.blnDebug==true)
		{
			this.nodeDebugLog = document.getElementById(this.strDebugLogId);
		}
	}

	

	pulldownMenu.prototype.log = function(strValue)
	{
		if (this.blnDebug)
		{
			if (this.nodeDebugLog && this.nodeDebugLog.innerHTML)
			{
				this.nodeDebugLog.innerHTML = this.nodeDebugLog.innerHTML + strValue;
			}
			if (this.nodeDebugLog && this.nodeDebugLog.value)
			{
				this.nodeDebugLog.value = this.nodeDebugLog.value + strValue +"\n";
			}
		}
		
	}


	
	pulldownMenu.prototype.setRootNode = function()
	{
		if (!document.getElementById) return true;
		this.nodeMenuRoot = document.getElementById(this.strMenuRootId);

		var blnError = true;
		if (this.nodeMenuRoot && this.nodeMenuRoot.nodeType && this.nodeMenuRoot.nodeType==1)
		{
			blnError = false;
		}

		return blnError;
	}



	pulldownMenu.prototype.setEventHandlers = function()
	{
		var arrLiNodes = this.nodeMenuRoot.getElementsByTagName('li');
		
		for (var i=0;i<arrLiNodes.length;i++)
		{
			nodeLi = arrLiNodes[i];
			nodeLi.pointer = this;
			
			nodeLi.onmouseover = function(e) { this.pointer.doMouseOver(this, e) }
			nodeLi.onmouseout  = function(e) { this.pointer.doMouseOut(this, e) }
		}
	}



	pulldownMenu.prototype.doMouseOver = function(nodeSource, e)
	{
		if (e)
		{
				// Moz
			if (e.target)
			{
				nodeEventSource = e.target;
				if (nodeEventSource = nodeSource) 
				{
					if (nodeEventSource.nodeName && nodeEventSource.nodeName.toLowerCase() == 'li' && this.getDistanceToRoot(nodeEventSource)==0) {
						this.hideOtherSubmenus(nodeSource);
					}
					else
					{
						//e.cancelBubble = true;
						if (e.stopPropagation) 
						{
							// this.log('stopPropagation');
							e.stopPropagation();
						}
					}
				}
				else
				{
					if (e.stopPropagation) e.stopPropagation();
				}
			}
		}
		else
		{
				// IE, no event bybbling issues or whatever
			this.hideOtherSubmenus(nodeSource);
		}
		
		this.showSubmenu(nodeSource);
		if (window.pulldownMenuTimer) window.clearTimeout(window.pulldownMenuTimer);
	}


	pulldownMenu.prototype.doMouseOut = function(nodeSource, e)
	{
		if (nodeSource.nodeName.toLowerCase()!='li') return;
		if (window.pulldownMenuTimer) window.clearTimeout(window.pulldownMenuTimer);
		window.pulldownMenuTimer = window.setTimeout(this.strInstanceName+'.hideTimed()',this.intMenuTimeout);
		//alert('mouseOut');
	}
	

	
	pulldownMenu.prototype.showSubmenu = function(nodeSource)
	{
		arrNodesUl = nodeSource.getElementsByTagName('ul');
		
		for (var i=0;i<arrNodesUl.length;i++)
		{
			arrNodesUl[i].style.display = 'block';
			// this.log('showSubmenu, display:block');
		}
	}
	
	
	
	pulldownMenu.prototype.hideTimed = function()
	{
		this.hideAllSubmenus();
	}
		

	pulldownMenu.prototype.hideAllSubmenus = function()
	{
		arrNodesUl = this.nodeMenuRoot.getElementsByTagName('ul');
		
		for (var i=0;i<arrNodesUl.length;i++)
		{
			arrNodesUl[i].style.display = 'none';
			// this.log('hideAllSubmenus, display:none');
		}
	}


	pulldownMenu.prototype.hideOtherSubmenus = function(nodeSource)
	{
		arrNodesUl = this.nodeMenuRoot.getElementsByTagName('ul');
		nodeSourceParentUl = nodeSource.parentNode;
		
		for (var i=0;i<arrNodesUl.length;i++)
		{
			if (arrNodesUl[i]!=nodeSourceParentUl && arrNodesUl[i].parentNode!=nodeSource)
			{
				arrNodesUl[i].style.display = 'none';
			}
		}
	}
	

	pulldownMenu.prototype.getDistanceToRoot = function(nodeSource)
	{
		var intDistance = 0;
		
		nodeWorking = nodeSource;
		while(nodeWorking.parentNode && nodeWorking.parentNode!=this.nodeMenuRoot)
		{
			nodeWorking = nodeWorking.parentNode;
			if (nodeWorking.nodeName.toLowerCase()=='ul')
			{
				intDistance++;
			}
			if (nodeWorking==this.nodeMenuRoot)
			{
				break;
			}
		}			
		
		return intDistance;
	}



	pulldownMenu.prototype.getFirstParentLi = function(nodeSource)
	{
		nodeWorking = nodeSource;
		while(nodeWorking.parentNode)
		{
			if (nodeWorking.nodeName.toLowerCase()=='li')
			{
				break;
			}
		}			
		
		return nodeWorking;
	}

	
/*
	pd_menu.prototype.mouseOver = function(myId,lvl0,lvl1,lvl2) {
    if (window.pd_menu_timer) window.clearTimeout(window.pd_menu_timer);
    this.hideAll('root',lvl0,lvl1,lvl2);
	}
  // *****
	pd_menu.prototype.mouseOut = function(myId,lvl0,lvl1,lvl2) {
		if (window.pd_menu_timer) window.clearTimeout(window.pd_menu_timer);
		window.pd_menu_timer = window.setTimeout(this.myInstanceName+'.hideTimed()',this.menuTimeOut);
	}
  // *****
	pd_menu.prototype.hideTimed = function() {
	  this.hideAll('root',-1,-1,-1);
    this.showSelected();
	}
	*/

















}