var contextMenuArbolTimeOut = null;
var lastMenu = null;

function mostrarMenu (idObject, parentObj, posX) {
	closeMenu ();
	clearTimeOutMenu ();
	
	for (k = 0; k < window.videosHide.length; k++) {
		document.getElementById (window.videosHide[k]).style.display = 'none';
	}
	
	var object =document.getElementById (idObject); 
	
	if (!object) 
		return;
		
	x = moveXbySlicePos (0, parentObj);
	y = moveYbySlicePos (0, parentObj);

	object.style.left = (x - 0 + posX) + "px";
	object.style.top = (y + 24) + "px";
	object.style.display = '';
	
	lastMenu = idObject;
}
		
function initTimeOutMenu () {
	if (contextMenuArbolTimeOut)
		clearTimeout (contextMenuArbolTimeOut);
		
	contextMenuArbolTimeOut = setTimeout ('closeMenu()', 1000);
}
		
function clearTimeOutMenu(){
	if (contextMenuArbolTimeOut)
		clearTimeout (contextMenuArbolTimeOut);
	contextMenuArbolTimeOut = null;
}

function closeMenu(){
	try{
		for (k = 0; k < window.videosHide.length; k++) {
			document.getElementById (window.videosHide[k]).style.display = '';
		}
		
		document.getElementById(lastMenu).style.display = "none";
		lastMenu = null;
	}catch(exc){}
}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}