var contextMenuArbolTimeOut = null;
var contextMenuSoccerTimeOut = null;
var lastMenu 				= null;
var lastMenuSoccer			= null;
var menuChangeColor			= null;
var menuTdObj				= null;
var idImgMenu				= null;

function mostrarMenu (idObject, parentObj, posX, id, changeColor, widthSubMenu, widthPage) {
	closeMenu ();
	clearTimeOutMenu ();
	
	for (k = 0; k < window.videosHide.length; k++) {
		document.getElementById (window.videosHide[k]).style.display = 'none';
	}
	
	menuChangeColor = changeColor;
	menuTdObj		= parentObj;
	idImgMenu		= id;
	
	if (changeColor) {
		parentObj.className 							= "menu_on";
		parentObj.background 							= "site/images/pestana1a.jpg";
		document.getElementById("img_menu_" + id).src 	= "site/images/pestana1b.jpg";
	}
	
	var object =document.getElementById (idObject); 
	
	if (!object) 
		return;
		
	x = moveXbySlicePos (0, parentObj);
	y = moveYbySlicePos (0, parentObj);

	tmp_x = (x - 0 + posX);
	if( (tmp_x + widthSubMenu) > (widthPage + (((screen.width - widthPage)/2)-(18/2)) ) )
		tmp_x = tmp_x - widthSubMenu + parentObj.offsetWidth + 8;
	
	object.style.left = tmp_x + "px";
	object.style.top = (y + 24) + "px";
	object.style.display = '';
	
	lastMenu = idObject;
}
		
function initTimeOutMenu () {
	if (contextMenuArbolTimeOut)
		clearTimeout (contextMenuArbolTimeOut);
		
	contextMenuArbolTimeOut = setTimeout ('closeMenu()', 100);
}
		
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 = '';
		}
		if (menuTdObj && menuChangeColor && idImgMenu != null) {
			menuTdObj.className 									= "menu_off";
			document.getElementById("img_menu_" + idImgMenu).src 	= "site/images/pestana2b.jpg";
		}
		
		document.getElementById(lastMenu).style.display = "none";
		
		lastMenu 		= null;
		menuChangeColor = null;
		menuTdObj		= null;
		idImgMenu		= 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;
}

/* Daniel Mejia*/

function selectDock(id, dock_size, text){
	var nameTSelect = document.getElementById('nameTSelect');
	if (nameTSelect){
		nameTSelect.innerHTML = "<b>" + text + "</b>";
	}
/*				for (i = 0; i<dock_size;i++){
		var dockItem = document.getElementById('showesc'+i);
		var divItem = document.getElementById('divshowesc'+i);
		if (dockItem){
			if (i == id-2 || i == id+2){
				dockItem.style.width="15px";
				divItem.style.width="15px";
				dockItem.style.height="15px";							
			} else if (i == id-1 || i == id+1){
				dockItem.style.width="20px";
				divItem.style.width="20px";
				dockItem.style.height="20px";
			} else if (i == id){
				dockItem.style.width="30px";
				divItem.style.width="30px";
				dockItem.style.height="30px";
			} else {
				dockItem.style.width="10px";
				divItem.style.width="10px";
				dockItem.style.height="10px";
			} 
		}
	}*/
}

function restoreDock(dock_size){
	for (i = 0; i<dock_size;i++){
		var dockItem = document.getElementById('showesc'+i);
		if (dockItem){
//						dockItem.style.width="10px";
//						dockItem.style.height="10px";
		}
	}
}
function showIcons( id_soccer ){
	hideIcons();
	lastMenuSoccer = id_soccer;	
	var ic = document.getElementById(lastMenuSoccer);
	if (ic){
		ic.style.left = 0;
		ic.style.zIndex = 100;			
		clearTimeOutSoccerMenu ();	
	}
}

function hideIcons(){
	if (lastMenuSoccer){
		var ic = document.getElementById(lastMenuSoccer)
		if (ic){
			ic.style.zIndex = 80;			
			ic.style.left = -110;
		}
	}
}

function clearTimeOutSoccerMenu(){
	if (contextMenuSoccerTimeOut)
		clearTimeout (contextMenuSoccerTimeOut);
	contextMenuSoccerTimeOut = null;
}

function initTimeOutSoccerMenu () {
	if (contextMenuSoccerTimeOut)
		clearTimeout (contextMenuSoccerTimeOut);		
	contextMenuSoccerTimeOut = setTimeout ('hideIcons()', 300);
}
