///<reference path="globalfw.js">
///<reference path="comun.js">

/* En este archivo js se han añadido todas aquellas funciones que se utilizan desde los distintos archivos vb
Desde el código vb se han creado varias funciones que llaman a éstas para crear distintos tipos de objetos en
código cliente. De esta manera tenemos un objeto que gestiona los popups, otro que gestiona el scroll de las capas
cuando se hace un postback, otro que gestiona unos paneles que se visualizan ú ocultan al pulsar un botón definido, etc.
Las funciones que llaman a éstas se encuentran en los archivos:
- funcionesGenerales.funcionesGenerales.vb
*/

/************************************************
			OBJETO GESTORCOOKIES
*************************************************/
function GestorCookies()
{
	this.Obtiene=getCookie;
	this.Inserta=setCookie;
	this.Elimina=delCookie;
}

function getCookie(name){
	try
	{
		var cname = name + "=";               
		var dc = document.cookie;   
		if (dc.length > 0) {              
			begin = dc.indexOf(cname);       
			if (begin != -1) {           
			begin += cname.length;       
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
				return unescape(dc.substring(begin, end));
			} 
		}
		return null;
	}catch(e)
	{
		return null;
	}
}


function setCookie(name, value, expires, path, domain, secure) {
	try
	{
		document.cookie = name + "=" + escape(value) + 
		((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		((secure == null) ? "" : "; secure");
	}catch(e)
	{
		
	}
}



function delCookie (name,path,domain) {
	try
	{
		if (getCookie(name)) {
			document.cookie = name + "=" +
			((path == null) ? "" : "; path=" + path) +
			((domain == null) ? "" : "; domain=" + domain) +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}catch(e)
	{
		
	}
}

/*******************************************
			OBJETO NAVEGADOR
******************************************/
//Descripcion:	Este objeto nos sirve para definir las distintas opciones del navegador utilizado
//				Que serán accesibles desde las demás funciones y objetos.

//Definicion:	funcion que crea el objeto Navegador

function Navegador()
{
	this.cookies=new GestorCookies();
	this.permiteCookies=CookiesActivas(this.cookies);
	
}
//Definicion: funcion que devuelve true si el navegador permite cookies, false en caso contrario.
function CookiesActivas(gestor)
{
	gestor.Inserta("CookiesActivas","1");
	if (gestor.Obtiene("CookiesActivas"))
	{
		return true;
	}
	else
	{		
		return false;	
	}
		
}
//Definicion: creamos el Objeto Nav para acceder a sus propiedades
var nav= new Navegador();


/*******************************************
			OBJETOS POPUP Y PANTALLA CARGA
******************************************/
//Descripción:	Éste objeto nos va a servir para poder gestionar todo lo referente a los popups
//				Con este objeto al abrir un popup se muestra una pantalla de carga en la página principal
//				También se definen funciones para mostrar las pantallas de carga sin necesidad de abrir un popup

//Definicion:	Constructor que define el objeto Popup para gestionar la apertura y cierra de los popups con pantalla de carga.
function PopUp(Direccion,NombrePopup,Atributos, minimizado, NombreEvento,obj)
{
	var vPopup;
	var Intervalo;
	var width;
	var height;
	var top;
	var left;
	var CapaCarga;
	this.ventana=vPopup;
	this.minimizado=false;
	this.intervalo=Intervalo;
	this.width=width;
	this.height=height;
	this.top=top;
	this.capaCarga=CapaCarga;
	this.left=left;
	this.MostrarCarga=MostrarCarga;
	this.CargarEvento=CargarEvento;
	this.OcultarCarga=OcultarCarga;
	this.CambiarDescripcion=CambiarDescripcionCapaCarga;
	this.direccion=Direccion;
	this.nombrePopup=NombrePopup;
	this.atributos=Atributos;
	this.nombreEvento=NombreEvento;
	this.objetoEvento=obj;
	//this.CargarPopUpMinimizado=CargarPopUpMinimizado;
	//this.CompruebaPopUpAbierto=CompruebaPopUpAbierto;
	//this.ObtenerValorParametro=ObtenerValorParametro;
	//this.CargarPopUp=CargarPopUp;
	//this.Redimensiona=Redimensiona;
	this.RedimensionaCapaCarga=RedimensionaCapaCarga;
}

//Definicion:	Constructor que define el objeto pantalla Carga para gestionar la visualizacion de la pantalla de Carga.
function PantallaCarga(obj,NombreEvento)
{
    var vPopup;
	var Intervalo;
	var width;
	var height;
	var top;
	var left;
	var CapaCarga;
	//this.ventana=vPopup;
	//this.minimizado=false;
	//this.intervalo=Intervalo;
	//this.width=width;
	//this.height=height;
	//this.top=top;
	this.capaCarga=CapaCarga;
	//this.left=left;
	this.MostrarCarga=MostrarCarga;
	this.CargarEvento=CargarEvento;
	this.OcultarCarga=OcultarCarga;
	this.RedimensionaCapaCarga=RedimensionaCapaCarga;
	this.spanDescripcion=null;
	this.CambiarDescripcion=CambiarDescripcionCapaCarga;
	
	//this.direccion=Direccion;
	//this.nombrePopup=NombrePopup;
	//this.atributos=Atributos;
	this.nombreEvento=NombreEvento;
	this.objetoEvento=obj;
	//this.CargarPopUpMinimizado=CargarPopUpMinimizado;
	//this.CompruebaPopUpAbierto=CompruebaPopUpAbierto;
	//this.ObtenerValorParametro=ObtenerValorParametro;
	//this.CargarPopUp=CargarPopUp;
	//this.Redimensiona=Redimensiona;
}

//Definicion:	Función que muestra la pantalla de carga y posteriormente llama a un evento de servidor
function CargarEvento()
{
	this.MostrarCarga();
	__doPostBack(this.objetoEvento.id,this.nombreEvento)
}

//Definicion: Funcionn que muestra la Pantalla de Carga
function MostrarCarga(quitarProgreso,descripcion)
{
	//Creamos la capa si no está creada
	
	var CapaCarga;
	
	if (!document.getAspElementById('CapaCarga'))
	{
		CapaCarga = document.createElement("DIV");
		CapaCarga.id="CapaCarga";
		CapaCarga.className="capaCarga";
		var tabla="";
		
		if ((!descripcion)||(descripcion==""))
		{
			descripcion="GENERANDO INFORME";
		}
		
		tabla += "<table cellpadding=0 cellspacing=0 class=\"capaCargaFondo\">"
		tabla += "<tr><td align=center valign=middle>"
		tabla += "</td></tr></table>"
		tabla += "<table id=\"imgCapaCarga\" class=\"capaCargaCentro\"><tr><td align=center><span id=\"spanDescripcionCapaCarga\">" + descripcion + "</span></td></tr><tr><td class=\"capaCargaLogo\" >&nbsp;</td></tr><tr id=\"trProgreso\" style=\"visibility:hidden;\"><td class=\"capaCargaProgreso\"></td></tr></table>"
		CapaCarga.innerHTML=tabla;
		document.body.insertBefore(CapaCarga,document.body.firstChild);
		CapaCarga.spanDescripcion=document.getElementById("spanDescripcionCapaCarga");
		this.capaCarga=CapaCarga;
	}else
	{
	    
		CapaCarga=document.getAspElementById('CapaCarga');
		CapaCarga.spanDescripcion=document.getElementById("spanDescripcionCapaCarga");
		this.capaCarga=CapaCarga;
		
		
		if ((descripcion)&&(descripcion!=""))
			this.CambiarDescripcion(descripcion);
			
	}
		
	
	//this.capaCarga.spanDescripcion=document.getElementById("spanDescripcionCapaCarga");
	
	
	if (quitarProgreso==true)
		document.getElementById('trProgreso').style.visibility="hidden";
	else
		document.getElementById('trProgreso').style.visibility="visible";
	
	this.RedimensionaCapaCarga();
	
	CapaCarga.style.display="block";
	//Asignamos los Eventos a la página
	if (window.addEventListener)
	{
		window.addEventListener("onresize", RedimensionaCapaCarga,false)
		window.addEventListener("onscroll", RedimensionaCapaCarga,false)
	}else
	{
		window.attachEvent("onresize", RedimensionaCapaCarga)
		window.attachEvent("onscroll", RedimensionaCapaCarga)
	}
	document.capaCargaActual=this;
	//si la carga sea instantánea
	window.setTimeout("document.capaCargaActual.RedimensionaCapaCarga();",100);
	
	
}

function CambiarDescripcionCapaCarga(descripcion)
{
    if((this.capaCarga) && (this.capaCarga.spanDescripcion))
		this.capaCarga.spanDescripcion.innerHTML=descripcion;
	
	
}

function RedimensionaCapaCarga()
{
	try{
	var CapaCarga=this.capaCarga;
	
	CapaCarga.style.width=document.body.clientWidth
	CapaCarga.style.height=document.body.clientHeight;
	CapaCarga.style.left=window.document.body.scrollLeft
	CapaCarga.style.top=window.document.body.scrollTop//-21
	var imgCapaCarga=document.getElementById("imgCapaCarga");
	imgCapaCarga.style.position="absolute";
	imgCapaCarga.style.zIndex=parseInt(CapaCarga.style.zIndex)+1;
	imgCapaCarga.style.left=(parseInt(CapaCarga.clientWidth)-parseInt(imgCapaCarga.clientWidth))/2;
	imgCapaCarga.style.top=(parseInt(CapaCarga.clientHeight)-parseInt(imgCapaCarga.clientHeight))/2;
	}catch(e)
	{
	    window.setTimeout("document.capaCargaActual.RedimensionaCapaCarga();",100);
	}
	//imgCapaCarga.style.left=window.document.body.scrollLeft;
	//imgCapaCarga.style.top=window.document.body.scrollTop;
}
//Definicion:	funcion que oculta la pantalla de carga
function OcultarCarga()
{
	if (this.capaCarga)
	{
		this.capaCarga.style.display="none";
		//Quitamos los eventos a la página
		window.detachEvent("onresize", RedimensionaCapaCarga)
		window.detachEvent("onscroll", RedimensionaCapaCarga)
	}
}


//Definicion:	funcion que comprueba si el popup está abierto y cargado
PopUp.prototype.CompruebaPopUpAbierto=function()
{
	try {
		//PopupActual;
		//var vPopup=document.PopupActual.ventana;
		var vPopup=this.ventana;
		
		
		if ((vPopup.closed==true) || ((vPopup.document) && (vPopup.document.readyState=="complete")))
		{
			
			this.OcultarCarga();
			//alert(window.location.href);
			window.clearInterval(this.intervalo);
			var intervalo;
			this.intervalo=intervalo;
			
			if (this.minimizado)
			{
				this.Redimensiona();
			}
			vPopup.focus();
			
		}
		
	} catch(e)
		{
		//alert(e.name + " - "+e.message);
		window.clearInterval(this.intervalo);
		document.PopupActual.OcultarCarga();
		
		}
										
}


function Prueba()
{
		//CargarPopUp('http://localhost/privado/Gerencia/DatosInformeGerencialComparativo.aspx?FechaInicio1=5oXFr2AE*^*6B6KDmKKvqLJzvPK8AoSjrL&FechaFin1=MpeBld*[*ZcvUCCGP0wFKa*[*j0yyqzVb7dO&FechaInicio2=PLIyE9Zpg3zCES0dQn73IWASnSqcYMGh&FechaFin2=0TjXRUm*^*5WUiX9MKqLHjSPDLQbvFTwKE&CompararPeriodos=*^*SgMiokVCKE[|]&CodigoValoradoEn=hVGfPQeqKAo[|]&NombreValoradoEn=M2yDhFFPAes[|]&paises=WJh27HJnh7jOyjvR*[*T1dbQ[|][|]&Centros=Wr8ST6iMHJw[|]&Ventanillas=PBe*[*0X*[*qKj*^*Jcybpqvwx5DzVB6gZ9Jcd7ys3*[*k*^*QhILoh*[*jkf7sGLBcXydxQ1A1oa*[*fnQwWFKcQd9AdnKQdnVGH0Qf0FoSRaCEKR4N*^*d7v6a*[*qQILyJNYGB4Oc*[*HsGiDrpgoRbDLLRh8u67ZXCtr*[*aiWlI8Tzb*[*Q*[*Ouj6zQFt9opuOWgM64iWeGhhmfjMFMlHzoUhkRjTOkbCLEmy2ETnbHNUEP*^*XrRr*[*CgICd7Ybdst6oRYFjIipn0fyMk*^*5OT*[*LkXQ*^*YLb5VJhhAD4OLhvSd*^*LXcER9hKvFUiD2d7tTTCWjp0ANPV5gNkN1hliqFhauCpgflPvsAM[|]&codigosVentanillas=ftym3Ht1JcHL*^*9Ifyz7FrbNEF8me7PoaWuMCVxJ3OclB*[*f80hHVOLzsM5w4rNhYzw41Hi8rM7Ok[|]&Monedas=Sfv1eMKj*[*VA0h7JzkwYMCJeU6AHafgoB&IdMenu=AsHLwmsJ2jQ[|]&IdPadre=U9pnH8PWpQk[|]','Google','top=0,left=0, width=100%,height=100%,status=NO,scrollbars=YES,resizable=YES');
		//alert(screen.availWidth-20);
		//CargarPopUp('http://www.google.com','Google','top=0,left=0,width='+(parseInt(screen.availWidth)-200)+',height='+(parseInt(screen.availHeight)-200)+',status=NO,scrollbars=YES,resizable=YES',1);
		//CargarPopUpMinimizado('http://localhost/privado/inicio.aspx','Google','top=10,left=10,width=600,height=500,status=NO,scrollbars=YES,resizable=YES',1);
		
		//var valor=ObtenerValorParametro('    top=0      ,       left=0,width='+(parseInt(screen.availWidth)-200)+',height='+(parseInt(screen.availHeight)-200)+',status=NO,scrollbars=YES,resizable=yes',"scrollbars");
		//alert(valor);
		//var pop=new PopUp('http://localhost/privado/inicio.aspx','Google','top=0,left=0,width='+(parseInt(screen.availWidth)-200)+',height='+(parseInt(screen.availHeight)-200)+',status=NO,scrollbars=YES,resizable=YES',1)
		//pop.CargarPopUpMinimizado();
		
		window.setTimeout("var pantalla= new PantallaCarga();pantalla.MostrarCarga();",3000);
		
		//alert(pop);
}
//Prueba();



//Definicion: Variable que contiene el popup que se está gestionando actualmente

//Definicion: Pantalla que muestra el popup con su pantalla de carga
PopUp.prototype.CargarPopUp=function(quitarProgreso,descripcion)
{
	try {
	
	this.MostrarCarga(quitarProgreso,descripcion);
	
	this.ventana=window.open(this.direccion,this.nombrePopup,this.atributos);
	
	document.PopupActual=this;
	//si hay un intervalo Activo
	
	if (this.intervalo)
		window.clearInterval(this.intervalo);
			
	this.intervalo= window.setInterval("document.PopupActual.CompruebaPopUpAbierto();",1000);	
		
	this.intervalo=document.PopupActual.intervalo;
		
					//window.focus();				
	} catch(e)
		{
		//alert(e.name + " - "+e.message);
		if (this.intervalo)
			window.clearInterval(this.intervalo);
		this.OcultarCarga();
		

		}
}

//Definicion:	Funcion que abre un popup Minimizado y al cargarse se expande con los valores establecidos
PopUp.prototype.CargarPopUpMinimizado=function(quitarProgreso,descripcion)
{
	try {
	
	this.minimizado=true;
	var atribMin=this.atributos.toLowerCase().split(",");
	var atrib=this.atributos.split(",");
	var atributosNuevos=" ";
			
	var pWidth=this.ObtenerValorParametro("width");
	var pHeight=this.ObtenerValorParametro("height");
	var pLeft=this.ObtenerValorParametro("left");
	var pTop=this.ObtenerValorParametro("top");
	this.width=pWidth;
	this.height=pHeight;
	this.left=pLeft;
	this.top=pTop;
													
	for (i=0; i<atribMin.length;i++)
	{
		var agregar=true;
		if ((pWidth) && (atribMin[i].indexOf("width=")>=0))
		{
			agregar=false;						
		}
		
		if ((pHeight) && (atribMin[i].indexOf("height=")>=0))
		{
			agregar=false;		
		}
		
		if ((pLeft) && (atribMin[i].indexOf("left=")>=0))
		{
			agregar=false;					
		}
		
		if ((pTop) && (atribMin[i].indexOf("top=")>=0))
		{
			agregar=false;		
		}
		
		if (agregar)
			atributosNuevos +=atrib[i] +","
		
		
	}
	
	atributosNuevos += "width=20,height=20,top=0,left=0"
	this.atributos=atributosNuevos;
	
	this.CargarPopUp(quitarProgreso,descripcion);
	window.focus();
	
	
	} catch(e)
		{
		//alert(e.name + " - "+e.message);
		
			
		}
	
}

//Definicion: funcion que obtiene el valor del parametro del popup que se especifica.
PopUp.prototype.ObtenerValorParametro=function(parametro)
{
	var valor;
	var inicio;
	var fin;
	var cadenaParametrosNueva;
	
	cadenaParametrosNueva=this.atributos.toLowerCase();
					
	do 
	{
		cadenaParametrosNueva=cadenaParametrosNueva.replace(" ","");
	}while (cadenaParametrosNueva.indexOf(" ")>=0)
	do 
	{
		this.atributos=this.atributos.replace(" ","");
	}while (this.atributos.indexOf(" ")>=0)
	
	if (cadenaParametrosNueva.indexOf(parametro + "=")!=0)
		parametro="," + parametro;
	
	parametro=parametro.toLowerCase() + "=";
	
	inicio=cadenaParametrosNueva.indexOf(parametro);
	
	if (inicio<0)
		return valor;
	
	inicio=cadenaParametrosNueva.indexOf("=",inicio);
	if (inicio<0)
		return valor;
	fin=cadenaParametrosNueva.indexOf(",",inicio);
	if (fin<0)
		fin=cadenaParametrosNueva.length;
	inicio+=1;
	valor=this.atributos.substring(inicio,fin);
	
	return valor;
					
}

//Definicion: funcion que redimensiona la ventana del popup a sus valores establecidos desde el estado minimizado
PopUp.prototype.Redimensiona=function()
{
		if (!this.width)
			this.width=screen.availWidth;
			
		if (!this.height)
			this.height=screen.availHeight;
			
		this.ventana.resizeTo(this.width, this.height);
		
		if (!this.left)
			this.left=0;
		if (!this.top)
			this.top=0;
		this.ventana.moveTo(this.top,this.left);
		
}

PopUp.prototype.Cerrar=function()
{
		
		if ((this.ventana) && (!this.ventana.closed))
			this.ventana.close();
	
}
			
			
/************************************************
			OBJETO PANEL DESLIZANTE
*************************************************/
//Descripcion:	Con este objeto definimos aquellas capas con scroll que queremos que 
//				mantengan la posición después de hacer scroll.

//Definicion:	Constructor para definir una capa con scroll y que mantenga su posicion después del postback
//Parametros:	idDivDatos string, será el nombre del objeto que queremos que mantenga la posición
//				idHiddenScroll string opcional, si el navegador no admite cookies y se especifica, se guardará la posición en él, sino se utilizarán Cookies.
//												debe ser un input type=hidden con la clausula runat="server" especificada.
function PanelDeslizante(idDivDatos, idHiddenScroll)
{
    try
    {
    
	
	obj=document.getAspElementById(idDivDatos);
	if (!obj)
	{
	    return obj;
	}
	
	obj.hiddenScroll=document.getAspElementById(idHiddenScroll);
	obj.onscroll=GuardaScroll;
	obj.ObtieneScroll=ObtieneScroll;
	obj.InicializaScroll=InicializaScroll;
	obj.GuardaScroll=GuardaScroll;
	if (obj.hiddenScroll)
	{
		obj.cookiesActivas=false;
	}
	else
		if (nav.permiteCookies)
		{
			obj.cookiesActivas=true;
		}
		else
		{
			obj.cookiesActivas=false;
		}
	
	if (!obj.style.overflow)
		obj.style.overflow="auto";
	//alert(obj.id);
	
	document.getAspElementById(obj.id ).ObtieneScroll();
	
	//Asignamos el setTimeout porque en ocasiones no se establecía correctamente
	window.setTimeout("try{document.getAspElementById('" + obj.id +"').ObtieneScroll()}catch(e){}",1);
	
	
	return obj;
	
	}catch(e)
    {
        //alert(e.message);
    }
	
}

//Definicion:	Guarda el Scroll en cookies(si están activadas) ó en el campoOculto especificado.
function GuardaScroll()
{
	try
	{
	
	var strScroll=this.scrollTop + "," + this.scrollLeft
	//alert("guardando: " + strScroll);
	
	if (this.hiddenScroll)
		this.hiddenScroll.value=strScroll;
	else
		if (this.cookiesActivas)
			nav.cookies.Inserta("pd_" + this.id,strScroll);
	}catch(e)
	{
	    //alert(e.message);
	}	
}

function InicializaScroll()
{
    try
    {
    
	this.scrollTop=0;
	this.scrollLeft=0;
	this.GuardaScroll();
	this.ObtieneScroll();
	}catch(e)
	{
	    //alert(e.message);
	}
	
}
//Definicion:	Obtiene el valor del Scroll de las cookies(si están activadas) ó en el campoOculto especificado.
function ObtieneScroll()
{
    try
    {
   
	
	var strScroll="";
	if (this.hiddenScroll)
	{	
		strScroll=this.hiddenScroll.value;
	}
	else
		if (this.cookiesActivas)
			strScroll=nav.cookies.Obtiene("pd_" + this.id)
	
	
	
	if ((strScroll!=null) && (strScroll!=""))
	{
		var tScroll=strScroll.split(",");
		if (tScroll.length>0)
		{
			
			//window.setTimeout("document.getElementById('"+this.id+"').scrollTop=" + tScroll[0], 1);
			this.scrollTop=tScroll[0];
			
			if (tScroll.length>1)
			{
				//window.setTimeout("document.getElementById('"+this.id+"').scrollLeft=" + tScroll[1],1);
				this.scrollLeft=tScroll[1];
								
			}
		
			//Si la página no se ha creado completamente puede que no se haya ejecutado correctamente el scroll.
			
			if (this.scrollTop!=tScroll[0])
                window.setTimeout("try{document.getAspElementById('" + this.id +"').ObtieneScroll();}catch(e){}",1);					
		}
	
		
	}
	
	}catch(e)
    {
        //alert(e.message);
    }
		
	
		
	//var valor=getCookie(this.id + "_scroll");
	//this.scrollTop=valor;
}




/*****************************************************
			OBJETO GESTORPANELES
******************************************************/
//Descripcion:	Mediante el Gestor de paneles podemos gestionar los distintos objetos que se van a mostrar
//				y ocultar en una página mediante javascript. De esta manera, al pulsar sobre una etiqueta
//				definida podemos hacer que una determinada tabla se muestre ó se oculte.
//NOTA:			Estas funciones han sido creadas para la gestion de los paneles de Expansión.
//				La posicion de los paneles se guarda en cookies, para que al hacer postback no pierdan su posicion
//				Al igual que todas las funciones en este fichero definidas exiten funciones en codigo vb que manejan estas funciones.

//Definicion: constructor del gestor de Paneles
function GestorPaneles(idGestor)
{
	
	var arrayIdPaneles;
	var arrayIdEtiquetas;
	this.AgregaPanel=AgregaPanel;
	this.paneles=arrayIdPaneles;
	this.etiquetas=arrayIdEtiquetas;
	this.VisualizaPanel=VisualizaPanel;
	this.IntroduceEstadoPaneles=IntroduceEstadoPaneles;
	this.ObtieneEstadoPaneles=ObtieneEstadoPaneles;
	this.InsertarPaneles=InsertarPaneles;
	this.id=idGestor;
	
}

//Definicion:	define el panel y el objeto que lo va a mostrar ú ocultar.
function AgregaPanel(idPanel, idEtiqueta,display)
{
	
	var indice=0;
	var lblEtiqueta=document.getAspElementById(idEtiqueta);
	var panel=document.getAspElementById(idPanel);
	if ((lblEtiqueta) && (panel))
	{
		lblEtiqueta.panel=panel;
		lblEtiqueta.gestorPaneles=this;
		lblEtiqueta.onclick=VisualizaPanelAsignado;
		lblEtiqueta.style.width="100%";
		lblEtiqueta.onmouseover=EntraRatonPanel;
		lblEtiqueta.onmouseout=SaleRatonPanel;
		/*var linkEtiqueta=document.createElement("a");
		linkEtiqueta.innerHTML="-"
		linkEtiqueta.href="javascript:;";
		linkEtiqueta.className="verdana10AzulOscuraBold"		
		lblEtiqueta.insertBefore(linkEtiqueta,lblEtiqueta.firstChild);
		*/
		var links;
		links=lblEtiqueta.getElementsByTagName("a")
		var k=0;
		while (links[k])
		{
			links[k].onfocus=EntraRatonPanel;
			links[k].etiqueta=lblEtiqueta;
			links[k].onblur=SaleRatonPanel;
			k++;
		}
		
		
		if (!display)
			display="block"
		
		panel.style.display=display;
		
		//lblEtiqueta.style.background="#f7f9fd";
		//lblEtiqueta.style.borderBottom="#d8ddee 1px solid";
		lblEtiqueta.style.cursor="hand";
		lblEtiqueta.className="panel_cabecera"
		
			
		if (this.paneles)
		{
			indice=this.paneles.length;
		}else
		{
			this.paneles=new Array();
			this.etiquetas=new Array();
		}
		
		this.paneles[indice]=panel;
		
		this.etiquetas[indice]=lblEtiqueta;
		
		
	}
	
}

//Definicion:	Visualiza el panel
function VisualizaPanelAsignado()
	{
		
		var tabla=this.panel;
		if ((tabla) && (tabla.style.display))
		{
			var sVer="";
			if (tabla.style.display=="none")
				sVer="block";
			else
				sVer="none";
			tabla.style.display=sVer;
			this.gestorPaneles.IntroduceEstadoPaneles();
		}
		
		
		
	}

//Definicion:	funcion que cambia el estilo al ponerse el raton encima de la etiqueta
	function EntraRatonPanel()
	{
		var obj=this;
		if (this.etiqueta)
			obj=this.etiqueta;
		
		obj.className="panel_cabecera_entra";
		//obj.style.background='#D8DDEE';
	}
//Definicion:	funcion que reestablece el estilo inicial
	function SaleRatonPanel()
	{
		var obj=this;
		if (this.etiqueta)
			obj=this.etiqueta;
		//obj.style.background='#f7f9fd';
		obj.className="panel_cabecera";
	}

//Definicion:	Esta función muestra u oculta el panel espedificado en el parametro
function VisualizaPanel(Panel)
{
	
	var tabla=Panel;
	var sVer="";
	if ((tabla) && (tabla.style.display))
	{
		if (tabla.style.display=="none")
			sVer="block";
		else
			sVer="none";
		
		tabla.style.display=sVer;
		this.IntroduceEstadoPaneles();
	}
	
}





//Definicion:	Función que recoge todos los estados de los paneles y los guarda
function IntroduceEstadoPaneles()
{
	
	var sEstado="";
	for(i=0;i<this.paneles.length;i++)
	{
		var tblPanel=this.paneles[i];
		sEstado +=tblPanel.style.display + "_";
	}
	if(sEstado!="")
		sEstado=sEstado.substring(0,sEstado.length-1);
	
	setCookie("GestorPanel_" + this.id, sEstado);
	
}

//Definicion:	función que obtiene el estado de los Paneles.
function ObtieneEstadoPaneles()
{
	
	//var hiddenEstadoPaneles= document.getElementById("hiddenEstadoPaneles");
	//var sEstado=hiddenEstadoPaneles.value;
	var sEstado=getCookie("GestorPanel_" + this.id)
	if ((!sEstado)||(sEstado==""))
		return;
	
	arrayEstado=sEstado.split("_");
	
	for(i=0;i<arrayEstado.length && i<this.paneles.length;i++)
	{
		var tblPanel=this.paneles[i];
		tblPanel.style.display=arrayEstado[i];
	}
	
		
}

//Definicion:	funcion que inserta todos los paneles en el gestor.
//				es necesario enviar una tabla de dos dimensiones, en la primera los paneles y en la segunda la etiqueta asignada.
//				Si se envía una tabla de tres dimensiones entonces la tercera se indicará el display
function InsertarPaneles(tPaneles)
{
		
	if ((tPaneles)&& (tPaneles.length>0))
	{
		var display=false;
		
		for (i=0;i<tPaneles.length;i++)
		{
			
			if (tPaneles[i].length==3)
			{
				this.AgregaPanel(tPaneles[i][0], tPaneles[i][1],tPaneles[i][2]);
				display=true;
			}else this.AgregaPanel(tPaneles[i][0], tPaneles[i][1]);
			
		}
		
		if (!display)
		{
			this.ObtieneEstadoPaneles();
			
		}else
		{
			this.IntroduceEstadoPaneles();	
			
		}
	}
			
}


/****************************************************
Funciones para mostrar un texto superpuesto en una capa
*****************************************************/


function MostrarCapaLink(texto, ancho, alto, link, clase, claselink,textoPlano)
	{
		
		var MostrarTexto=CapaMostrarTexto();
		MostrarTexto.style.top=event.y-5+parseInt(window.document.body.scrollTop);
		MostrarTexto.style.left=event.x-5+parseInt(window.document.body.scrollLeft);
        if(textoPlano==1)
			MostrarTexto.innerHTML="<a id='linkCapa'>" + texto.replace("<", "&lt;").replace(">", "&lg;").replace("@", "--a--") + "</a>";
        else
            MostrarTexto.innerHTML="<a id='linkCapa'>" + texto.replace("@", "--a--") + "</a>";
         
        
		var linkCapa=document.getAspElementById("linkCapa");
		
		if (clase!='')
		{
			MostrarTexto.className=clase;
			
		}
		else
		{
			MostrarTexto.className='tooltip';
		}
		
		if (claselink!='')
		{
			
			linkCapa.className=claselink;
		}
		else
		{
			linkCapa.className=link.className;
			
		}
		
		if (link.href)
		{
		linkCapa.href=link.href;
		linkCapa.target=link.target;
		}
		else
		{
			linkCapa.href='javascript:;';
		}
		
		linkCapa.onclick=link.onclick;
		if ((ancho>0) && (alto>0))
		{
			
			MostrarTexto.style.height=alto;
			MostrarTexto.style.width=ancho;
		}
		else
		{
			
			MostrarTexto.style.height=80;
			MostrarTexto.style.width=190;
		}
		
		//alert(window.document.body.scrollTop);
		if ((event.x-5+parseInt(MostrarTexto.style.width,10))>=parseInt(window.document.body.clientWidth,10))
			MostrarTexto.style.left=parseInt(MostrarTexto.style.left,10)-parseInt(MostrarTexto.style.width,10)+10;
		if ((event.y-5+parseInt(MostrarTexto.style.height,10))>=parseInt(window.document.body.clientHeight,10))
			MostrarTexto.style.top=parseInt(MostrarTexto.style.top,10)-parseInt(MostrarTexto.style.height,10)+10;
		
		MostrarTexto.style.visibility="visible";
		
		//window.setTimeout("document.getElementById('" +MostrarTexto.id+"').style.visibility='visible'",300);
		MostrarTexto.innerHTML=MostrarTexto.innerHTML.replace("--a--","@");
	}
			
function MostrarCapa(texto, ancho, alto, clase,textoPlano)
	{
	
	var MostrarTexto=CapaMostrarTexto();
	MostrarTexto.style.top=event.y+5+parseInt(window.document.body.scrollTop);
	MostrarTexto.style.left=event.x+5+parseInt(window.document.body.scrollLeft);
		
	if ((clase) && (clase!=''))
	{
		MostrarTexto.className=clase;
	}
	else
	{
		MostrarTexto.className='tooltip'; 
		
	}
	
	//añadir alfa a la clase
	//document.styleSheets[0].addRule("." + MostrarTexto.className, "filter:alpha(opacity=90)");
	
	if ((ancho>0) && (alto>0))
	{
		MostrarTexto.style.height=alto;
		MostrarTexto.style.width=ancho;
	}
	else
	{
		MostrarTexto.style.height=80;
		MostrarTexto.style.width=190;
	}
	
	if(textoPlano==1)
	    MostrarTexto.innerText=texto;
	else
   		MostrarTexto.innerHTML=texto;
	
	if ((event.x-5+parseInt(MostrarTexto.style.width,10))>=parseInt(window.document.body.clientWidth,10))
		MostrarTexto.style.left=parseInt(MostrarTexto.style.left,10)-parseInt(MostrarTexto.style.width,10)+10;
    if ((event.y-5+parseInt(MostrarTexto.style.height,10))>=parseInt(window.document.body.clientHeight,10))
		MostrarTexto.style.top=parseInt(MostrarTexto.style.top,10)-parseInt(MostrarTexto.style.height,10)+10;
	  
	MostrarTexto.style.visibility="visible";
	}

function OcultarCapa()
	{
		if (document.getAspElementById("MostrarTexto1"))
			document.getAspElementById("MostrarTexto1").style.visibility="hidden";
		//window.setTimeout("document.getElementById('MostrarTexto1').style.visibility='visible'",500);
	}

function CapaMostrarTexto()
{
	var idMostrarTexto="MostrarTexto1";
	if (!document.getAspElementById(idMostrarTexto))
		{
		var MostrarTexto=document.createElement("Div");
		MostrarTexto.onmouseup=MostrarCapaTexto;
		MostrarTexto.classname="tooltip";
		MostrarTexto.id=idMostrarTexto;
		MostrarTexto.onmouseover=MostrarCapaTexto;
		MostrarTexto.onmouseout=OcultarCapaTexto;
		MostrarTexto.style.textAlign="Justify";
		MostrarTexto.style.zIndex="122";
		MostrarTexto.style.visibility="hidden";
		MostrarTexto.style.overflow="auto";
		MostrarTexto.style.width=190;
		MostrarTexto.style.height=80;
		MostrarTexto.style.position="absolute";
		MostrarTexto.style.top=0;
		MostrarTexto.style.left=0;
		document.body.insertBefore(MostrarTexto,document.body.firstChild);
		MostrarTexto=document.getAspElementById(idMostrarTexto);
		return MostrarTexto;
	}
	else
	{
		return document.getAspElementById(idMostrarTexto);
	}
	
}

function MostrarCapaTexto()
{
	this.style.visibility='visible';
}
function OcultarCapaTexto()
{
	this.style.visibility='hidden';
}



/****************************************************
Funciones para crear un Datagrid Seleccionable
*****************************************************/


//Estas dos variables se establecen para saber el Item sobre el que está el ratón
//De esta manera podemos seleccionar o deseleccionar el item pulsando en la descripcion
//que aparece cuando se recorta el texto
var itemActual;
var idCheckActual;

function DatagridSeleccionable(idDatagrid,seleccionMultiple,idChkSeleccionado, cssItemSeleccionado,cssItemDeseleccionado,cssItemEncimaSeleccionado,cssItemEncimaDeseleccionado)
{
	var dtg=this;
	dtg.tablaDatagrid=document.getAspElementById(idDatagrid);
	dtg.filas=new Array();
	dtg.filaSeleccionada=null;
	dtg.filaFoco=null;
		
	
	if (idChkSeleccionado)
		dtg.idChkSeleccionado=idChkSeleccionado;
	else
		dtg.idChkSeleccionado="chkSeleccionado";
		
	if (seleccionMultiple)
		dtg.seleccionMultiple=true;
	else
		dtg.seleccionMultiple=false;
		
	if (cssItemSeleccionado)
		dtg.cssItemSeleccionado=cssItemSeleccionado;
	else
		dtg.cssItemSeleccionado="dtgItemSeleccionado";
		
	if (cssItemDeseleccionado)
		dtg.cssItemDeseleccionado=cssItemDeseleccionado;
	else
		dtg.cssItemDeseleccionado="dtgItemDeseleccionado";
	
	if (cssItemEncimaSeleccionado)
		dtg.cssItemEncimaSeleccionado=cssItemEncimaSeleccionado;
	else
		dtg.cssItemEncimaSeleccionado="dtgItemEncimaSeleccionado";
	
	if (cssItemEncimaDeseleccionado)
		dtg.cssItemEncimaDeseleccionado=cssItemEncimaDeseleccionado;
	else
		dtg.cssItemEncimaDeseleccionado="dtgItemEncimaDeseleccionado";
	
	if (!dtg.tablaDatagrid)
		return false;
		
	var filas=dtg.tablaDatagrid.getElementsByTagName("tr");
	var filasTabla=new Array();	
	filasTabla[0]=-1;
	indice=0;
		
	//cogemos solamente las filas directas
	for (i=0;i<filas.length;i++)
	{
		if (filas[i].parentElement.parentElement.id==dtg.tablaDatagrid.id)
		{
			dtg.AgregaFila(filas[i]);
		}
	}
	
		
	return dtg
}

DatagridSeleccionable.prototype.AgregaFila=function (dtgFila)
{
	var fila;
	fila=dtgFila;
	
	//Cogemos los checkBox;
	var checks=fila.getElementsByTagName("input");
	for (k=0;k<checks.length;k++)
	{
		if (checks[k].id.toLowerCase().indexOf(this.idChkSeleccionado.toLowerCase())>=0)
		{
			fila.chkSeleccion=checks[k];
			if ((!this.seleccionMultiple) && (checks[k].checked))
			{
				this.filaSeleccionada=fila;
			}
		}
	}
	//Si no existe el control de seleccion, puede ser que sea la fila de la cabecera ó el pie del datagrid.
	//por lo que no añadimos la fila
	if (!fila.chkSeleccion)
		return dtgFila;
	
	
	fila.datagrid=this;
	fila.onmouseover=this.dtgEncimaItem;
	fila.onmouseout=this.dtgSalirItem;
	fila.onclick=this.dtgSeleccionarItem;
	fila.style.cursor="hand";
	fila.EncimaItem=this.dtgEncimaItem;
	fila.BorrarSeleccion=this.dtgBorrarSeleccion;
	fila.SalirItem=this.dtgSalirItem;
	
	//fila.onfocus=EncimaItem;
	//cogemos los links y al obtener los focos
	var links=fila.getElementsByTagName("a");
	for (l=0;l<links.length;l++)
	{
		links[l].fila=fila
		links[l].onfocus=this.FocoLink;
		links[l].onblur=this.BlurLink;
	}
	fila.links=links;
	
	fila.SalirItem();	
	this.filas[this.filas.length]=fila;
	
	return fila;
}

DatagridSeleccionable.prototype.ObtenerFilasSeleccionadas=function()
{
	var i=0;
	var filasSeleccionadas=new Array();
	if (this.filas)
	{
		while (this.filas[i])
		{
			if (this.filas[i].chkSeleccion.checked)
			{
				filasSeleccionadas[filasSeleccionadas.length]=this.filas[i];
			}
			i++;
		}
	}
	return filasSeleccionadas;
}

DatagridSeleccionable.prototype.BorrarSeleccionFilas=function ()
{
	var filasSeleccionadas=this.ObtenerFilasSeleccionadas();
	var i=0;
	while(filasSeleccionadas[i])
	{
		filasSeleccionadas[i].BorrarSeleccion();
		i++;
	}
	
}

DatagridSeleccionable.prototype.FocoLink=function()
{
	if (this.fila.datagrid.filaFoco!=null)
	{
		this.fila.datagrid.filaFoco.SalirItem();
	}
	this.fila.datagrid.filaFoco=this.fila;
	this.fila.EncimaItem();
	
}

DatagridSeleccionable.prototype.BlurLink=function()
{
	this.fila.SalirItem();
}


DatagridSeleccionable.prototype.dtgEncimaItem=function()
{
	
	if (this.datagrid.filaFoco!=null)
	{
		this.datagrid.filaFoco.SalirItem();
	}
	
	if (this.chkSeleccion.checked)
		this.className=this.datagrid.cssItemEncimaSeleccionado;
	else
		this.className=this.datagrid.cssItemEncimaDeseleccionado;
	
	//Seleccionamos
	//alert(window.document.title);
	
	this.datagrid.filaFoco=this;
	
}


DatagridSeleccionable.prototype.dtgSeleccionarItem=function()
{
	
	if ((!this.datagrid.seleccionMultiple) && (this.datagrid.filaSeleccionada!=null))
	{
		this.datagrid.filaSeleccionada.BorrarSeleccion();
	}
	this.datagrid.filaSeleccionada=this;
	this.chkSeleccion.checked=!this.chkSeleccion.checked;
	this.SalirItem();
	this.datagrid.AlCambiarSeleccion(this);
}

//Evento que se llamará al pulsar una Fila
// para que se ejecute en una página habrá que asignarlo de la siguiente forma
// objDatagridSeleccionable.AlCambiarSeleccion=NuevaFuncionAlCambiarSeleccion;
//donde NuevaFuncionAlCambiarSeleccion es una funcion que tiene la misma firma que esta.
DatagridSeleccionable.prototype.AlCambiarSeleccion=function(fila)
{
	
}

DatagridSeleccionable.prototype.dtgBorrarSeleccion=function()
{
	this.chkSeleccion.checked=false;
	this.SalirItem();
}

DatagridSeleccionable.prototype.dtgSalirItem=function(dtg, item, IdCheck)
{
	if (this.chkSeleccion.checked)
		this.className=this.datagrid.cssItemSeleccionado;
	else
		this.className=this.datagrid.cssItemDeseleccionado;
}


/*
	Menu por pestanias
*/

function MenuHorizontal(idTablaMenu,idHidden,funcionOnclick, cssEntra,cssSale,cssSeleccionada)
{	
	var tabla=this;
	tabla.tblMenu=document.getAspElementById(idTablaMenu);
	tabla.CreaOpcionMenu=CreaOpcionMenuHorizontal;
	tabla.CreaOpcionVacia=CreaOpcionMenuHorizontalVacia;
	if (!cssEntra)
		cssEntra="opcionMenuEntra";
		
	if (!cssSale)
		cssSale="opcionMenuDeseleccionada";
	if (!cssSeleccionada)
		cssSeleccionada="opcionMenuSeleccionada"
	
	if (funcionOnclick)
	{
		tabla.funcionOnclick=funcionOnclick;
	}
	
	tabla.cssEntra=cssEntra;
	tabla.cssSale=cssSale;
	tabla.cssSeleccionada=cssSeleccionada;
	tabla.campoOculto=document.getAspElementById(idHidden);
	tabla.opcionSeleccionada=null;
	tabla.DibujaMenu=DibujaMenuHorizontal;
	tabla.opciones=new Array();
	tabla.SeleccionaOpcionMenu=SeleccionaOpcionMenu;
	return tabla
}

function SeleccionaOpcionMenu(opcion)
{
	opcion.celda.SeleccionaOpcion();
}


function SeleccionaOpcion(AlInicializarMenu)
{
	this.opcion.menuPadre.opcionSeleccionada=this.opcion;
	this.opcion.menuPadre.campoOculto.value=this.opcion.valor;
	this.opcion.menuPadre.DibujaMenu();
	if ((!AlInicializarMenu) && (this.opcion.menuPadre.funcionOnclick))
	{
		this.opcion.menuPadre.funcionOnclick();
	}
}

function SaleOpcionMenuHorizontal()
{
	//this.opcion.menuPadre.opcionSeleccionada=this.opcion;
	//this.opcion.menuPadre.campoOculto.value=this.opcion.valor;
	//this.opcion.menuPadre.DibujaMenu();
	var opcionSeleccionada=this.opcion.menuPadre.opcionSeleccionada;
	if ((opcionSeleccionada!=null) && (opcionSeleccionada.valor==this.opcion.valor))
	{
		this.opcion.celda.className=this.opcion.menuPadre.cssSeleccionada;
	}else
	{
		this.opcion.celda.className=this.opcion.menuPadre.cssSale;
	}
}

function EntraOpcionMenuHorizontal()
{
	//this.opcion.menuPadre.opcionSeleccionada=this.opcion;
	//this.opcion.menuPadre.campoOculto.value=this.opcion.valor;
	//this.opcion.menuPadre.DibujaMenu();
	var opcionSeleccionada=this.opcion.menuPadre.opcionSeleccionada;
	if ((opcionSeleccionada==null) || (opcionSeleccionada.valor!=this.opcion.valor))
	{
		this.opcion.celda.className=this.opcion.menuPadre.cssEntra;
	}

}

function DibujaMenuHorizontal()
{
	for (i=0;i<this.opciones.length;i++)
	{
		var opcion=this.opciones[i];
		//si nos se ha establecido la opcion seleccionada entonces la seleccionamos
		if (this.opcionSeleccionada==null)
		{
			if (opcion.valor==this.campoOculto.value)
				this.opcionSeleccionada=opcion;
		
		}	
		
		//Seleccionamos la opcion si es la opcion seleccionada
		if ((this.opcionSeleccionada!=null) && (this.opcionSeleccionada.valor==opcion.valor))
		{
			
			opcion.celda.className=this.cssSeleccionada;
			if (opcion.objetoVisualizacion)
				opcion.objetoVisualizacion.style.display="block";
		}else
		{					
			opcion.celda.className=this.cssSale;
			if (opcion.objetoVisualizacion)
				opcion.objetoVisualizacion.style.display="none";
		}
		
	}
	this.tblMenu.style.visibility="visible";
}

function CreaOpcionMenuHorizontal(idCeldaMenu,valorMenu,idObjetoVisualizacion)
{
	var opcion=new OpcionMenuHorizontal(this,idCeldaMenu,valorMenu,idObjetoVisualizacion);
	this.opciones[this.opciones.length]=opcion;
	
	return opcion;
}


function CreaOpcionMenuHorizontalVacia(idCeldaMenu)
{
    var celda=document.getAspElementById(idCeldaMenu);
	celda.className=this.cssSale;
	return celda;
	
				
}

function OpcionMenuHorizontal(menuPadre,idCeldaMenu,valorMenu,idObjetoVisualizacion)
{
	var CeldaMenu=this;
	CeldaMenu.celda=document.getAspElementById(idCeldaMenu);
	CeldaMenu.celda.className=menuPadre.cssSale;
	CeldaMenu.valor=valorMenu;
	CeldaMenu.celda.onclick=SeleccionaOpcion;
	CeldaMenu.celda.onmouseover=EntraOpcionMenuHorizontal;
	CeldaMenu.celda.onmouseout=SaleOpcionMenuHorizontal;
	CeldaMenu.celda.EntraOpcion=EntraOpcionMenuHorizontal;
	CeldaMenu.celda.SaleOpcion=SaleOpcionMenuHorizontal;
	CeldaMenu.celda.SeleccionaOpcion=SeleccionaOpcion;
	
	CeldaMenu.celda.style.cursor="hand";
			
	CeldaMenu.menuPadre=menuPadre;
	CeldaMenu.objetoVisualizacion=document.getAspElementById(idObjetoVisualizacion);
	CeldaMenu.celda.opcion=CeldaMenu;
	var enlaces=CeldaMenu.celda.getElementsByTagName("a");
	
	for (i=0;i<enlaces.length;i++)
	{
		var enlace=new NuevoEnlaceMenuHorizontal(CeldaMenu,enlaces[i]);
	}
	
	if (menuPadre.campoOculto.value==CeldaMenu.valor)
	{
		CeldaMenu.celda.SeleccionaOpcion(true);
	}
	
	//CeldaMenu.celda.enlaces=enlaces;
	return CeldaMenu;
}


function NuevoEnlaceMenuHorizontal(CeldaMenu,enlace)
{
	enlace.opcion=CeldaMenu;
	//enlace.onfocus=EntraOpcion;
	if(window.addEventListener)
	{
		enlace.addEventListener("onfocus",EntraOpcionEnlace,false);
		enlace.addEventListener("onblur",SaleOpcionEnlace,false);
		if(enlace.opcion.menuPadre.funcionOnclick)
		{
			enlace.addEventListener("onclick",SeleccionaOpcionEnlace,false);
		}
	}else
	{
		enlace.attachEvent("onfocus",EntraOpcionEnlace);
		enlace.attachEvent("onblur",SaleOpcionEnlace);
		if(enlace.opcion.menuPadre.funcionOnclick)
		{
			enlace.attachEvent("onclick",SeleccionaOpcionEnlace);
		}
	}
	//enlace.onblur=SaleOpcionEnlace;
	return enlace;
}
function SeleccionaOpcionEnlace()
{
	event.cancelBubble=true;
	var enlace=event.srcElement;
	enlace.opcion.celda.SeleccionaOpcion();
	
	return false;
	
}

function EntraOpcionEnlace()
{
	var enlace=event.srcElement;//.iddocument.activeElement;
	enlace.opcion.celda.EntraOpcion();
	
}
function SaleOpcionEnlace()
{
	//alert(document.activeElement.id);
	//alert(event.srcElement.id)
	var enlace=event.srcElement;
	enlace.opcion.celda.SaleOpcion();
}



/****************************************************
Funciones para crear una CAPA DINÁMICA
*****************************************************/
/*
	Una capa dinámica se abre y cierra con un efecto.
	En principio aparecerá centrada en la página.
	Se puede utilizar para mostrar un texto opcional, una pequeña ventana, ú cualquier otro elemento.
	Todas las capas creadas se guardarán en un Array "document.CapasDinamicas"
	Para crear la capa habrá que pasarle un Div, y una Tabla. La tabla estará contenida en el Div y es la que distribuirá el contenido.
*/

//crea la capa
function CapaDinamica(idTblContenido,tituloVentana, ancho,alto, modal)
{
	this.ancho=ancho;
	if (modal)
		this.modal=true;
	else
		this.modal=false;
	
	this.alto=alto;
	this.id="Capa_" + idTblContenido;
	this.activa=false;
	
	if (!document.capasDinamicas)
	{
		document.capasDinamicas=new Array();
		document.capasDinamicasAbiertas=new Array();
	}
	
	
	
	this.indice=document.capasDinamicas.length;
	//creamos la capa
	var capa=document.createElement("div");
	capa.className="capaDinamica";
	///capa.style.border="#172a5b 1px solid";
	//capa.style.display="none";
	//capa.style.position="absolute";
	capa.style.zIndex=103+(this.indice*2);
	//capa.style.left="0px";
	//capa.style.top="0px";
	/*capa.style.backgroundColor="white";
	capa.style.overflow="hidden";
	capa.style.width="0px";
	capa.style.height="0px";
	capa.style.verticalAlign="top";*/
	//document.body.insertBefore(capa,document.body.firstChild);
	//lo tenemos que introducir dentro del Form Principal, para que si hay datos 
	//a guardar en el viewstate, se guarden y se conserven durante el postback
	if (document.forms.length>0)
		document.forms[0].appendChild(capa);
	else
		document.body.insertBefore(capa,document.body.firstChild);
	
	this.capa=capa;
	
		
	this.contenido=document.getAspElementById(idTblContenido);
	
	if (this.contenido)
		this.contenido.style.margin="0px";
	
	
	//creamos la tabla que contiene la apariencia de ventana
	var tblVentana=document.createElement("table");
	tblVentana.className="capaDinamicaTabla";
    tblVentana.style.width=this.ancho-6;
	
	
	var trVentana1=document.createElement("tr")
	var tdVentana1=document.createElement("td")
	var tdVentana2=document.createElement("td");
	trVentana1.className="capaDinamicaCabecera";
	//trVentana1.style.height="15px";
	//tdVentana1.id=this.id + "_titulo";
	tdVentana1.innerHTML=tituloVentana;
	tdVentana1.style.width=this.ancho-20;
		
	
	var hlkCerrar=document.createElement("a");
	hlkCerrar.href="javascript:;";
	hlkCerrar.onclick=this.OcultarVentana;
	hlkCerrar.innerHTML="[X]";
	hlkCerrar.capaDinamica=this;
	this.botonCerrar=hlkCerrar;
	
		
	tdVentana2.appendChild(hlkCerrar);
	tdVentana2.style.width="25px";
	tdVentana2.style.align="left";
	
	
	trVentana1.appendChild(tdVentana1);
	trVentana1.appendChild(tdVentana2);
	
	
	var trVentana2=document.createElement("tr");
	var tdVentana21=document.createElement("td");
	tdVentana21.colSpan=2;
	trVentana2.className="capaDinamicaContenido";
	if (this.contenido)
		tdVentana21.appendChild(this.contenido);
	
	trVentana2.appendChild(tdVentana21);
	
	
	
	
	
	var tBody=document.createElement("tbody");
	tBody.style.vAlign="top";
	tBody.appendChild(trVentana1);
	tBody.appendChild(trVentana2);
	tblVentana.appendChild(tBody);
		
	//tblVentana.style.display="block";
	
	
	document.body.insertBefore(tblVentana,document.body.firstChild);
	this.tablaVentana=tblVentana;
	
	
	this.capa.appendChild(tblVentana);
	this.capaPadre=null;//Esta propiedad nos vale para definir si una ventana depende de otra.
	
	
	
	//creamos un iFrame para que las listas se queden por debajo.
	this.iframe=document.createElement("IFRAME");
	this.iframe.className="capaDinamica";
	/*this.iframe.style.position=this.capa.style.position;
	this.iframe.style.overflow="auto";
	this.iframe.style.border="0px solid #ff0000";
	this.iframe.style.display="none";*/
	
	document.body.insertBefore(this.iframe,document.body.firstChild);
	document.capasDinamicas[this.indice]=this;
	//lo utilizamos para establecer la velocidad
	this.movimientoX=60;
	this.movimientoY=40;
	this.visible=false;
	
}


CapaDinamica.prototype.OcultarVentana=function()
{
	this.capaDinamica.Ocultar();
}

//Dependiendo del estado de la capa la Muestra ó la Oculta.
CapaDinamica.prototype.MostrarOcultar=function()
{
	if (this.visible)
	{
		this.Ocultar();
		
	}else
	{
		this.Mostrar();
	}
}

/****************
	Funciones que crean un frame para que desde una capa dinámica no se pueda ir a la parte de abajo.
	Hay que mejorarlas: añadiendo el frame a un div con una imagen al final para que cuando se pase el foco a la imagen
	se devuelva el foco al primer objeto del contenido de la capa dinámica que pueda obtener foco.
*****************/
/* 
function MostrarFrameDialogo(zIndex)
{
	var m = document.body;
  	var wnd = document.createElement('iframe');
  	wnd.style.width=100;
  	wnd.style.height=100;
  	wnd.style.filter="Alpha(opacity=20, finishopacity=20, style=2)";
	wnd.setAttribute('allowtransparency', 'true');
	wnd.id="frameDialogo"+zIndex;
	//wnd.setAttribute('src', "/imagenes/iconolapiz.gif");
	document.body.insertBefore(wnd,document.body.firstChild);
	wnd.style.position="absolute";
	wnd.style.zIndex=zIndex;
	var obj=new Object();
	obj.frameDialogo=wnd;
	obj.RedimensionaFrameDialogo=RedimensionaFrameDialogo;
	document.frameDialogoActual=obj;
		//Asignamos los Eventos a la página
	if (window.addEventListener)
	{
		window.addEventListener("onresize", RedimensionaFrameDialogo,false)
		window.addEventListener("onscroll", RedimensionaFrameDialogo,false)
	}else
	{
		window.attachEvent("onresize", RedimensionaFrameDialogo)
		window.attachEvent("onscroll", RedimensionaFrameDialogo)
	}
	obj.RedimensionaFrameDialogo();
}

function RedimensionaFrameDialogo()
{
	try{
	var frameDialogo=document.frameDialogoActual.frameDialogo;
	frameDialogo.style.width=document.body.clientWidth
	frameDialogo.style.height="100%"
	frameDialogo.style.left=window.document.body.scrollLeft
	frameDialogo.style.top=window.document.body.scrollTop//-21
	frameDialogo.style.display="block";
	}catch(e)
	{
		alert(e.message);
		window.setTimeout("document.frameDialogoActual.RedimensionaFrameDialogo();",100);
	}
}

function OcultarFrameDialogo()
{
	document.frameDialogoActual.frameDialogo.style.display="none";
}
*/
//Muestra la capa
CapaDinamica.prototype.Mostrar=function(sinEfecto)
{
		//MostrarFrameDialogo(parseInt(this.capa.style.zIndex)-1)
		if (!this.OcultarCapasDinamicasModales())
			return false;
		
		if (this.AlMostrar()==false)
			return;
		
		this.visible=true;
		if (this.contenido)
			this.contenido.style.display="none";
		this.capa.style.display="block";
		this.capa.style.top=((parseInt(document.body.clientHeight)-this.alto)/2)+parseInt(document.body.scrollTop);
		this.capa.style.left=((parseInt(document.body.clientWidth)-this.ancho)/2)+parseInt(document.body.scrollLeft);
		if (sinEfecto)
		{
			this.capa.style.width=this.ancho;
			this.capa.style.height=this.alto;
		}else
		{
			this.capa.style.width=0;
			this.capa.style.height=5;
		}
		this.iframe.style.zIndex=parseInt(this.capa.style.zIndex)-1;
		
		this.iframe.style.display="block";
		this.iframe.style.top=((parseInt(document.body.clientHeight)-this.alto)/2)+parseInt(document.body.scrollTop);
		this.iframe.style.left=((parseInt(document.body.clientWidth)-this.ancho)/2)+parseInt(document.body.scrollLeft);
		
		this.iframe.style.width=this.capa.style.width;
		this.iframe.style.height=this.capa.style.height;
		
		
			
		
		
				
		this.Maximizar();

}

//Realiza el Efecto de Maximizar la Capa.
CapaDinamica.prototype.Maximizar=function()
{
	try
	{
		if (!this.visible)
		{
			return;
		}
		
		if (parseInt(this.capa.style.width)>=this.ancho)
		{
			this.capa.style.width=this.ancho;
			this.capa.style.height=parseInt(this.capa.style.height)+this.movimientoY;
			this.iframe.style.width=this.ancho;
			this.iframe.style.height=this.capa.style.height;
			if (parseInt(this.capa.style.height)<this.alto)
			{
				window.setTimeout("document.capasDinamicas["+this.indice+"].Maximizar()",1);
			}else
			{
				if (this.contenido)
					this.contenido.style.display="block";
				this.capa.style.height=this.alto;
				this.iframe.style.height=this.alto;
				//this.capa.focus();
				this.botonCerrar.focus();
				//va a ser una cola tipo LIFO
				document.capasDinamicasAbiertas.unshift(this);
				this.AlTerminarMostrar();
				
			}
		}else
		{	
			this.capa.style.width=parseInt(this.capa.style.width)+this.movimientoX;
			this.iframe.style.width=this.capa.style.width;
			window.setTimeout("document.capasDinamicas["+this.indice+"].Maximizar()",1);
		}
	}
	catch(e)
	{	
		if (this.capa)
		{
			this.iframe.style.width=this.ancho;
			this.iframe.style.height=this.alto;
			this.iframe.style.display="block";
			
			this.capa.style.width=this.ancho;
			this.capa.style.height=this.alto;
			
			if (this.contenido)
				this.contenido.style.display="block";
			this.capa.style.display="block";
			this.capa.focus();
			this.AlTerminarMostrar();
			
		}
	
	}
}

//Oculta la Capa
CapaDinamica.prototype.Ocultar=function()
{
	if (this.AlOcultar()==false)
		return;
	
	if (this.visible)
	{
		if (this.contenido)
			this.contenido.style.display="none";
		this.visible=false;
		//va a ser una cola tipo LIFO
		document.capasDinamicasAbiertas.shift();
		this.Minimizar();
	}
}

//Evento producido al Ocultar la Capa.
//se puede utilizar para validar los datos antes de Cerrar.
CapaDinamica.prototype.AlOcultar=function()
{
	return true;
}

//Evento producido al Mostrar la Capa;
//Se puede utilizar para validar los datos antes de Mostrar
CapaDinamica.prototype.AlMostrar=function()
{
	return true;
}

//Evento producido al Ocultar la Capa.
CapaDinamica.prototype.AlTerminarMostrar=function()
{
		
}

//Evento producido al Mostrar la Capa;
CapaDinamica.prototype.AlTerminarOcultar=function()
{
	
}



//Oculta todas las capas contenidas en document.capasDinamicas que sean modales excepto la actual.
CapaDinamica.prototype.OcultarCapasDinamicasModales=function()
{
	var i=0;
	for (i=0;i<document.capasDinamicas.length;i++)
	{
		var capaInformacion=document.capasDinamicas[i];
		if ((i!=this.indice) && (capaInformacion.modal) && (capaInformacion.visible))
		{
			
				
				capaInformacion.Ocultar();
				//si no se ha podido ocultar es porque no ha pasado la validacion
				//realizada en el evento AlOcultar.
				if (capaInformacion.visible==true)
				{
					//capaInformacion.MostrarListas();
					//capaInformacion.OcultarListas();
					return false;
				}
		}
	}
	return true;
}
//Realiza el Efecto de Minimizar la Capa
CapaDinamica.prototype.Minimizar=function()
{

	
		
	try
	{	
		if (this.visible)
		{
			return;
		}
		if (parseInt(this.capa.style.height)>10)
		{
			var alto=parseInt(this.capa.style.height)-this.movimientoY;
			alto=(alto>0)?(alto):0;
			this.capa.style.height=alto;
			this.iframe.style.height=this.capa.style.height;
			window.setTimeout("document.capasDinamicas["+this.indice+"].Minimizar()",1);
		}else
		{	
			if (parseInt(this.capa.style.width)>10)
			{
				var ancho=parseInt(this.capa.style.width)-this.movimientoX
				ancho=(ancho>0)?(ancho):0;
				this.capa.style.width=ancho;
				this.iframe.style.width=this.capa.style.width;
				window.setTimeout("document.capasDinamicas["+this.indice+"].Minimizar()",1);					
			}else
			{
				
				this.capa.style.display="none";
				this.iframe.style.display="none";
				//OcultarFrameDialogo();
				if (this.capaPadre)
					this.capaPadre.Mostrar(true);
				this.AlTerminarOcultar();
				
				
			}
		}
	}
	catch(e)
	{	
		if (this.capa)
		{
			this.capa.style.height=parseInt(this.capa.style.height)-this.movimientoY;
			this.iframe.style.width=0;
			this.iframe.style.height=0;
			this.iframe.style.display="none";
			this.capa.style.width=0;
			this.capa.style.height=0;
			this.capa.style.display="none";
			this.visible=false;
			//OcultarFrameDialogo();
			this.AlTerminarOcultar();
			
		}
	}
}


/****************************************************
Funciones para crear un mensaje de Informacion
*****************************************************/
/*
	Una capa dinámica se abre y cierra con un efecto.
	En principio aparecerá centrada en la página.
	Se puede utilizar para mostrar un texto opcional, una pequeña ventana, ú cualquier otro elemento.
	Todas las capas creadas se guardarán en un Array "document.CapasDinamicas"
	Para crear la capa habrá que pasarle un Div, y una Tabla. La tabla estará contenida en el Div y es la que distribuirá el contenido.
*/

function MensajeAplicacion(texto,tiempo,ancho,alto,cssClass)
{
	
	//this.ancho=ancho;
	//this.alto=alto;
	if (!document.mensajesAplicacion)
	{
		document.mensajesAplicacion=new Array();
		document.mensajesAplicacionAbiertos=new Array();
	}
	this.id="MensajeAplicacion" + document.mensajesAplicacion.length;
	this.indice=document.mensajesAplicacion.length;
	
	//creamos la capa
	var capa=document.createElement("div");
	/*capa.style.border="#172a5b 1px solid";
		
	capa.style.display="none";
	
	capa.style.position="absolute";
	capa.style.zIndex=103;
	capa.style.left="0px";
	capa.style.top="0px";
	capa.style.backgroundColor="white";
	capa.style.overflow="hidden";
	capa.style.cursor="hand";*/
	if(!cssClass)
	    capa.className="mensajeAplicacion"
	else
	    capa.className=cssClass
	    
	if (!ancho)
		ancho="300px";
	if(!alto)
		alto="70px";
	capa.style.width=ancho;
	capa.style.height=alto;
	
	capa.style.verticalAlign="top";
	
	
	
	//lo tenemos que introducir dentro del Form Principal, para que si hay datos 
	//a guardar en el viewstate, se guarden y se conserven durante el postback
	if (document.forms.length>0)
		document.forms[0].appendChild(capa);
	else
		document.body.insertBefore(capa,document.body.firstChild);
	
	this.capa=capa;
	this.capa.mensajeAplicacion=this;
	this.capa.onmouseenter=this.AlEntrarRaton;
	this.capa.onmouseover=this.AlEstarEncimaRaton;
	this.capa.onmouseout=this.AlSalirRaton;
	
	
	
		
	this.mensaje=texto;
	
	//if (this.mensaje)
		//this.mensaje.style.margin="0px";
	
	
	//creamos la tabla que contiene la apariencia de ventana
	var tblVentana=document.createElement("table");
	tblVentana.className="tablaMensaje";
	/*tblVentana.style.visibility="visible";
	tblVentana.style.width="100%";
	tblVentana.style.height="100%";
	tblVentana.style.backgroundColor="white";
	tblVentana.style.backgroundImage="url(/imagenes/fondoMensaje.gif)";
	tblVentana.style.top=1;
	tblVentana.style.left=1;
	tblVentana.style.borderCollapse="collapse";
	tblVentana.style.margin="0px";*/
	
	var trVentana1=document.createElement("tr");
	var tdVentana1=document.createElement("td")
	var tdVentana2=document.createElement("td");
	trVentana1.className="tablaMensajeCabecera"
	/*trVentana1.style.height="15px";
	tdVentana1.style.borderBottom="1px solid #d8ddee";*/
	var tituloVentana="Globalnet"
	tdVentana1.innerHTML="<span>" + tituloVentana + "</span>";
	tdVentana1.style.width=parseInt(this.capa.style.width)-15;
	
		
	
	var hlkCerrar=document.createElement("a");
	hlkCerrar.href="javascript:;";
	hlkCerrar.onclick=this.Cerrar;
	hlkCerrar.innerHTML="X";
	hlkCerrar.mensajeAplicacion=this;
	this.botonCerrar=hlkCerrar;
	
		
	tdVentana2.appendChild(hlkCerrar);
	tdVentana2.style.width="20px";
	tdVentana2.style.align="left";
		
	trVentana1.appendChild(tdVentana1);
	trVentana1.appendChild(tdVentana2);
	
	var trEspacio=document.createElement("tr");
	var tdEspacio=document.createElement("td");
	tdEspacio.colSpan=2;
	tdEspacio.style.height="8px"
	trEspacio.appendChild(tdEspacio);
	
	
	
	var trVentana2=document.createElement("tr");
	var tdVentana21=document.createElement("td");
	tdVentana21.colSpan=2;
	tdVentana21.className="tablaMensajeCuerpo";
	
	
	if (this.mensaje)
		tdVentana21.innerHTML=this.mensaje;
	
	trVentana2.appendChild(tdVentana21);
	
	var trVentana3=document.createElement("tr");
	var tdVentana31=document.createElement("td");
	tdVentana31.colSpan=2;
	tdVentana31.innerHTML="&nbsp;";
	trVentana3.appendChild(tdVentana31);	
	
	var tBody=document.createElement("tbody");
	tBody.appendChild(trVentana1);
	tBody.appendChild(trEspacio);
	tBody.appendChild(trVentana2);
	tBody.appendChild(trVentana3);
	tblVentana.appendChild(tBody);
	
	document.body.insertBefore(tblVentana,document.body.firstChild);
	this.tablaVentana=tblVentana;
	
	this.capa.appendChild(tblVentana);
	
	
	
	//creamos un iFrame para que las listas se queden por debajo.
	this.iframe=document.createElement("IFRAME");
	this.iframe.style.position=this.capa.style.position;
	this.iframe.style.overflow="auto";
	this.iframe.style.border="0px solid #ff0000";
	this.iframe.style.display="none";
	this.iframe.style.width=this.capa.style.width;
	this.iframe.style.height=this.capa.style.height;
	
	document.body.insertBefore(this.iframe,document.body.firstChild);
	document.mensajesAplicacion[this.indice]=this;
	//lo utilizamos para establecer la velocidad
	this.velocidad=10;
	this.tiempoIntervalo=15;
	this.visible=false;
	this.ancho=parseInt(capa.style.width);
	this.alto=parseInt(capa.style.height);
	this.mostrado=0;
	//variable que indica si ocultar está activado
	this.ocultarActivado=true;
	this.alpha=0;
	//segundos que durará el mensaje
	if (tiempo)
		this.tiempoMensaje=tiempo;
	else 
		this.tiempoMensaje=6 //segundos
	
	this.intervalo=null;
	
	document.PosicionarMensajesAplicacionesAbiertos=this.PosicionarMensajesAplicacionesAbiertos;
	document.OcultarMensajesAplicacionesAbiertos=this.OcultarMensajesAplicacionesAbiertos;
	
	
	window.attachEvent("onresize", document.PosicionarMensajesAplicacionesAbiertos)
	
}
//tipo Mensaje
//1=Alpha
//2=Alargando
document.tipoEfectoMensajeAplicacion=2;

MensajeAplicacion.prototype.Mostrar=function()
{
	switch(document.tipoEfectoMensajeAplicacion)
	{
		case 1:{ this.MostrarAlpha();
			break;}
		case 2:{ this.MostrarAlargando();
			break;}		
	}
	
}

MensajeAplicacion.prototype.Ocultar=function(sinEfecto)
{
    if (sinEfecto)
    {
        this.OcultarSinEfecto();
    }else
    {
	    switch(document.tipoEfectoMensajeAplicacion)
	    {
		    case 1:{ this.OcultarAlpha();
			    break;}
		    case 2:{ this.OcultarAlargando();
			    break;}		
	    }
	}
}

MensajeAplicacion.prototype.DesAparecerSinEfecto=function()
{
    
}

MensajeAplicacion.prototype.Aparecer=function()
{
	switch(document.tipoEfectoMensajeAplicacion)
	{
		case 1:{ this.AparecerAlpha();
			break;}
		case 2:{ this.AparecerAlargando();
			break;}		
	}
}
MensajeAplicacion.prototype.DesAparecer=function()
{
	switch(document.tipoEfectoMensajeAplicacion)
	{
		case 1:{ this.DesAparecerAlpha();
			break;}
		case 2:{ this.DesAparecerAlargando();
			break;}		
	}
}




EjecutarEjemploMensajeAplicacion=function()
{
	
	document.ma1=new MensajeAplicacion("No olvide <b>Guardar</b> el presupuesto periódicamente para evitar la pérdida de datos.");
	document.ma1.tiempoMensaje=20;
	window.setTimeout("document.ma1.Mostrar();",1000);
	document.ma2=new MensajeAplicacion("No olvide <b>Guardar</b> el presupuesto periódicamente para evitar la pérdida de datos2.");
	document.ma2.alto=200;
	window.setTimeout("document.ma2.Mostrar();",2000);
	document.ma3=new MensajeAplicacion("No olvide <b>Guardar</b> el presupuesto periódicamente para evitar la pérdida de datos3.");
	document.ma3.alto=100;
	window.setTimeout("document.ma3.Mostrar();",3000);
	document.ma4=new MensajeAplicacion("No olvide <b>Guardar</b> el presupuesto periódicamente para evitar la pérdida de datos3.");
	document.ma4.alto=80;
	window.setTimeout("document.ma4.Mostrar();",5000);
}

MensajeAplicacion.prototype.OcultarMensajesAplicacionesAbiertos=function()
{
    if ((document.mensajesAplicacionAbiertos) && (document.mensajesAplicacionAbiertos.length>0))
    {
        var q=0;
        while (document.mensajesAplicacionAbiertos[q])
        {
            var mAplicacion=document.mensajesAplicacionAbiertos[q];
            if (mAplicacion.ocultarActivado)
            {
                mAplicacion.mostrado=0
                mAplicacion.DesAparecerAlargando();           
            }
            q++;
        }
    }    
}

MensajeAplicacion.prototype.PosicionarMensajesAplicacionesAbiertos=function()
{
	
	if ((document.mensajesAplicacionAbiertos) && (document.mensajesAplicacionAbiertos.length>0))
	{
		var q=0;
		var altoSuperior=parseInt(document.body.offsetHeight);
		
		var widthHTML=parseInt(document.body.getElementsByTagName("table")[0].clientWidth);
		
		var widthWindow=parseInt(document.body.offsetWidth);
		var left=widthWindow;
		
		if (widthWindow>widthHTML)
		   left=widthHTML + ((widthWindow-widthHTML)/2);			
		else
		   left=widthWindow;			
		   
		   
		while (document.mensajesAplicacionAbiertos[q])
		{
			var mensaje=document.mensajesAplicacionAbiertos[q];
			//posicionamos la primera capa
			if (q==0)
			{
				altoSuperior=altoSuperior-30-parseInt(mensaje.alto);
				mensaje.capa.style.top=altoSuperior;
				mensaje.capa.style.left=left-parseInt(mensaje.capa.style.width)-5;
				//mensaje.capa.style.left=parseInt(mensaje.capa.style.left)+parseInt(window.document.body.scrollLeft);
				mensaje.capa.style.top=parseInt(mensaje.capa.style.top)+parseInt(window.document.body.scrollTop);
	
			}else
			{
				//posicionamos las demás capas
				altoSuperior=altoSuperior-10-parseInt(mensaje.alto);
				mensaje.capa.style.top=altoSuperior;
				mensaje.capa.style.left=left-parseInt(mensaje.capa.style.width)-5;
				//mensaje.capa.style.left=parseInt(mensaje.capa.style.left)+parseInt(window.document.body.scrollLeft);
				mensaje.capa.style.top=parseInt(mensaje.capa.style.top)+parseInt(window.document.body.scrollTop);
			}
			
			mensaje.iframe.style.top=mensaje.capa.style.top;
			mensaje.iframe.style.left=mensaje.capa.style.left;
			q++;	
		}
		
		
		
		
	}
	
}

MensajeAplicacion.prototype.MostrarAlpha=function(texto)
{
	this.capa.onmouseenter=this.AlEntrarRaton;
	this.capa.onmouseover=this.AlEstarEncimaRaton;
	this.capa.onmouseout=this.AlSalirRaton;
	this.capa.onmouseout();
	this.capa.style.display="block";
	
	
	
	var i=0;
	var agregar=true;
	while(document.mensajesAplicacionAbiertos[i])
	{
		if (document.mensajesAplicacionAbiertos[i].id==this.id)
		{
			agregar=false;
			break;
		}
		i++;
	}
	if (agregar)
		document.mensajesAplicacionAbiertos.splice(document.mensajesAplicacionAbiertos.length,0,this);
	document.PosicionarMensajesAplicacionesAbiertos();
	this.capa.style.height=this.alto;
	this.capa.style.width=this.ancho;	
	this.capa.style.filter="Alpha(opacity=0, finishopacity=0, style=2)";
	this.alpha=0;
	this.iframe.style.top=this.capa.style.top;
	this.iframe.style.left=this.capa.style.left;
	this.iframe.style.display=this.capa.style.display;
	this.iframe.style.width=this.capa.style.width;
	this.iframe.style.height=this.capa.style.height;
	this.iframe.style.filter=this.capa.style.filter;
	
	//this.capa.style.left=parseInt(document.body.offsetWidth)-parseInt(this.capa.style.width)-10;
	
	//this.capa.style.left=parseInt(this.capa.style.left)+parseInt(window.document.body.scrollLeft);
	//this.capa.style.top=parseInt(this.capa.style.top)+parseInt(window.document.body.scrollTop);
	
	
	if (!this.ocultarActivado)
		this.botonCerrar.style.display="none";
	else
		this.botonCerrar.style.display="block";
	//this.iframe.style.display="block";
	//this.iframe.style.filter="Alpha(opacity=0, finishopacity=0, style=2)"
	if (this.intervalo)
		window.clearTimeout(this.intervalo);
	
	this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].Aparecer()",this.tiempoIntervalo);
	
	//this.Aparecer();
	
    //if(oc!=100) setTimeout('oc++;fadeIn()',40);
    //else setTimeout('fadeOut()',5000);</pre>
}

MensajeAplicacion.prototype.OcultarAlpha=function(texto)
{
	
	if (!this.ocultarActivado)
		return;
		
	//this.capa.style.filter="Alpha(opacity=0, finishopacity=0, style=2)"
	if (this.intervalo)
		window.clearTimeout(this.intervalo);
		
	this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].DesAparecer()",this.tiempoIntervalo);
	//this.alpha=0;
	//this.Aparecer();
	
    //if(oc!=100) setTimeout('oc++;fadeIn()',40);
    //else setTimeout('fadeOut()',5000);</pre>
}



MensajeAplicacion.prototype.AparecerAlpha=function(noLanzarOcultar)
{
	this.alpha+=this.velocidad;
	//alert(this.alpha);
	var finisHopacity=0;
	if (this.alpha>=100)
	{
		this.alpha=100;
		finisHopacity=100;
		this.visible=true;
		//va a ser una cola tipo LIFO
		//document.mensajesAplicacionAbiertos.splice(document.mensajesAplicacionAbiertos.length,0,this);
	}
	else
	{
		finisHopacity=this.alpha + Math.round(Math.random()*15);
		this.capa.style.display="block";
	}
	var tipo =Math.round(Math.random()*3);
	this.capa.style.filter="Alpha(opacity=" + this.alpha + ")"
	//this.capa.style.filter="Alpha(opacity=" + this.alpha + ", finishopacity=" + finisHopacity + ", style="+tipo+")"
		
	if (this.alpha<100)
	{
		if (this.intervalo)
			window.clearTimeout(this.intervalo);
		this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].Aparecer()",this.tiempoIntervalo);
	}else
	{
		window.clearTimeout(this.intervalo);
		//window.setTimeout("document.mensajesAplicacion["+this.indice+"].DesAparecer()",this.tiempoMensaje * 1000);
		if(!noLanzarOcultar)
		{
			this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].Ocultar()",this.tiempoMensaje * 1000);		
		}
	}
}

MensajeAplicacion.prototype.DesAparecerAlpha=function()
{
	if (!this.ocultarActivado)
		return;
	this.alpha-=this.velocidad;
	//alert(this.alpha);
	var finisHopacity=0;
	if (this.alpha<=0)
	{
		this.alpha=0;
		finisHopacity=0;
		this.visible=false;
		this.iframe.style.display="none";
		var m=0;
		
		while (m<document.mensajesAplicacionAbiertos.length)
		{
			if (this.id==document.mensajesAplicacionAbiertos[m].id)
			{
				document.mensajesAplicacionAbiertos.splice(m,1);
				document.PosicionarMensajesAplicacionesAbiertos();
			}
			m++;
		}
		
	}
	else
	{
		finisHopacity=this.alpha - Math.round(Math.random()*15);
	}
	var tipo =Math.round(Math.random()*3);
	this.capa.style.filter="Alpha(opacity=" + this.alpha + ")" //", finishopacity=" + finisHopacity + ", style="+tipo+")"
	this.iframe.style.filter=this.capa.style.filter;
	
	if (this.alpha>0)
	{
		if(this.intervalo)
			window.clearTimeout(this.intervalo);
		this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].DesAparecer()",this.tiempoIntervalo);
	}else
	{
		window.clearTimeout(this.intervalo);
		this.visible=false;
		this.alpha=0;
		this.capa.style.display="none";
		this.iframe.style.display=this.capa.style.display;
		
	}
}



//Funciones del Efecto de alargando: Son funciones más ligeras
MensajeAplicacion.prototype.MostrarAlargando=function(texto)
{
	
	this.capa.onmouseenter=this.AlEntrarRaton;
	this.capa.onmouseover=this.AlEstarEncimaRaton;
	this.capa.onmouseout=this.AlSalirRaton;
	this.capa.onmouseout();
	this.capa.style.display="none";
	
	
	var i=0;
	var agregar=true;
	while(document.mensajesAplicacionAbiertos[i])
	{
		if (document.mensajesAplicacionAbiertos[i].id==this.id)
		{
			agregar=false;
			break;
		}
		i++;
	}
	if (agregar)
		document.mensajesAplicacionAbiertos.splice(document.mensajesAplicacionAbiertos.length,0,this);
	
	this.mostrado=1;
	this.capa.style.height=this.mostrado;
	document.PosicionarMensajesAplicacionesAbiertos();
	
	this.iframe.style.top=this.capa.style.top;
	this.iframe.style.left=this.capa.style.left;
	this.iframe.style.display=this.capa.style.display;
	this.iframe.style.width=this.capa.style.width;
	this.iframe.style.height=this.capa.style.height;
	this.iframe.style.filter=this.capa.style.filter;
	
	this.capa.style.display="block";
	
	
	//this.capa.style.left=parseInt(document.body.offsetWidth)-parseInt(this.capa.style.width)-10;
	
	//this.capa.style.left=parseInt(this.capa.style.left)+parseInt(window.document.body.scrollLeft);
	//this.capa.style.top=parseInt(this.capa.style.top)+parseInt(window.document.body.scrollTop);
	
	
	if (!this.ocultarActivado)
		this.botonCerrar.style.display="none";
	else
		this.botonCerrar.style.display="block";
	//this.iframe.style.display="block";
	//this.iframe.style.filter="Alpha(opacity=0, finishopacity=0, style=2)"
	if (this.intervalo)
		window.clearTimeout(this.intervalo);
	
	this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].Aparecer()",this.tiempoIntervalo);
	
	//this.Aparecer();
	
    //if(oc!=100) setTimeout('oc++;fadeIn()',40);
    //else setTimeout('fadeOut()',5000);</pre>
}

MensajeAplicacion.prototype.OcultarAlargando=function(texto)
{
	
	if (!this.ocultarActivado)
		return;
		
	//this.capa.style.filter="Alpha(opacity=0, finishopacity=0, style=2)"
	if (this.intervalo)
		window.clearTimeout(this.intervalo);
		
	this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].DesAparecer()",this.tiempoIntervalo);
	//this.alpha=0;
	//this.Aparecer();
	
    //if(oc!=100) setTimeout('oc++;fadeIn()',40);
    //else setTimeout('fadeOut()',5000);</pre>
}



MensajeAplicacion.prototype.AparecerAlargando=function(noLanzarOcultar)
{
    this.mostrado+=this.velocidad;
	
	if (this.mostrado>this.alto)
		this.mostrado=this.alto;
		
	this.capa.style.height=this.mostrado;
	
		
	if (this.mostrado<this.alto)
	{
		if (this.intervalo)
			window.clearTimeout(this.intervalo);
		this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].Aparecer()",this.tiempoIntervalo);
	}else
	{
		//cuando se haya mostrado del todo entonces se lanza
		if (this.intervalo)
			window.clearTimeout(this.intervalo);
		this.visible=true;
		if(!noLanzarOcultar)
		{
			this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].Ocultar()",this.tiempoMensaje * 1000);		
		}
	}
}

MensajeAplicacion.prototype.DesAparecerAlargando=function()
{
	if (!this.ocultarActivado)
		return;
	this.mostrado-=this.velocidad;
	
	if (this.mostrado<=0)
	{
		this.mostrado=0;
		this.visible=false;
		this.iframe.style.display="none";
		var m=0;
		while (m<document.mensajesAplicacionAbiertos.length)
		{
			//buscamos el mensaje aplicacion a cerrar
			if (this.id==document.mensajesAplicacionAbiertos[m].id)
			{
				//lo eliminamos de la lista
				document.mensajesAplicacionAbiertos.splice(m,1);
				document.PosicionarMensajesAplicacionesAbiertos();
				
			}
			m++;
		}
		
	}
	
	this.capa.style.height=this.mostrado;
	this.iframe.style.height=this.capa.style.height;
	
	if (this.mostrado>0)
	{
		if(this.intervalo)
			window.clearTimeout(this.intervalo);
		this.intervalo=window.setTimeout("document.mensajesAplicacion["+this.indice+"].DesAparecer()",this.tiempoIntervalo);
	}else
	{
		window.clearTimeout(this.intervalo);
		this.visible=false;
		this.mostrado=0;
		this.capa.style.height=this.mostrado;
		this.iframe.style.height=this.capa.style.height;	
		this.capa.style.display="none";
		this.iframe.style.display=this.capa.style.display;
		
	}
}



//Se asignará el evento al entrar el ratón en la capa.
MensajeAplicacion.prototype.AlEntrarRaton=function()
{
	//this.mensajeAplicacion.Mostrar();
	this.mensajeAplicacion.ratonDentro=true;
	
	if (this.mensajeAplicacion.intervalo)
	{
		window.clearTimeout(this.mensajeAplicacion.intervalo);
		this.mensajeAplicacion.intervalo=null;
		
	}
	if (this.mensajeAplicacion.intervalo)
		window.clearTimeout(this.mensajeAplicacion.intervalo);
	this.mensajeAplicacion.intervalo=window.setTimeout("document.mensajesAplicacion["+this.mensajeAplicacion.indice+"].Aparecer(true)",this.tiempoIntervalo);
}

//se asignará el evento al salir el ratón en la capa
MensajeAplicacion.prototype.AlSalirRaton=function()
{
	this.mensajeAplicacion.ratonDentro=false;
	if (this.mensajeAplicacion.intervalo)
	{
		window.clearTimeout(this.mensajeAplicacion.intervalo);
		this.mensajeAplicacion.intervalo=null;
	}
	//this.style.border="#172a5b 1px solid";
	
	//this.mensajeAplicacion.Aparecer();
	if (this.mensajeAplicacion.intervalo)
		window.clearTimeout(this.mensajeAplicacion.intervalo);
	this.mensajeAplicacion.intervalo=window.setTimeout("document.mensajesAplicacion["+this.mensajeAplicacion.indice+"].Ocultar()",parseInt(this.mensajeAplicacion.tiempoMensaje/2) * 1000);
	
}

MensajeAplicacion.prototype.AlEstarEncimaRaton=function()
{
	if (this.mensajeAplicacion.intervalo)
	{
		window.clearTimeout(this.mensajeAplicacion.intervalo);
		this.mensajeAplicacion.intervalo=null;
	}
	if (this.alpha<100)
	{
		this.mensajeAplicacion.Aparecer();
	}
}

MensajeAplicacion.prototype.CancelarEvento=function()
{
    
}

MensajeAplicacion.prototype.Cerrar=function()
{
    this.mensajeAplicacion.capa.onmouseenter=this.mensajeAplicacion.CancelarEvento;
	this.mensajeAplicacion.capa.onmouseover=this.mensajeAplicacion.CancelarEvento;
	this.mensajeAplicacion.capa.onmouseout=this.mensajeAplicacion.CancelarEvento;
    
    if (this.mensajeAplicacion.intervalo)
	{
		window.clearTimeout(this.mensajeAplicacion.intervalo);
	}
	//this.mensajeAplicacion.capa.style.display="none";
	
	this.mensajeAplicacion.alpha=0;
	this.mensajeAplicacion.DesAparecer();
	var m=0;
	while (m<document.mensajesAplicacionAbiertos.length)
		{
			//buscamos el mensaje aplicacion a cerrar
			if (this.id==document.mensajesAplicacionAbiertos[m].id)
			{
				//lo eliminamos de la lista
				document.mensajesAplicacionAbiertos.splice(m,1);
				document.PosicionarMensajesAplicacionesAbiertos();
				
			}
			m++;
		}
	
	
}


