//******************** Usage Example ********************
/*
<div id="divAdmMenu" style="position:relative; z-index:5;"></div>
<script language="Javascript" type="text/javascript">
	var divMenu = getDocumentLayer("divAdmMenu");

	var objMenu = new objMenu_Class(divMenu, document.location, "vertical", "down", "", "", false, false);
	objMenu.intElementsWidth = 134;
	objMenu.intElementsHeight = 13;

	objMenu.addElement("texto", "link", "menuLink", "menuLink_Over");
	objMenu.arrElements[0].addSubMenu("vertical", "right", "top");
	objMenu.arrElements[0].subMenu.intElementsWidth = 140;
	objMenu.arrElements[0].subMenu.strBackGroundClass = "menu_background";
	objMenu.arrElements[0].subMenu.strSepLineStyle = "1px solid green";

	objMenu.arrElements[0].subMenu.addElement("texto", "link", "menuLink", "menuLink_Over");
	objMenu.arrElements[0].subMenu.arrElements[0].addSubMenu("vertical", "right", "top");
	objMenu.arrElements[0].subMenu.arrElements[0].subMenu.intElementsWidth = 300;

	objMenu.arrElements[0].subMenu.arrElements[0].subMenu.addElement("texto", "link", "menu_head", "menu_head");

	// Los elementos que se heredan hay que cambiarlos ANTES de agregar "hijos"
</script>
*/

// Constructores
/**
 * @return objMenuObject Objeto tipo Menú
 * @param obj objContainer Objeto que contiene el menú (un div o un td por ejemplo) [se hereda a los elementos hijos]
 * @param obj objTargetObject Objeto en donde se aplicará el link (document.location ó form) [se hereda a los elementos hijos]
 * @param string strOrientation Orientación del menú (horizontal ó vertical)
 * @param string strGrowTo Dirección hacia donde se expandirá el menú (up,down,left,right)
 * @param string strAlign Alineación del menú expandido, solo utilizado si strGrowTo es:
 				 horizontal
 				 	up, down: left, center, right
 				 vertical
 				 	left, right: top, middle, bottom
 * @param string strBackGroundClass Clase CSS para el div de background, false ó "" implican que NO se utiliza [se hereda a los sub-menús en los elementos hijos]
 * @param string strSepLineStyle Estilo del BORDE que forma la línea de división, false o "" implican que NO se utiliza y los elementos quedan pegados
 * @param obj objOwnerElement Elemento que contiene el menú (en caso de ser un sub-menú), SE INICIALIZA CON FALSE PARA EL MENU PADRE
 * @desc Constructor de la clase Menú
*/

// DEFINICION DE VARIABLES GLOBALES
if (!document.boolIsHmlMenuJSLoaded) {
	var intMainMenuObjectsCounter = 0;

	var objSubMenuDelayElement;
	var objSubMenuTimeout = 0;

	var objDelayHideMenu = new Array();
	var objGlobalTimeOut = new Array();

	var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var sinAppVersion = 0;
	if (isInternetExplorer) {
		sinAppVersion = navigator.appVersion;
		sinAppVersion = sinAppVersion.split(" ");
		sinAppVersion = sinAppVersion[3];
		sinAppVersion = sinAppVersion.substr(0, 3);
		sinAppVersion = 1*sinAppVersion;
	}

	document.boolIsHmlMenuJSLoaded = true;
}

function objMenu_Class(objContainer, objTargetObject, strOrientation, strGrowTo, strAlign, strBackGroundClass, strSepLineStyle, objOwnerElement, boolDrawSeparator) {
	this.rootOverElement = false; // Variable que solo se va a definir en el menu ROOT para saber si ya no estoy sobre ninguna instancia del menú para así ocultarlo...

	this.rootMenu = false; //Variable que indica en CADA MENU cual es el menú ROOT
	this.boolRoot = false; //Indica si es el root menu
	this.MainObjectID = -1;
	if (!objOwnerElement) {
		this.rootMenu = this; // Asignación de esta variable inicial...
		this.boolRoot = true;
		this.MainObjectID = intMainMenuObjectsCounter; // Asignacion de ID
		intMainMenuObjectsCounter++;
	}

	this.objOwnerElement = objOwnerElement;
	this.objContainer = objContainer;
	this.objTargetObject = objTargetObject;
	this.boolDrawSeparator = boolDrawSeparator;

	this.strOrientation = strOrientation;
	this.strGrowTo = strGrowTo;
	this.strAlign = strAlign;

	this.objBackground = false; // Objeto que apunta al DIV de background, solo se define si strBackGroundClass se utiliza
	this.objBackFrame = false; // Objeto que apunta al IFRAME de background, solo se define si strBackGroundClass se utiliza y es para que los selects queden abajo del menu en IE<=6
	this.strBackGroundClass = strBackGroundClass;
	this.strSepLineStyle = strSepLineStyle;

	this.intElementsWidth = 100; // Este tamaño se riega entre los hijos, hay que cambiarlo ANTES de agregar elementos...
	this.intElementsHeight = 15; // Este tamaño se riega entre los hijos, hay que cambiarlo ANTES de agregar elementos...

	this.intLeft = 0;
	this.intTop = 0;

	this.boolShow = true;
	this.boolDrawn = false; // Para ver si ya se dibujo, de modo que solo lo dibujo si lo voy a usar...

	this.parentMenu = false; // Puntero al menú padre

	this.objDefaultElement = false; // Puntero al elemento predeterminado.

	this.objLastExpandedElement = false; // Puntero al ultimo elemento que se expandió, sirve para ocultarlos con eventos del mouse y clicks
	this.intElements = -1; //Ojo, zero based!!!
	this.arrElements = new Array();

	this.addElement = objMenu_addElement;
	this.resize = objMenu_resize;
	this.autoFixWidth = objMenu_autoFixWidth;
	this.draw = objMenu_draw;
	this.show = objMenu_show;
	this.hide = objMenu_hide;
}

/**
 * @return menuElement Objeto tipo Elemento del menú
 * @param obj objOwner Objeto menú que contiene el elemento
 * @param obj objContainer Objeto que contiene el elemento (un div o un td por ejemplo), este se hereda del menú al ejecutar menu.addElement
 * @param obj objTargetObject Objeto en donde se aplicará el link (document.location ó form), este se hereda del menú al ejecutar menu.addElement
 * @param string strText Texto para el elemento
 * @param string strLink Link a la que irá objTargetObject, false => no tiene link y es solo una division o texto informativo
 * @param string strNormalClass Clase CSS para la posición normal del elemento
 * @param string strOverClass Clase CSS para la posición mouseover del elemento
 * @desc Constructor de la clase menuElement
*/
function menuElement(objOwner, objContainer, objTargetObject, strText, strLink, strNormalClass, strOverClass, strNormalPic, strOverPic) {
	this.objOwner = objOwner;
	this.objContainer = objContainer;
	this.objTargetObject = objTargetObject;

	this.strText = strText;
	this.strLink = strLink;
	this.strExtraFlashVars = "";

	this.strNormalClass = strNormalClass;
	this.strOverClass = strOverClass;

	this.strNormalPic = strNormalPic;
	this.strOverPic = strOverPic;

	this.intWidth = this.objOwner.intElementsWidth;
	this.intHeight = this.objOwner.intElementsHeight;

	this.intLeft = 0;
	this.intTop = 0;

	this.boolShow = true;

	this.sepObject = false; //Objeto que contiene el div con la línea de división para este elemento

	this.divObject = document.createElement("div"); //Objeto con el div que hace el elemento visible
	this.divObject.elementObject = this; //Hago una referencia hacia este elemento para poder usar eventos del mouse

	this.subMenu = false;

	this.boolIsFlash = (this.strNormalClass.indexOf(".swf", 0) >= 0);

	this.draw = menuElement_draw;
	this.show = menuElement_show;
	this.hide = menuElement_hide;
	this.refreshSize = menuElement_refreshSize;
	this.forceOverStyle = menuElement_forceOverStyle;

	 // Para definir funciones externas a ejecutar en MouseOver y MouseOut
	this.onMouseOutExternalFunction = false;
	this.onMouseOverExternalFunction = false;
	this.onClickExternalFunction = false;

	this.addSubMenu = menuElement_addSubMenu;
}

// Funciones de Eventos del DIV asociado
function delayed_sub_menu_hide() {
	if (objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement && objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement != objSubMenuDelayElement.elementObject) {
		// Si hay otro menú activo, lo escondo
		objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement.divObject.className = objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement.strNormalClass;
		if (objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement.subMenu) objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement.subMenu.hide();
		objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement = false;
	}

	if (objSubMenuDelayElement.elementObject.subMenu) {
		// Muestro el sub-menú de este
		objSubMenuDelayElement.elementObject.subMenu.show();
	}
	objSubMenuDelayElement.elementObject.objOwner.objLastExpandedElement = objSubMenuDelayElement.elementObject;
}

function menuElementDiv_onmouseover() {
	// Si hay elemento default, le pone la clase normal
	if (this.elementObject.objOwner.rootMenu.objDefaultElement) {
		this.elementObject.objOwner.rootMenu.objDefaultElement.divObject.className = this.elementObject.objOwner.rootMenu.objDefaultElement.strNormalClass;
		if (this.elementObject.objOwner.rootMenu.objDefaultElement.strNormalPic)
			this.elementObject.objOwner.rootMenu.objDefaultElement.divObject.style.backgroundImage = "url('" + this.elementObject.objOwner.rootMenu.objDefaultElement.strNormalPic + "')";
		else
			this.elementObject.objOwner.rootMenu.objDefaultElement.divObject.style.backgroundImage = "";
	}

	// Guarda en el rootmenu el elemento para saber que si estoy sobre alguna instancia del menu
	this.elementObject.objOwner.rootMenu.rootOverElement = this.elementObject;
	objDelayHideMenu[this.elementObject.objOwner.rootMenu.MainObjectID] = this.elementObject.objOwner.rootMenu;

	// Pongo la clase OVER
	this.className = this.elementObject.strOverClass;

	//ONMOUSEOVER  IMAGE
	if (this.elementObject.strOverPic) this.style.backgroundImage = "url('" + this.elementObject.strOverPic + "')";

	if (this.elementObject.objOwner.objOwnerElement) {
		// Si es un elemento perteneciente a un sub-menu, le pongo over al elemento que hace el trigger al sub-menu
		this.elementObject.objOwner.objOwnerElement.divObject.className = this.elementObject.objOwner.objOwnerElement.strOverClass;
	}

	// Si todavia queda tiempo en el timeout de mouseout, borro el timeout.
	if (objGlobalTimeOut[this.elementObject.objOwner.rootMenu.MainObjectID] > 0) clearTimeout(objGlobalTimeOut[this.elementObject.objOwner.rootMenu.MainObjectID]);

	objSubMenuDelayElement = this; //div del elemento sobre el que paso para luego hacer el delay
	objSubMenuTimeout = setTimeout("delayed_sub_menu_hide()", 300);  //Delay para mostrar el submenu del elemento sobre el que paso y esconder el del elemento anterior.

	// Funcion externa de mouseover
	if (this.elementObject.onMouseOverExternalFunction) this.elementObject.onMouseOverExternalFunction(this.elementObject);

	return;
}

function delayed_menu_hide(intID) {
	if (objDelayHideMenu[intID] && objDelayHideMenu[intID].rootOverElement == false && objDelayHideMenu[intID].objLastExpandedElement) {
		// Si No estoy sobre ningun elemento del menu y hay un sub-menu expandido, lo cierro...
		objDelayHideMenu[intID].objLastExpandedElement.divObject.className = objDelayHideMenu[intID].objLastExpandedElement.strNormalClass;
		if (objDelayHideMenu[intID].objLastExpandedElement.subMenu) objDelayHideMenu[intID].objLastExpandedElement.subMenu.hide();
		objDelayHideMenu[intID].objLastExpandedElement = false;

		if (objDelayHideMenu[intID].objDefaultElement) objDelayHideMenu[intID].objDefaultElement.forceOverStyle();
	}
}

function menuElementDiv_onmouseout() {
	// Notifico que no estoy en ninguna instancia del menu y llamo a la funcion que cierra todo el menu
	if (objSubMenuTimeout > 0) clearTimeout(objSubMenuTimeout);

	this.elementObject.objOwner.rootMenu.rootOverElement = false;
	objDelayHideMenu[this.elementObject.objOwner.rootMenu.MainObjectID] = this.elementObject.objOwner.rootMenu;
	objGlobalTimeOut[this.elementObject.objOwner.rootMenu.MainObjectID] = setTimeout("delayed_menu_hide("+this.elementObject.objOwner.rootMenu.MainObjectID+")" , 500);

	this.className = this.elementObject.strNormalClass;

	if (this.elementObject.strNormalPic)
		this.style.backgroundImage = "url('" + this.elementObject.strNormalPic + "')";
	else
		this.style.backgroundImage = "";

	// Funcion externa de mouseout
	if (this.elementObject.onMouseOutExternalFunction) this.elementObject.onMouseOutExternalFunction(this.elementObject);

	return;
}
//******************** Clase MenuElement ********************
function menuElement_forceOverStyle() {
	// Primero escondo el submenu activo en este momento
	// Notifico que no estoy en ninguna instancia del menu y llamo a la funcion que cierra todo el menu
	if (objSubMenuTimeout > 0) clearTimeout(objSubMenuTimeout);

	this.objOwner.rootMenu.rootOverElement = false;
	objDelayHideMenu[this.objOwner.rootMenu.MainObjectID] = this.objOwner.rootMenu;
	delayed_menu_hide(this.objOwner.rootMenu.MainObjectID);

	if (!this.objOwner.boolRoot) {
		// si NO es un elemento del rootMenu, muestro el submenu del elemento padre
		objSubMenuDelayElement = this.objOwner.objOwnerElement.divObject; //div del elemento sobre el que paso para luego hacer el delay
		delayed_sub_menu_hide();
	}
	this.divObject.className = this.strNormalClass;

	if (this.divObject.strNormalPic) this.style.backgroundImage = this.divObject.strNormalPic;

	// Luego muestro el submenu de este elemento
	// Guarda en el rootmenu el elemento para saber que si estoy sobre alguna instancia del menu
	this.objOwner.rootMenu.rootOverElement = this.elementObject;
	objDelayHideMenu[this.objOwner.rootMenu.MainObjectID] = this.objOwner.rootMenu;

	// Pongo la clase OVER
	this.divObject.className = this.strOverClass;
	if (this.objOwner.objOwnerElement) {
		// Si es un elemento perteneciente a un sub-menu, le pongo over al elemento que hace el trigger al sub-menu
		this.objOwner.objOwnerElement.divObject.className = this.objOwner.objOwnerElement.strOverClass;
	}

	// Si todavia queda tiempo en el timeout de mouseout, borro el timeout.
	if (objGlobalTimeOut[this.objOwner.rootMenu.MainObjectID] > 0) clearTimeout(objGlobalTimeOut[this.objOwner.rootMenu.MainObjectID]);

	objSubMenuDelayElement = this.divObject; //div del elemento sobre el que paso para luego hacer el delay
	delayed_sub_menu_hide();

	if (this.onMouseOverExternalFunction) this.onMouseOverExternalFunction(this);

	return;
}

function menuElement_refreshSize() {
	this.divObject.style.width = this.intWidth;
	this.divObject.style.height = this.intHeight;
}

function menuElement_onclick() {
	if (this.elementObject.strLink) {
		this.className = this.elementObject.strNormalClass;

		if (this.elementObject.objOwner.rootMenu && this.elementObject.objOwner.rootMenu.objLastExpandedElement) {
			this.elementObject.objOwner.rootMenu.objLastExpandedElement.divObject.className = this.elementObject.objOwner.rootMenu.objLastExpandedElement.strNormalClass;
			if (this.elementObject.objOwner.rootMenu.objLastExpandedElement.subMenu) this.elementObject.objOwner.rootMenu.objLastExpandedElement.subMenu.hide();
			this.elementObject.objOwner.rootMenu.objLastExpandedElement = false;
		}
		else if (this.elementObject.objOwner.objLastExpandedElement) {
			this.elementObject.objOwner.objLastExpandedElement.divObject.className = this.elementObject.objOwner.objLastExpandedElement.strNormalClass;
			if (this.elementObject.objOwner.objLastExpandedElement.subMenu) this.elementObject.objOwner.objLastExpandedElement.subMenu.hide();
			this.elementObject.objOwner.objLastExpandedElement = false;
		}

		if (this.elementObject.objTargetObject.src) {
			this.elementObject.objTargetObject.src = this.elementObject.strLink;
		}
		else if (this.elementObject.objTargetObject.href) {
			this.elementObject.objTargetObject.href = this.elementObject.strLink;
		}
		else if (this.elementObject.objTargetObject.tagName == "INPUT") {
			this.elementObject.objTargetObject.value = this.elementObject.strLink;
		}
	}

	if (this.elementObject.onClickExternalFunction) this.elementObject.onClickExternalFunction(this.elementObject);

	return;
}

// Funciones del objeto como tal
function menuElement_draw(intLeft, intTop, boolShow) {
	this.intLeft = intLeft;
	this.intTop = intTop;
	this.boolShow = boolShow;

	this.divObject.className = this.strNormalClass;
	if (this.strNormalPic)
		this.divObject.style.backgroundImage = "url('" + this.strNormalPic + "')";
	else
		this.divObject.style.backgroundImage = "";

	if (this.divObject.style.cursor) {
		if (this.strLink) {
			this.divObject.style.cursor = "pointer";
		}
		else {
			this.divObject.style.cursor = "default";
		}
	}

	this.divObject.style.position = "absolute";
	this.divObject.noWrap = true;
	this.divObject.style.width = this.intWidth;
	this.divObject.style.height = this.intHeight;
	this.divObject.style.left = this.intLeft;
	this.divObject.style.top = this.intTop;
	this.divObject.style.zIndex = 10;

	if (this.boolShow) this.divObject.style.display = "inline";
	else this.divObject.style.display = "none";

	this.divObject.onmouseover = menuElementDiv_onmouseover;
	this.divObject.onmouseout = menuElementDiv_onmouseout;
	this.divObject.onclick = menuElement_onclick;

	this.divObject.subMenu = this.subMenu;

	var intTMP = this.strNormalClass.indexOf(".swf", 0);

	if (intTMP >= 0) {
		this.divObject.innerHTML = "" +
	    "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' " +
	    "        codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'" +
	    "        WIDTH='"+this.intWidth+"' HEIGHT='"+this.intHeight+"' ALIGN=''>" +
	    "     <PARAM NAME=movie VALUE='" + this.strNormalClass + "'>" +
	    "	  <PARAM NAME=FlashVars VALUE='linkTXT="+this.strText+"&linkURL="+this.strLink+"&linkWindow=_self"+this.strExtraFlashVars+"'>" +
	    "     <PARAM NAME=quality VALUE=high>" +
	    "     <PARAM NAME=wmode VALUE=transparent>" +
	    "     <PARAM NAME=bgcolor VALUE=transparent>" +
	    " 	  <EMBED FlashVars='linkTXT="+this.strText+"&linkURL="+this.strLink+"&linkWindow=_self"+this.strExtraFlashVars+"'" +
	    "            src='" + this.strNormalClass + "' quality=high wmode=transparent bgcolor=transparent" +
	    "            WIDTH='"+this.intWidth+"' HEIGHT='"+this.intHeight+"' NAME='menuItems' ALIGN=''" +
	    "            TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>" +
	    "</OBJECT>";
	}
	else {
		this.divObject.innerHTML = this.strText;
	}

	if (this.sepObject) {
		this.objContainer.appendChild(this.sepObject);
	}
	this.objContainer.appendChild(this.divObject);

	if (this.subMenu) {
		var intX = 0;
		var intY = 0;
		if (this.subMenu.strOrientation == "vertical") {
			if (this.subMenu.strGrowTo == "up") {
			}
			else if (this.subMenu.strGrowTo == "down") {
				intX = this.intLeft;
				intY = this.intTop + this.intHeight + 1;
			}
			else if (this.subMenu.strGrowTo == "left") {
				if (this.subMenu.strAlign == "top") {
					intX = this.intLeft - this.subMenu.intElementsWidth;
					intY = this.intTop;
				}
				else if (this.subMenu.strAlign == "middle") {
					intX = this.intLeft - this.subMenu.intElementsWidth;
					intY = this.intTop + this.subMenu.intElementsHeight/2;
				}
				else if (this.subMenu.strAlign == "bottom") {
				}
			}
			else if (this.subMenu.strGrowTo == "right") {
				if (this.subMenu.strAlign == "top") {
					intX = this.intLeft + this.intWidth + 1;
					intY = this.intTop;
				}
				else if (this.subMenu.strAlign == "middle") {
					intX = this.intLeft + this.intWidth + 1;
					intY = this.intTop + this.subMenu.intElementsHeight/2;
				}
				else if (this.subMenu.strAlign == "bottom") {
				}
			}
		}
		else if (this.subMenu.strOrientation =="horizontal") {
			if (this.subMenu.strGrowTo == "up") {
				if (this.subMenu.strAlign == "left") {
				}
				else if (this.subMenu.strAlign == "center") {
				}
				else if (this.subMenu.strAlign == "right") {
				}
			}
			else if (this.subMenu.strGrowTo == "down") {
				if (this.subMenu.strAlign == "left") {
					intX = this.intLeft;
					intY = this.intTop + this.intHeight + 1;
				}
				else if (this.subMenu.strAlign == "center") {
					intX = this.intLeft + this.subMenu.intElementsWidth/2;
					intY = this.intTop + this.intHeight + 1;
				}
				else if (this.subMenu.strAlign == "right") {
				}
			}
			else if (this.subMenu.strGrowTo == "left") {
			}
			else if (this.subMenu.strGrowTo == "right") {
				intX = this.intLeft + this.intWidth + 1;
				intY = this.intTop;
			}
		}

		this.subMenu.draw(intX, intY, false);
	}

	return;
}

function menuElement_show() {
	if (this.sepObject) this.sepObject.style.display = "inline";
	this.divObject.style.display = "inline";

	return;
}
function menuElement_hide() {
	if (this.sepObject) this.sepObject.style.display = "none";
	if (this.subMenu) this.subMenu.hide();
	this.divObject.style.display = "none";
	this.divObject.className = this.strNormalClass;

	return;
}

function menuElement_addSubMenu(strOrientation, strGrowTo, strAlign) {
	this.subMenu = new objMenu_Class(this.objContainer, this.objTargetObject, strOrientation, strGrowTo, strAlign, this.objOwner.strBackGroundClass, this.objOwner.strSepLineStyle, this);
	this.subMenu.rootMenu = this.objOwner.rootMenu;
	this.subMenu.parentMenu = this.objOwner;
	this.subMenu.intElementsWidth = this.intWidth;
	this.subMenu.intElementsHeight = this.intHeight;

	return this.subMenu;
}

//******************** Clase Menu ********************
// Funciones para eventos del div asociado

// Funciones del objeto como tal
function objMenu_addElement(strText, strLink, strNormalClass, strOverClass, strNormalPic, strOverPic) {

	this.intElements++;
	this.arrElements[this.intElements] = new menuElement(this, this.objContainer, this.objTargetObject, strText, strLink, strNormalClass, strOverClass , strNormalPic , strOverPic);
	this.arrElements[this.intElements].intWidth = this.intElementsWidth;
	this.arrElements[this.intElements].intHeight = this.intElementsHeight;

	return this.arrElements[this.intElements];
}

function objMenu_resize(intNewElementsWidth, intNewElementsHeight) {
	if (intNewElementsWidth > 0) {
		this.intElementsWidth = intNewElementsWidth;
		for (i=0;i<=this.intElements;i++) {
			this.arrElements[i].intWidth = intNewElementsWidth;
		}
	}

	if (intNewElementsHeight > 0) {
		this.intElementsHeight = intNewElementsHeight;
		for (i=0;i<=this.intElements;i++) {
			this.arrElements[i].intHeight = intNewElementsHeight;
		}
	}
}

function objMenu_autoFixWidth(sinFontFactor) {
	var intMaxSize = 0;
	var intTMP;
	for (i=0;i<=this.intElements;i++) {
		if (this.arrElements[i].boolIsFlash) {
			intTMP = this.arrElements[i].intWidth/sinFontFactor;
		}
		else {
			intTMP = this.arrElements[i].strText.length;
		}
		if (intTMP > intMaxSize) intMaxSize = intTMP;
	}
	intTMP = intMaxSize*sinFontFactor;
	if (intTMP > this.intElementsWidth) {
		this.resize(intTMP, 0);
		return intTMP;
	}
	else {
		return this.intElementsWidth;
	}
}

function objMenu_draw(intLeft, intTop, boolShow) {
	var i = 0;
	var intTmpLeft = 0;
	var strTopRow = "";

	if (this.intLeft == 0 || this.intTop == 0) {
		this.intLeft = intLeft;
		this.intTop = intTop;
	}

	this.boolShow = boolShow;

	if (this.boolShow) {
		this.boolDrawn = true;
	}
	else {
		this.boolDrawn = false;
		return;
	}

	if (this.strOrientation == "vertical") {
		if (this.strGrowTo == "up" || ((this.strGrowTo == "left" || this.strGrowTo == "right") && this.strAlign == "bottom")) {
		}
		else if (this.strGrowTo == "down" || ((this.strGrowTo == "left" || this.strGrowTo == "right") && (this.strAlign == "top" || this.strAlign == "middle"))) {
			var intRealTop = this.intTop;
			if (this.strAlign == "middle") {
				intRealTop = this.intTop - ((this.intElements+1)*this.intElementsHeight)/2;
			}
			var intTMP = intRealTop;

			for (i=0;i<=this.intElements;i++) {
				intTmpLeft = this.intLeft;
				if (this.strSepLineStyle) {
					if (i > 0 || !boolShow) {
						if (this.strGrowTo == "down") {
							this.arrElements[i].sepObject = document.createElement("div");

							if (boolShow) this.arrElements[i].sepObject.style.display = "inline";
							else this.arrElements[i].sepObject.style.display = "none";

							this.arrElements[i].sepObject.style.position = "absolute";
							this.arrElements[i].sepObject.style.width = this.arrElements[i].intWidth;
							this.arrElements[i].sepObject.style.height = 6;
							this.arrElements[i].sepObject.style.left = this.intLeft + 2;
							this.arrElements[i].sepObject.style.top = intTMP - 1;
							this.arrElements[i].sepObject.innerHTML = "<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'><tr><td width='50%' style='font-size:2px; border-right:" + this.strSepLineStyle + ";'>&nbsp;</td><td width='50%' style='font-size:2px;'>&nbsp;</td></tr></table>";
							intTMP += 5;
						}
						else if ((this.strGrowTo == "left" || this.strGrowTo == "right") && (this.strAlign == "top" || this.strAlign == "middle")) {
							this.arrElements[i].sepObject = document.createElement("div");

							if (boolShow) this.arrElements[i].sepObject.style.display = "inline";
							else this.arrElements[i].sepObject.style.display = "none";

							this.arrElements[i].sepObject.style.position = "absolute";
							this.arrElements[i].sepObject.style.width = 10;
							this.arrElements[i].sepObject.style.height = this.arrElements[i].intHeight;
							this.arrElements[i].sepObject.style.left = this.intLeft;
							this.arrElements[i].sepObject.style.top = intTMP;

							if (intTMP == this.objOwnerElement.intTop) {
								strTopRow = "<td height='50%' width='50%' style='font-size:2px; border-bottom:" + this.strSepLineStyle + ";'>&nbsp;</td>";
							}
							else {
								strTopRow = "<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>";
							}

							if (i == 0) {
								if (i == this.intElements) {
									this.arrElements[i].sepObject.innerHTML = "" +
										"<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'>" +
										"	<tr>" +
										"		" + strTopRow +
										"		<td height='50%' width='50%' style='font-size:2px; border-bottom:" + this.strSepLineStyle + ";'>&nbsp;</td>" +
										"	</tr>" +
										"	<tr>" +
										"		<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>" +
										"		<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>" +
										"	</tr>" +
										"</table>";
								}
								else {
									this.arrElements[i].sepObject.innerHTML = "" +
										"<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'>" +
										"	<tr>" +
										"		" + strTopRow +
										"		<td height='50%' width='50%' style='font-size:2px; border-bottom:" + this.strSepLineStyle + ";'>&nbsp;</td>" +
										"	</tr>" +
										"	<tr>" +
										"		<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>" +
										"		<td height='50%' width='50%' style='font-size:2px; border-left:" + this.strSepLineStyle + ";'>&nbsp;</td>" +
										"	</tr>" +
										"</table>";
								}
							}
							else if (i == this.intElements) {
								this.arrElements[i].sepObject.innerHTML = "" +
									"<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'>" +
									"	<tr>" +
									"		" + strTopRow +
									"		<td height='50%' width='50%' style='font-size:2px; border-left:" + this.strSepLineStyle + "; border-bottom:" + this.strSepLineStyle + ";'>&nbsp;</td>" +
									"	</tr>" +
									"	<tr>" +
									"		<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>" +
									"		<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>" +
									"	</tr>" +
									"</table>";
							}
							else {
								this.arrElements[i].sepObject.innerHTML = "" +
									"<table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'>" +
									"	<tr>" +
									"		" + strTopRow +
									"		<td height='50%' width='50%' style='font-size:2px; border-left:" + this.strSepLineStyle + "; border-bottom:" + this.strSepLineStyle + ";'>&nbsp;</td>" +
									"	</tr>" +
									"	<tr>" +
									"		<td height='50%' width='50%' style='font-size:2px;'>&nbsp;</td>" +
									"		<td height='50%' width='50%' style='font-size:2px; border-left:" + this.strSepLineStyle + ";'>&nbsp;</td>" +
									"	</tr>" +
									"</table>";
							}

							intTmpLeft = this.intLeft + 10;
						}
					}
				}
				this.arrElements[i].draw(intTmpLeft, intTMP, this.boolShow);
				intTMP += this.arrElements[i].intHeight;
			}

			if (this.strBackGroundClass) {
				this.objBackground = document.createElement("div");

				if (boolShow) this.objBackground.style.display = "inline";
				else this.objBackground.style.display = "none";

				this.objBackground.className = this.strBackGroundClass;
				this.objBackground.style.position = "absolute";
				this.objBackground.style.zIndex = 9;
				this.objBackground.style.width = this.intElementsWidth;
				this.objBackground.style.height = intTMP - intRealTop;
				this.objBackground.style.left = intTmpLeft;
				this.objBackground.style.top = intRealTop;
				this.objContainer.appendChild(this.objBackground);

				if (isInternetExplorer && sinAppVersion < 7) {
					this.objBackFrame = document.createElement("iframe"); //Objeto con el iframe que hace el elemento visible sobre los selects en IE 6
					this.objBackFrame.src = "core/index.html";
					this.objBackFrame.scrolling = "no";
					this.objBackFrame.frameBorder = "0";
					this.objBackFrame.style.position = "absolute";
					this.objBackFrame.style.zIndex = 8;
					this.objBackFrame.style.width = this.intElementsWidth;
					this.objBackFrame.style.height = intTMP - intRealTop;
					this.objBackFrame.style.left = intTmpLeft;
					this.objBackFrame.style.top = intRealTop;
					this.objContainer.appendChild(this.objBackFrame);
				}
			}
		}
	}
	else if (this.strOrientation =="horizontal") {
		var intRealLeft = this.intLeft;
		if (this.strGrowTo == "up") {
			if (this.strAlign == "left") {
			}
			else if (this.strAlign == "center") {
			}
			else if (this.strAlign == "right") {
			}
		}
		else if (this.strGrowTo == "down") {
			if (this.strAlign == "center") {
				intRealLeft = this.intLeft - ((this.intElements+1) * this.intElementsWidth)/2;
			}
			if (this.strAlign == "left" || this.strAlign == "center") {
				var intTMP = intRealLeft;
				for (i=0;i<=this.intElements;i++) {
					this.arrElements[i].draw(intTMP, this.intTop, this.boolShow);
					intTMP += this.arrElements[i].intWidth;
					if (this.strSepLineStyle) {
						this.arrElements[i].divObject.style.border = this.strSepLineStyle;
					}
				}
			}
			else if (this.strAlign == "right") {
			}
		}
		else if (this.strGrowTo == "left") {
		}
		else if (this.strGrowTo == "right") {
			var intTMP = this.intLeft;
			for (i=0;i<=this.intElements;i++) {
				this.arrElements[i].draw(intTMP, this.intTop, this.boolShow);

				intTMP += this.arrElements[i].intWidth;
				if (this.strSepLineStyle) {
					this.arrElements[i].divObject.style.border = this.strSepLineStyle;
				}
			}
		}

		if (this.strBackGroundClass) {
			this.objBackground = document.createElement("div");

			if (boolShow) this.objBackground.style.display = "inline";
			else this.objBackground.style.display = "none";

			this.objBackground.className = this.strBackGroundClass;
			this.objBackground.style.position = "absolute";
			this.objBackground.style.zIndex = 9;
			this.objBackground.style.width = (this.intElements + 1) * this.intElementsWidth;
			this.objBackground.style.height = this.intElementsHeight;
			this.objBackground.style.left = intRealLeft;
			this.objBackground.style.top = this.intTop;
			this.objContainer.appendChild(this.objBackground);

			if (isInternetExplorer && sinAppVersion < 7) {
				this.objBackFrame = document.createElement("iframe"); //Objeto con el iframe que hace el elemento visible sobre los selects en IE 6
				this.objBackFrame.src = "javascript:'<html></html>';";
				this.objBackFrame.scrolling = "no";
				this.objBackFrame.frameBorder = "0";
				this.objBackFrame.style.position = "absolute";
				this.objBackFrame.style.zIndex = 8;
				this.objBackFrame.style.width = this.intElementsWidth;
				this.objBackFrame.style.height = intTMP - intRealTop;
				this.objBackFrame.style.left = intTmpLeft;
				this.objBackFrame.style.top = intRealTop;
				this.objContainer.appendChild(this.objBackFrame);
			}
		}
	}

	if (this.objDefaultElement) this.objDefaultElement.forceOverStyle();

	return;
}

function objMenu_show() {
	// Aqui va la rutina para ver si cabe o no
	var i = 0;

	if (!this.boolDrawn) {
		this.draw(this.intLeft, this.intTop, true);
	}
	else {
		if (this.objBackground) this.objBackground.style.display = "inline";
		if (this.objBackFrame) this.objBackFrame.style.display = "";

		for (i=0;i<=this.intElements;i++) {
			this.arrElements[i].show();
		}
	}

	return;
}

function objMenu_hide() {
	var i = 0;

	if (this.objBackground) this.objBackground.style.display = "none";
	if (this.objBackFrame) this.objBackFrame.style.display = "none";

	for (i=0;i<=this.intElements;i++) {
		this.arrElements[i].hide();
	}

	if (this.objOwnerElement) this.objOwnerElement.divObject.className =  this.objOwnerElement.strNormalClass;

	return;
}