
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function cross(left1, top1, width1, height1, left2, top2, width2, height2)
{
	if (left1 >= left2 && left1 <= left2 + width2 && top1 >= top2 && top1 <= top2 + height2)	
		return (true);	
		
	if (left1 + width1 >= left2 && left1 + width1 <= left2 + width2 && top1 >= top2 && top1 <= top2 + height2)	
		return (true);
	
	if (left1 >= left2 && left1 <= left2 + width2 && top1+ height1 >= top2 && top1+height1 <= top2 + height2)	
		return (true);
	
	if (left1+width1 >= left2 && left1+ width1 <= left2 + width2 && top1+ height1 >= top2 && top1+height1 <= top2 + height2)	
		return (true);

	if (left1 <= left2 && left1 + width1 >= left2 + width2 && top1 >= top2 && top1 <= top2 + height2)
		return (true);

	if (left1 <= left2 && left1 + width1 >= left2 + width2 && top1 + height1 >= top2 && top1 + height1 <= top2 + height2)
		return (true);
		
	return (false);		
}

function setVisibility(obj, status)
{
	var form;
	for (var i = 0 ; i < document.forms.length ; i++)
		{
		form = window.document .forms[i];				
		for (var j=0; j< form.elements.length; j++)
			{	
			if (form.elements[j].type == "select-one" || form.elements[j].type == "select-multiple" )
				{																
				var item = form.elements[j];				
				if (cross(findPosX(item), findPosY(item), item.offsetWidth, item.offsetHeight, findPosX(obj), findPosY(obj), obj.offsetWidth, obj.offsetHeight))																		
					{
					form.elements[j].style.visibility = status;																								
					}
				}
			}
		}
}


function nh_HideDivTags(sDivToShow) 
{	
	var pDivs = "";
	if (document.all)
		pDivs  = document.all.tags("div");	
	else
		pDivs  = document.getElementsByTagName("div");				
		
	var vArr = sDivToShow.split("_");
	var vArrDiv;
	for (var i=0; i<pDivs.length; i++) 
	{		
		vArrDiv = (pDivs[i].id).split("_");
		if ( ( vArrDiv[0] == vArr[0] ) || (vArr[0].length < vArrDiv[0].length) )
		{		
			setVisibility(pDivs[i], 'visible')					
			pDivs[i].className = "nhMenuhide";						
		}			
	}	
}

function nh_Toggle(pDiv, sCss) 
{	
	
	var vArr = pDiv.split("_");
	nh_HideDivTags(pDiv);	
	if (document.all)
		pDiv = document.all[pDiv];
	else
		pDiv = document.getElementById(pDiv);		

	if (pDiv) 
		{		
		if (pDiv.className = "nhMenuhide")
			{			
			pDiv.className = ("nhMenushow"+sCss);						
			setVisibility(pDiv, 'hidden')					

			}
		else
			{	
			setVisibility(pDiv, 'visible')												
			pDiv.className = "nhMenuhide";											
			}			
	}			
	return(false);	
}

function nh_OnMouseOutCheck(pDiv) 
{
	if (document.all)
		if (!document.all[pDiv].contains(event.toElement)) 
			{				
			nh_HideDivTags(pDiv);							
			}
}

