var targetLastSM = null;
var ppcSM = false;


function hideSubMenu(obj, obj2) {
	targetLastSM = null;
	obj.style.visibility = "hidden";
	obj2.style.visibility = "hidden";
	ppcSM = false;
}


function getSubMenuFor(target){
	ppcSV = target;

	if ((ppcSV != null)&&(ppcSV))
	{
			var obj = document.all['subm' + target.name];
			var obj2 = document.all['fsubm' + target.name];

			// clear prev menu if opened
			if(targetLastSM != null )
			{
				if(targetLastSM.name != target.name )
				{	
					document.all['subm' + targetLastSM.name].style.visibility = "hidden";
					document.all['fsubm' + targetLastSM.name].style.visibility = "hidden";
					targetLastSM = null;
				}
			}

			if(obj.style.visibility == "hidden")
			{	var iX = 0 , iY = target.offsetHeight + 1;
				var oP;
				for(  oP = target; oP != null; oP = oP.offsetParent )
				{	iY += oP.offsetTop; iX += oP.offsetLeft;
				}
				obj.style.left = iX; //document.body.scrollLeft+event.clientX; 
				obj.style.top  = iY; //document.body.scrollTop+event.clientY;
				obj.style.visibility = "visible";
				obj2.style.left = iX; 
				obj2.style.top  = iY; 

				obj2.style.width = obj.clientWidth; 
				obj2.style.height  = obj.clientHeight; 

				obj2.style.visibility = "visible";
				targetLastSM = target;
			}else{
//				hideSubMenu(obj, obj2);
				obj.style.visibility = "hidden";
				obj2.style.visibility = "hidden";
			}
	}else{
		showErrorSM(ppcER[0]);
	}
	ppcSM=true;
}


function showErrorSM(message) {
	window.alert("[ PopUp SubMenu ]\n\n" + message);}
