/*******************************************************************************/
//	ANIMACIONES
/*******************************************************************************/

function animarMostrar(nombre, valor) {
	var cuadro = document.getElementById(nombre);
	document.getElementById(nombre).style.opacity = (valor/100).toString();
	document.getElementById(nombre).style.filter = "alpha(opacity="+valor+")";
	valor += 10;
	if (valor < 100) {
		setTimeout("animarOcultar('"+nombre+"', "+valor+")", 100);
	}
	else {
		document.getElementById(nombre).style.opacity = "0.9";
		document.getElementById(nombre).style.filter = "alpha(opacity=90)";
	}
}
function animarOcultar(nombre, valor) {
	var cuadro = document.getElementById(nombre);
	document.getElementById(nombre).style.opacity = (valor/100).toString();
	document.getElementById(nombre).style.filter = "alpha(opacity="+valor+")";
	valor -= 10;
	if (valor > 0) {
		setTimeout("animarOcultar('"+nombre+"', "+valor+")", 100);
	}
	else {
		document.getElementById(nombre).style.opacity = "0";
		document.getElementById(nombre).style.filter = "alpha(opacity=0)";
		document.getElementById(nombre).style.display = "";
	}
}

function mostrar(nombre) {
	document.getElementById(nombre).style.display = "block";
	//animarMostrar(nombre,0);
	if (document.getElementById("Triangulo_"+nombre)) {
		document.getElementById("Triangulo_"+nombre).style.display = "block";	
	}
}
function ocultar(nombre) {
	//animarOcultar(nombre,100);
	document.getElementById(nombre).style.display = "";
	if (document.getElementById("Triangulo_"+nombre)) {
		document.getElementById("Triangulo_"+nombre).style.display = "none";	
	}
}


/*******************************************************************************/
//	CLASE MENU
/*******************************************************************************/

function Menu(nombre,cadena_etiqueta,ancho,posX) {
	this.id = nombre;
	this.etiqueta = cadena_etiqueta;
	this.ancho = ancho;
	this.posX = posX;
	this.submenu = null;
	this.url = null;
	this.agregarMenu = agregarMenu;
}

function agregarMenu() {
	var html = "<div class=\"Menu\" id=\""+this.id+"\" style=\"margin-left:"+(this.posX-492)+"px\" onmouseover=\"javascript:mostrar('"+this.submenu.id+"',this);\" onmouseout=\"javascript:ocultar('"+this.submenu.id+"',this);\"><div id=\"Titulo_"+this.id+"\" class=\"ContenedorTituloMenu\" style=\"width:"+this.ancho+"px;\"><table class=\"TituloMenu\"><tr><td>";
	
	if (this.url != null) {
		html += "<a class=\"LinkMenu\" href=\""+this.url+"\">"+this.etiqueta+"</a></td></tr></table></div></div>";
	}
	else {
		html += this.etiqueta+"</td></tr></table></div>";
	}
	
	if (this.submenu != null) {
		this.submenu.primero = true;
		this.submenu.posX = 0;
		this.submenu.posY = 30;
		html += this.submenu.getHTMLSubmenu();
	}
	html += "</div>";
	document.write(html);
}

/*******************************************************************************/
//	CLASE SUBMENU
/*******************************************************************************/

function Submenu(id, ancho) {
	this.id = id;
	this.ancho = ancho;
	this.posX;
	this.posY;
	this.primero = false;
	this.items = new Array();
	this.getHTMLSubmenu = getHTMLSubmenu;
}

function getHTMLSubmenu() {
	var html = "<div id=\""+this.id+"\" class=\"SubMenu\" style=\"left:"+this.posX+"px; top:"+this.posY+"px;";
	if (this.primero) {
		html += " border-left: none;";		
	}
	html += "\">";
	for (var i=0; i<this.items.length; i++) {
		var it = this.items[i];
		html += "<div class=\"Item\" ";
		if (it.submenu != null) {
			html += "  onmouseover=\"javascript:mostrar('"+it.submenu.id+"');\"   onmouseout=\"javascript:ocultar('"+it.submenu.id+"');\"";
		}
		html += ">";
		// Imprimimos el título...
		html += "<div class=\"ContenedorTituloItem\" style=\"width:"+this.ancho+"px;";
		if (i==0) {
			html += " border-top:none";
		}
		html += "\">";
		html += "<table class=\"TituloItem\"><tr><td>";
		if (it.url != "") {
			html += "<a class=\"LinkMenu\" href=\""+it.url+"\">"+it.titulo+"</a>";	
		}
		else {
			html += it.titulo;
		}
		html += "</td>";
		if (it.submenu != null) {
			html += "<td class=\"CeldaTriangulito\"><img src=\"../../App_Themes/Imagenes/triangulito.gif\" id='Triangulo_"+it.submenu.id+"' style='display:none' /></td>";
		}
		html += "</tr></table></div>";
		// Si hay un submenú lo imprimimos
		if (it.submenu != null) {
			it.submenu.posX = this.ancho;
			it.submenu.posY = i*21;
			html += it.submenu.getHTMLSubmenu();	
		}
		html += "</div>";
	}
	html += "</div>";
	return html;	
}

/*******************************************************************************/
//	CLASE ITEM
/*******************************************************************************/

function Item(titulo, url) {
	this.titulo = titulo;
	this.url = url;
	this.submenu = null;
}