

//ruta de imagenes y estilos.
var rutaImagen = "images/";
var rutaEstilo = "/interfaz/css/";
var nombreImagenCerrar = "cerrar.jpg";
var imagenFondoTitulo = "titulo_fondo.jpg";
var nombreHojaEstilo = "estiloVentana.css";


//variables por defecto.
var veNombreVentanaUnico = "ventanaEmergente";
var veColorContenidoVentanaPorDefecto = "#D6E1F5";
var veAlineacionTituloPorDefecto = "center";
var veMostrarCerrarPorDefecto = true;
var veScrollBarHorizontalPorDefecto = "auto";
var veScrollBarVerticalPorDefecto = "auto";
var veActivarTraerAlFrente = true;
var veMostrarTitulo = true;
var veActivarNotificacionCierreVentana = false;


//incluimos los estilos
document.write('<link rel="stylesheet" type="text/css" href="' + rutaEstilo + nombreHojaEstilo + '">\n');



/* ----------------------------------------------------------------------
  Function    : Ventana()
  Description : crear una nueva ventana.
  Usage       : Ventana(left,top,ancho,alto,idDivContenido,idVentana,[textoTitulo],[colorVentana],[mostrarCerrar])
  Arguments   : *left*(int/objeto html)   - Posición 'x' de la ventana, puede ser un valor numérico o un objeto html del cual obtenemos su left.
	              *top*(int/objeto html) 		- Posición 'y' de la ventana, puede ser un valor numérico o un objeto html del cual obtenemos su top.
								*ancho*(int)        			- Ancho que queremos que tenga la ventana, es un valor numérico.
								*alto*(int)        				- Alto que queremos que tenga la ventana, es un valor numérico.
	              *idDivContenido*(string)  - Es el 'id' del div que contiene el contenido html que queremos agregar a la ventana,
	              se recibe el nombre del tag 'id' del objeto div, si este objeto no es de tipo '[object HTMLDivElement]' (no funciona en IE por tanto no comprueba este tipo de
	              objeto) no se agregará a la ventana popup.
                
                *idVentana*(int)    		  - Valor numérico que usaremos para identificar cada ventana que creamos, debe ser único y de valor numérico,el div principal
                de la ventana emergente tendrá un id que será '"ventanaEmergente"+idVentana'.
                
                *textoTitulo*(string)    	- Título de la ventana.
                *colorVentana(string)*    - Color de la ventana.
                *mostrarCerrar(boolean)*  - Mostrar o no el botón cerrar en la ventana.
---------------------------------------------------------------------- */


function Ventana(left,top,ancho,alto,idDivContenido,idVentana,textoTitulo,colorVentana,mostrarCerrar)
{
	
	//variables de la ventana.
	this.activarTraerAlFrente = veActivarTraerAlFrente;
	this.ancho = ancho;
	this.alto = alto;
	this.idNumeroVentana = idVentana;
	this.idVentana = veNombreVentanaUnico + idVentana;
	this.top = 50;
	this.left = 50;
	this.textoTitulo = textoTitulo;
	this.mostrarTitulo = veMostrarTitulo;
	this.colorContenido = colorVentana;
	this.alineacionTitulo = veAlineacionTituloPorDefecto;
	this.mostrarCerrar = mostrarCerrar;
	this.divVentanaEmergente = null;
	this.tablePrincipal = null;
	this.tableSecundaria = null;
	this.tableTercera = null;
	this.eTituloTD = null;
	this.divScroll = null;
	this.eContenidoTD = null;
	this.activarNotificacionCierreVentana = veActivarNotificacionCierreVentana;
	
	//color ventana
	if (this.colorContenido==null || this.colorContenido==undefined){
		this.colorContenido = veColorContenidoVentanaPorDefecto;
	}
	else if (this.colorContenido==''){
		this.colorContenido = veColorContenidoVentanaPorDefecto;
	}
	
	//texto titulo
	if (this.textoTitulo==null || this.textoTitulo==undefined){
		this.textoTitulo = "";
	}
	
	//mostrar cerrar
	if (this.mostrarCerrar==null || this.mostrarCerrar==undefined){
		this.mostrarCerrar = veMostrarCerrarPorDefecto;
	}
	
	//posicionamos la ventana según no llegue una posición númerica o...
	//...un objeto identificado por su id del cual obtenemos su posición.
	if (!isNaN (top) && !isNaN (left)){
	//es un valor numerico.
		this.top = top;
		this.left = left;
	} 
	else{
		//es un objeto html.
		this.top = Ventana.prototype.findPosY(document.getElementById(top));
		this.left = Ventana.prototype.findPosX(document.getElementById(left));
	}
	
	
	//variables de uso para generar ventana.
	var eTR;
	var eTD;
	var eTextNode;
	var eAnchor;
	var eCerrarTD;
	var eMinimizarTD;
	var eMaximizarTD;
	var imgTag;
	
	//------------------creamos los div -  div principal -----------------------
	this.divVentanaEmergente = document.createElement("div");
	this.divVentanaEmergente.setAttribute("id",this.idVentana);
	this.divVentanaEmergente.style.position = "absolute";
	this.divVentanaEmergente.style.left = this.left + "px";
	this.divVentanaEmergente.style.top = this.top + "px";
	this.divVentanaEmergente.style.visibility = "hidden";
	this.divVentanaEmergente.style.width =  this.ancho + "px";
	this.divVentanaEmergente.style.height = this.alto + "px";
	

	
	// al hacer click en el div principal lo ponemos delante de todas las otras ventanas.
	this.divVentanaEmergente.ventana = this;
	if (this.activarTraerAlFrente){
		this.divVentanaEmergente.onmousedown = Ventana.prototype.traerAlFrente;
	}
	//---------------------------------------------------------------------------
	
	
	//------------------------classBlur-----------------------------------------
	var divClassBlur = document.createElement("div");
	divClassBlur.id="eDivClassBlur";
	divClassBlur.className = "blur";
	//---------------------------------------------------------------------------
	
	
	
	//----------------------classShadow-----------------------------------------
	var divClassShadow = document.createElement("div");
	divClassShadow.id="eDivClassShadow";
	divClassShadow.className = "shadow";
	//---------------------------------------------------------------------------




	//--------------------classContent------------------------------------------
	var divClassContent = document.createElement("div");
	divClassContent.id="eDivClassContent";
	divClassContent.className = "content";
	divClassContent.style.backgroundColor = this.colorContenido;
	//---------------------------------------------------------------------------
	
	
	
	
	//--------------------creamos el table principal----------------------------
	this.tablePrincipal = document.createElement("table");
  this.tablePrincipal.cellSpacing = 0;
	this.tablePrincipal.cellPadding = 2;
	this.tablePrincipal.border = 0;
	this.tablePrincipal.id = "eTableprincipal";
	this.tablePrincipal.style.backgroundColor = this.colorContenido;
	//---------------------------------------------------------------------------
	
	
	
	
	//-----------------------creamos el table secundaria------------------------
	this.tableSecundaria = document.createElement("table");
 	this.tableSecundaria.width = "100%";
	this.tableSecundaria.border = 0;
	this.tableSecundaria.id = "eTableSecundaria";
	this.tableSecundaria.style.backgroundColor = "#FFFFFF";
		
	//añadimos los elementos a la tabla secundaria.
	
	//primer TR.
	//------------titulo-----------------------------
	if (this.mostrarTitulo){
		eTR = this.tableSecundaria.insertRow(0);
		eTR.id = "eTRTitulo";
		eTR.className = "tituloEstilo";

		//primer TD del primer TR (titulo).
		this.eTituloTD = eTR.insertCell(0);
		//ponemos espacios al titulo según alineación.
		if (this.alineacionTitulo=='right'){
			this.textoTitulo = this.textoTitulo + "&nbsp;";
		}
		else if (this.alineacionTitulo=='left'){
			this.textoTitulo = "&nbsp;" + this.textoTitulo;
		}
		
		//si el titulo se envia vacio ponemos espacio en blanco.
		if (Ventana.prototype.trim(this.textoTitulo)==''){
			this.textoTitulo = "&nbsp;";
		}
		
		//no sigue el estandar de DOM (innerHTML).
		this.eTituloTD.innerHTML = this.textoTitulo;
		//no uso el ejemplo de abajo porque no me permite espacios.
		/*eTextNode = document.createTextNode(title);
		eTD.appendChild(eTextNode);*/
		
		//alineacion del titulo.
		this.eTituloTD.align=this.alineacionTitulo;
		this.eTituloTD.style.borderBottom = "1px solid #000000";
		this.eTituloTD.style.backgroundImage = "url(" + rutaImagen + imagenFondoTitulo + ")";
		this.eTituloTD.height = "20%";
		this.eTituloTD.width = "98%";
		this.eTituloTD.id = "eTDTextoTitulo";
	}
	//--------------------------------------------



	//boton cerrar---------------------------.
	if (this.mostrarCerrar){
		if (this.mostrarTitulo){
			//se mostrara el titulo y el boton cerrar.
			eCerrarTD = eTR.insertCell(1);
			eCerrarTD.style.borderBottom = "1px solid #000000";
			eCerrarTD.style.backgroundImage = "url(" + rutaImagen + imagenFondoTitulo + ")"; 
		}
		else{
			//solo mostramos el boton cerrar pero no el titulo.
			this.tableSecundaria.style.backgroundColor = this.colorContenido;
			eTR = this.tableSecundaria.insertRow(0);
			//---------------------
			eTR.id = "eTRTitulo";
			this.eTituloTD = eTR.insertCell(0);
			this.eTituloTD.id = "eTDTextoTitulo";
			//--------------------
			//eTR.id = "eTRTituloSoloCerrar";
			//eTR.className = "tituloEstilo";
			eCerrarTD = eTR.insertCell(1); 
			eCerrarTD.align="right";
			eCerrarTD.style.backgroundColor = this.colorContenido;
		}
		//creamos el tag img y lo agregamos.
		imgTag = document.createElement("img");
		imgTag.id = "eIMGCerrar";
		imgTag.src=rutaImagen + nombreImagenCerrar;
		eCerrarTD.appendChild(imgTag);
	
		eCerrarTD.ventana = this;
		eCerrarTD.style.cursor="pointer";
		eCerrarTD.onmousedown = Ventana.prototype.cerrar;
	  eCerrarTD.width = "1%";
		eCerrarTD.style.paddingLeft = "1px";
		eCerrarTD.id = "eTDCerrar";
	}
	//------------------------------------------------
	
	
	//---------------------------------------------------------------------------
	
	//-----------------creamos el table tercera----------------------------------
	this.tableTercera = document.createElement("table");
 	this.tableTercera.width = "100%";
 	this.tableTercera.height = "100%";
	this.tableTercera.cellSpacing = 0;
	this.tableTercera.cellPadding = 2;
	this.tableTercera.border = 0;
	this.tableTercera.id = "eTableTercera";
	this.tableTercera.style.backgroundColor = "#FFFFFF";
	//añadimos los elementos a la tabla tercera.
	eTR = this.tableTercera.insertRow(0);
	eTR.id = "eTRTableTercera";
	this.eContenidoTD = eTR.insertCell(0);
	this.eContenidoTD.style.backgroundColor = this.colorContenido;
	this.eContenidoTD.id="eTDTableTerceraContenido";
	
	
	//no sigue el estandar de DOM (innerHTML)
	//recibimos el nombre de un 'id' de un div y será lo que cargamos en la ventana.
	var divAgregar = document.getElementById(idDivContenido);
	if (divAgregar!=null && divAgregar!=undefined){
	//si el elemento existe y es de tipo '[object HTMLDivElement]' entonces lo agregamos(NO FUNCIONA EN IE).
	//if (divAgregar=='[object HTMLDivElement]'){
			this.eContenidoTD.innerHTML = divAgregar.innerHTML;
		//}
	}
	//---------------------------------------------------------------------------
	
	
	
	//--------------------creamos el div de scroll-------------------------------
	this.divScroll = document.createElement("div");
	this.divScroll.id = "eDivScrollbar";
	this.divScroll.style.overflow = "hidden";
	this.divScroll.style.overflowY = veScrollBarVerticalPorDefecto;
	this.divScroll.style.overflowX = veScrollBarHorizontalPorDefecto;
	this.divScroll.style.scrollTop  = 0 + "px";
	this.divScroll.style.scrollLeft = 0 + "px";

	
	
	/*if (mostrarScrollBarVertical==true){
		scrollbarObj.style.height=this.alto - (this.alto/6); 
	} else{
		scrollbarObj.style.height=this.alto - 16; //- (this.alto/4); 
	}*/
	
	//this.divScroll.style.width =   (this.ancho - (this.ancho/22)) + "px";
	this.divScroll.style.width =   this.ancho - 21 + "px";
	
	//this.divScroll.style.height =  (this.alto - (this.alto/22)) + "px"; 
	this.divScroll.style.height =  this.alto - 21 + "px"; 
	//---------------------------------------------------------------------------
	
	
	
	//--------añadimos los elementos a la tabla principal------------------------
	eTR = this.tablePrincipal.insertRow(0);
	eTR.id ="eTRAddTableSecundariaToPrincipal";
	eTD = eTR.insertCell(0);	
	eTD.id ="eTDAddTableSecundariaToPrincipal";
	//añadimos la tabla secundaria a la tabla principal.
	eTD.appendChild(this.tableSecundaria);

	eTR = this.tablePrincipal.insertRow(1);
	eTR.id ="eTRAddScrollToTablePrimera";
	eTD = eTR.insertCell(0);
	eTD.id ="eTDAddScrollToTablePrimera";
	//añadimos la tabla tercera al div scroll.
	this.divScroll.appendChild(this.tableTercera);
	//añadimos el div scroll a la tabla principal.
	eTD.appendChild(this.divScroll);
	//---------------------------------------------------------------------------
	
	
	//--------añadimos la tabla principal al primer div (content)----------------
	divClassContent.appendChild(this.tablePrincipal);
	//---------------------------------------------------------------------------
	
	//--------añadimos el div content al div shadow-----------------------------
	divClassShadow.appendChild(divClassContent);
	//---------------------------------------------------------------------------
	
	//--------añadimos el div shadow al div blur-----------------------------
	divClassBlur.appendChild(divClassShadow);
	//---------------------------------------------------------------------------
	
	
	//--------añadimos el div blur al div ventanaEmergente-----------------------------
	this.divVentanaEmergente.appendChild(divClassBlur);
	//---------------------------------------------------------------------------
	
		
	//añadimos todo al body del documento.
	document.body.appendChild(this.divVentanaEmergente);
	
}


/*------------------------traerAlFrente----------------------------------------------
Función     : traerAlFrente()
Descripción : Método que permite mostrar una ventana sobre otra al seleccionarla.
Uso         : traerAlFrente()
-------------------------------------------------------------------------------------*/
Ventana.prototype.traerAlFrente = function()
{
	
	if (this.ventana.divVentanaEmergente!=null && this.ventana.divVentanaEmergente!=undefined){
		//recibe una referencia de ventana emergente (this es un puntero a 'divVentanaEmergente' que es
		//...el objeto que llamó a este método).
		if ( document.body.childNodes[document.body.childNodes.length-1] !== this.ventana.divVentanaEmergente)
		{
			//situa la ventana al principio
			document.body.appendChild(this.ventana.divVentanaEmergente);
		}
	}
}
//-------------------------------------------------------------------------------------


/*------------------------cerrar-----------------------------------------------------
Función     : cerrar()
Descripción : Cierra la ventana actual y luego la destruye.
Uso         : cerrar()
-------------------------------------------------------------------------------------*/
Ventana.prototype.cerrar = function()
{	
	
	//diferenciamos de donde viene, si se llama desde el boton cerrar es 'this.ventana.divVentanaEmergente'...
	//si llama desde fuera es 'this.divVentanaEmergente'.
	if (this.ventana!=null){
		if (this.ventana.divVentanaEmergente!=null && this.ventana.divVentanaEmergente!=undefined){
			//cerramos la ventana actual.
			if (this.ventana.divVentanaEmergente.parentNode!=null && this.ventana.divVentanaEmergente.parentNode!=undefined){
				this.ventana.divVentanaEmergente.parentNode.removeChild(this.ventana.divVentanaEmergente);
			}
			//destruimos la ventana.
			this.ventana.destruir();
		}
	}
	else if (this.divVentanaEmergente!=null){
		if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
			//cerramos la ventana actual.
			if (this.divVentanaEmergente.parentNode!=null && this.divVentanaEmergente.parentNode!=undefined){
				this.divVentanaEmergente.parentNode.removeChild(this.divVentanaEmergente);
			}
			//destruimos la ventana.
			this.destruir();
		}
	}
	/*llama a este metodo si existe para notificar que id (numero) de ventana se ha cerrado
	siempre y cuando este activada la notificacion por 'setActivarNotificacionCierreVentana(true)'.*/
	if (this.ventana!=null){
    	if (this.ventana.activarNotificacionCierreVentana){
    		cerrarVentana(this.ventana.idNumeroVentana);
    	}
    }
  	else{
  		if (this.activarNotificacionCierreVentana){
  			cerrarVentana(this.idNumeroVentana);
  		}
  	}
}
//-------------------------------------------------------------------------------------


/*------------------------setActivarNotificacionCierreVentana--------------------------------------------
Función     : setActivarNotificacionCierreVentana()
Descripción : Establece el ancho de la ventana.
Uso         : setActivarNotificacionCierreVentana(activar)
Argumentos  : *activar*  - Recibe un bolean activando o no la notificación de cierre de la ventana
							, si se establece a 'true' se tiene que declarar en tu html la función:
													
													function cerrarVentana(id){
														//tu código
													}
-------------------------------------------------------------------------------------*/
Ventana.prototype.setActivarNotificacionCierreVentana = function (activar){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		this.activarNotificacionCierreVentana = activar;
	}
}
//-------------------------------------------------------------------------------------



/*------------------------isActive--------------------------------------------
Función     : isActive()
Descripción : Indica si la ventana esta viva.
Uso         : isActive()
Argumentos  : Devuelve un booleano indicando si la ventana existe o esta destruida.
-------------------------------------------------------------------------------------*/
Ventana.prototype.isActive = function (){
	
	var active = false;
	if (this.idVentana!=null){
		if (document.getElementById(this.idVentana)){
			active = true;
		}
	}
	return active;
}
//-------------------------------------------------------------------------------------



/*------------------------findPosX---------------------------------------------------
Función     : findPosX()
Descripción : Obtenemos la posición 'X' del objeto html pasado por parámetro.
Uso         : findPosX(obj)
Argumentos  : *obj*  - Es un objeto html obtenido por 'getElementById' (no un 'id').
-------------------------------------------------------------------------------------*/
Ventana.prototype.findPosX = function (obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
} 
//-------------------------------------------------------------------------------------

/*------------------------findPosY---------------------------------------------------
Función     : findPosY()
Descripción : Obtenemos la posición 'y' del objeto html pasado por parámetro.
Uso         : findPosY(obj)
Argumentos  : *obj*  - Es un objeto html obtenido por 'getElementById' (no un 'id').
-------------------------------------------------------------------------------------*/
Ventana.prototype.findPosY = function (obj){
	var curTop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curTop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y){
		curTop += obj.y;
	}
	return curTop;
} 
//-------------------------------------------------------------------------------------



/*------------------------visible---------------------------------------------------
Función     : visible()
Descripción : Hace visible la ventana.
Uso         : visible()
-------------------------------------------------------------------------------------*/
Ventana.prototype.visible = function(){
		if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
			this.divVentanaEmergente.style.visibility="visible";
		}
}
//-------------------------------------------------------------------------------------



/*------------------------ocultar---------------------------------------------------
Función     : ocultar()
Descripción : Oculta la ventana.
Uso         : ocultar()
-------------------------------------------------------------------------------------*/
Ventana.prototype.ocultar = function(){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		this.divVentanaEmergente.style.visibility="hidden";
	}
}
//-------------------------------------------------------------------------------------


/*------------------------destruir---------------------------------------------------
Función     : destruir()
Descripción : Destruye la ventana de memoria.
Uso         : destruir()
-------------------------------------------------------------------------------------*/
Ventana.prototype.destruir = function(){
		
		if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
			if (this.divVentanaEmergente.parentNode!=null && this.divVentanaEmergente.parentNode!=undefined){
				this.divVentanaEmergente.parentNode.removeChild(this.divVentanaEmergente);
			}
			//destruimos todos los objetos (DOM html) de la ventana.
			this.destruirAll(this.divVentanaEmergente);
		}
		this.tablePrincipal = null;
		this.tableSecundaria = null;
		this.tableTercera = null;
		this.eTituloTD = null;
		this.divScroll = null;
		this.eContenidoTD = null;
		this.divVentanaEmergente = null;
}
//-------------------------------------------------------------------------------------



/*------------------------destruir---------------------------------------------------
Función     : destruirAll()
Descripción : Destruye todos los objetos que conforman la ventana.
Uso         : destruirAll()
Argumentos  : *nodoPadre*  - Recibe un nodo padre del cual recorreremos los hijos de este.
-------------------------------------------------------------------------------------*/
Ventana.prototype.destruirAll = function(nodoPadre){
	
	var nodoRecorrer;
	
	if (nodoPadre.firstChild!=null){
		nodoRecorrer = nodoPadre.firstChild;
	
		while (nodoRecorrer!=null){
			//el TD que contiene el contenido del DIV agregado ('eTDTableTerceraContenido')...
			//....no se toca, si eleminamos el TD pero no el contenido.
			if (nodoRecorrer.hasChildNodes() && nodoRecorrer.id!='eTDTableTerceraContenido'){
			//función recursiva.
					this.destruirAll(nodoRecorrer);
			}
			nodoRecorrer = nodoRecorrer.nextSibling;
			if (nodoRecorrer!=null){
				//alert("nodo id/name -->  " + nodoRecorrer.previousSibling.id + "  /  " + nodoRecorrer.previousSibling);
				//eliminamos el elemento anterior, siempre y cuando haya más de uno contenido en nodoPadre.
				nodoRecorrer.previousSibling.parentNode.removeChild(nodoRecorrer.previousSibling);
			}
		}
		//alert("nodo id/name -->  " + nodoPadre.firstChild.id + "  /  " + nodoPadre.firstChild);
		//nos situamos en el nodo padre del primer y unico elemento de la lista y lo eliminamos.
		nodoPadre.firstChild.parentNode.removeChild(nodoPadre.firstChild);
	}
	
}
//-------------------------------------------------------------------------------------



/*------------------------setTituloVentana--------------------------------------------
Función     : setTituloVentana()
Descripción : Establece el título de la ventana.
Uso         : setTituloVentana(titulo)
Argumentos  : *titulo*  - Recibe un string con el título.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setTituloVentana = function (titulo){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (this.mostrarTitulo){
			if (titulo!=null && titulo!=undefined){
				this.textoTitulo = titulo;
				//no sigue el estandar de DOM (innerHTML).
				this.eTituloTD.innerHTML = this.textoTitulo;
			}
		}
	}
}

//-------------------------------------------------------------------------------------




/*------------------------mostrarTituloVentana--------------------------------------------
Función     : mostrarTituloVentana()
Descripción : Establece si se verá o no el título de la ventana.
Uso         : mostrarTituloVentana(mostrar)
Argumentos  : *mostrar*  - Recibe un boolean para mostrar o no el título de la ventana.
							*titulo*   - Recibimos un string con el titulo a mostrar, si mostrar es false podemos enviar en blanco ('').
-------------------------------------------------------------------------------------*/
Ventana.prototype.mostrarTituloVentana = function (mostrar,titulo){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		this.mostrarTitulo=mostrar;
		if (this.mostrarTitulo){
			if (titulo!=null && titulo!=undefined){
				this.textoTitulo = titulo;
			}
		}
		//destruimos todos los objetos (DOM html) de la ventana.
		this.destruirAll(this.tableSecundaria);
		//cargamos la barra titulo con los nuevos datos.
		//siempre en este orden de creación.
		this.crearBarraTitulo();
		this.crearBotonCerrarTitulo();
	}
}
//-------------------------------------------------------------------------------------




/*------------------------mostrarBotonCerrar--------------------------------------------
Función     : mostrarBotonCerrar()
Descripción : Establece si se verá o no el botón cerrar de la ventana.
Uso         : mostrarBotonCerrar(mostrar)
Argumentos  : *mostrar*  - Recibe un boolean para mostrar o no el botón cerrar de la ventana.
-------------------------------------------------------------------------------------*/
Ventana.prototype.mostrarBotonCerrar = function (mostrar){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
			this.mostrarCerrar = mostrar;
			
			//destruimos todos los objetos (DOM html) de la ventana.
			this.destruirAll(this.tableSecundaria);
			//cargamos la barra titulo con los nuevos datos.
			//siempre en este orden de creación.
			this.crearBarraTitulo();
			this.crearBotonCerrarTitulo();
	}
}

//-------------------------------------------------------------------------------------



/*------------------------crearBarraTitulo--------------------------------------------
Función     : crearBarraTitulo()
Descripción : Vuelve a generar la barra de titulo según las opciones establecidas.
Uso         : crearBarraTitulo()
-------------------------------------------------------------------------------------*/

Ventana.prototype.crearBarraTitulo = function (){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (this.mostrarTitulo){
			eTR = this.tableSecundaria.insertRow(0);
			eTR.id = "eTRTitulo";
			eTR.className = "tituloEstilo";
	
			//primer TD del primer TR (titulo).
			this.eTituloTD = eTR.insertCell(0);
			//ponemos espacios al titulo según alineación.
			if (this.alineacionTitulo=='right'){
				this.textoTitulo = this.textoTitulo + "&nbsp;";
			}
			else if (this.alineacionTitulo=='left'){
				this.textoTitulo = "&nbsp;" + this.textoTitulo;
			}
			
			//si el titulo se envia vacio ponemos espacio en blanco.
			if (Ventana.prototype.trim(this.textoTitulo)==''){
				this.textoTitulo = "&nbsp;";
			}
			
			//no sigue el estandar de DOM (innerHTML).
			this.eTituloTD.innerHTML = this.textoTitulo;
			//no uso el ejemplo de abajo porque no me permite espacios.
			/*eTextNode = document.createTextNode(title);
			eTD.appendChild(eTextNode);*/
			
			//alineacion del titulo.
			this.eTituloTD.align=this.alineacionTitulo;
			this.eTituloTD.style.borderBottom = "1px solid #000000";
			this.eTituloTD.style.backgroundImage = "url(" + rutaImagen + imagenFondoTitulo + ")";
			this.eTituloTD.height = "20%";
			this.eTituloTD.width = "98%";
			this.eTituloTD.id = "eTDTextoTitulo";
		}
	}
}
//-------------------------------------------------------------------------------------




/*------------------------crearBotonCerrarTitulo--------------------------------------------
Función     : crearBotonCerrarTitulo()
Descripción : Vuelve a generar el botón de cerrar del titulo según las opciones establecidas.
Uso         : crearBotonCerrarTitulo()
-------------------------------------------------------------------------------------*/

Ventana.prototype.crearBotonCerrarTitulo= function (){

	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (this.mostrarCerrar){
			if (this.mostrarTitulo){
				//se mostrara el titulo y el boton cerrar.
				eCerrarTD = eTR.insertCell(1);
				eCerrarTD.style.borderBottom = "1px solid #000000";
				eCerrarTD.style.backgroundImage = "url(" + rutaImagen + imagenFondoTitulo + ")"; 
			}
			else{
				//solo mostramos el boton cerrar pero no el titulo.
				this.tableSecundaria.style.backgroundColor = this.colorContenido;
				eTR = this.tableSecundaria.insertRow(0);
				//----------------
				eTR.id = "eTRTitulo";
				this.eTituloTD = eTR.insertCell(0);
				this.eTituloTD.id = "eTDTextoTitulo";
				//-----------------
				//eTR.id = "eTRTituloSoloCerrar";
				//eTR.className = "tituloEstilo";
				eCerrarTD = eTR.insertCell(1); 
				eCerrarTD.align="right";
				eCerrarTD.style.backgroundColor = this.colorContenido;
			}
			//creamos el tag img y lo agregamos.
			imgTag = document.createElement("img");
			imgTag.id = "eIMGCerrar";
			imgTag.src=rutaImagen + nombreImagenCerrar;
			eCerrarTD.appendChild(imgTag);
		
			eCerrarTD.ventana = this;
			eCerrarTD.style.cursor="pointer";
			eCerrarTD.onmousedown = Ventana.prototype.cerrar;
		  eCerrarTD.width = "1%";
			eCerrarTD.style.paddingLeft = "1px";
			eCerrarTD.id = "eTDCerrar";
		}
	}
}
//-------------------------------------------------------------------------------------



/*------------------------setAncho--------------------------------------------
Función     : setAncho()
Descripción : Establece el ancho de la ventana.
Uso         : setAncho(ancho)
Argumentos  : *ancho*  - Recibe un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAncho = function (ancho){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (ancho)){
		//es un valor numerico.
			this.ancho = ancho;
			this.divScroll.style.width =   this.ancho - 21 + "px";
			this.divVentanaEmergente.style.width =  this.ancho + "px";
		}
	}
}
//-------------------------------------------------------------------------------------




/*------------------------setAlto--------------------------------------------
Función     : setAlto()
Descripción : Establece el alto de la ventana.
Uso         : setAlto(alto)
Argumentos  : *alto*  - Recibe un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAlto = function (alto){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (alto)){
		//es un valor numerico.
			this.alto = alto;
			this.divScroll.style.height =   this.alto - 21 + "px";
			this.divVentanaEmergente.style.height =  this.alto + "px";
		}
	}
}
//-------------------------------------------------------------------------------------


/*------------------------getAncho--------------------------------------------
Función     : getAncho()
Descripción : Retorna el ancho de la ventana.
Uso         : getAncho()
-------------------------------------------------------------------------------------*/
Ventana.prototype.getAncho = function (){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		return this.ancho;
	}
}
//-------------------------------------------------------------------------------------


/*------------------------getAlto--------------------------------------------
Función     : getAlto()
Descripción : Retorna el alto de la ventana.
Uso         : getAlto()
-------------------------------------------------------------------------------------*/
Ventana.prototype.getAlto = function (){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		return this.alto;
	}
}
//-------------------------------------------------------------------------------------


/*------------------------setAppendAlto--------------------------------------------
Función     : setAppendAlto()
Descripción : Añade al alto actual de la ventana el valor numérico recibido por parámetro.
Uso         : setAppendAlto(alto)
Argumentos  : *alto*  - Recibe un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAppendAlto = function (alto){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (alto)){
		//es un valor numerico.
			this.alto = this.alto + alto;
			this.divScroll.style.height =   this.alto - 21 + "px";
			this.divVentanaEmergente.style.height =  this.alto + "px";
		}
	}
}
//-------------------------------------------------------------------------------------


/*------------------------setAppendAncho--------------------------------------------
Función     : setAppendAncho()
Descripción : Añade al ancho actual de la ventana el valor numérico recibido por parámetro.
Uso         : setAppendAncho(ancho)
Argumentos  : *ancho*  - Recibe un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAppendAncho = function (ancho){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (ancho)){
		//es un valor numerico.
			this.ancho = this.ancho + ancho;
			this.divScroll.style.width =   this.ancho - 21 + "px";
			this.divVentanaEmergente.style.width =  this.ancho + "px";
		}
	}
}
//-------------------------------------------------------------------------------------


/*------------------------mostrarScrollBarHorizontal--------------------------------------------
Función     : mostrarScrollBarHorizontal()
Descripción : Establece si se mostrará el scroll horizontal o no.
Uso         : mostrarScrollBarHorizontal(mostrar)
Argumentos  : *mostrar*  - Recibe un booleano indicando si se verá el scroll horizontal o no.
-------------------------------------------------------------------------------------*/
Ventana.prototype.mostrarScrollBarHorizontal = function (mostrar){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (mostrar){
			this.divScroll.style.overflowX = "auto";
		} 
		else{
			this.divScroll.style.overflowX = "hidden";
		}
	}
}
//-------------------------------------------------------------------------------------



/*------------------------mostrarScrollBarVertical--------------------------------------------
Función     : mostrarScrollBarVertical()
Descripción : Establece si se mostrará el scroll vertical o no.
Uso         : mostrarScrollBarVertical(mostrar)
Argumentos  : *mostrar*  - Recibe un booleano indicando si se verá el scroll vertical o no.
-------------------------------------------------------------------------------------*/
Ventana.prototype.mostrarScrollBarVertical = function (mostrar){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (mostrar){
			this.divScroll.style.overflowY = "auto";
		} 
		else{
			this.divScroll.style.overflowY = "hidden";
		}
	}
}
//-------------------------------------------------------------------------------------





/*------------------------setActivarTraerAlFrente--------------------------------------------
Función     : setActivarTraerAlFrente()
Descripción : Activa o desactiva la funcionalidad de traer al frente la ventana seleccionada.
Uso         : setActivarTraerAlFrente(activar)
Argumentos  : *activar*  - Recibe un booleano que activa o desactiva esta funcionalidad.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setActivarTraerAlFrente = function (activar){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (activar!=null && activar!=undefined){
			this.activarTraerAlFrente = activar;
			if (this.activarTraerAlFrente){
				this.divVentanaEmergente.onmousedown = Ventana.prototype.traerAlFrente;
			}
			else{
				this.divVentanaEmergente.onmousedown = null;
			}
		}
	}
}
//-------------------------------------------------------------------------------------



/*------------------------setTop--------------------------------------------
Función     : setTop()
Descripción : Establece la posición 'y' de la ventana.
Uso         : setTop(top)
Argumentos  : *top*  - Es el 'id' de un objeto html del cual obtiene su posición top o puede ser un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setTop = function (top){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (top)){
		//es un valor numerico.
			this.top = top;
		}	 
		else{
			//es un objeto html.
			this.top = Ventana.prototype.findPosY(document.getElementById(top));
		}
		this.divVentanaEmergente.style.top = this.top + "px";
	}
}
//-------------------------------------------------------------------------------------


/*------------------------setLeft--------------------------------------------
Función     : setLeft()
Descripción : Establece la posición 'X' de la ventana.
Uso         : setLeft(left)
Argumentos  : *left*  - Es el 'id' de un objeto html del cual obtiene su posición left o puede ser un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setLeft = function (left){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (left)){
		//es un valor numerico.
			this.left = left;
		}	 
		else{
			//es un objeto html.
			this.left = Ventana.prototype.findPosX(document.getElementById(left));
		}
		this.divVentanaEmergente.style.left = this.left + "px";
	}
}
//-------------------------------------------------------------------------------------



/*------------------------getTop--------------------------------------------
Función     : getTop()
Descripción : Retorna el valor de la posición 'y' de la ventana.
Uso         : getTop()
-------------------------------------------------------------------------------------*/
Ventana.prototype.getTop = function (){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		return this.top;
	}
}
//-------------------------------------------------------------------------------------


/*------------------------getLeft--------------------------------------------
Función     : getLeft()
Descripción : Retorna el valor de la posición 'x' de la ventana.
Uso         : getLeft()
-------------------------------------------------------------------------------------*/
Ventana.prototype.getLeft = function (){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		return this.left;
	}
}
//-------------------------------------------------------------------------------------



/*------------------------setAppendTop--------------------------------------------
Función     : setAppendTop()
Descripción : Establece la posición 'y' de la ventana pero añadiendo el valor pasado por parámetro a la posición actual de 'y'.
Uso         : setAppendTop(top)
Argumentos  : *top*  - Es el 'id' de un objeto html o puede ser un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAppendTop = function (top){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (top)){
		//es un valor numerico.
			this.top = this.top + top;
		}	 
		else{
			//es un objeto html.
			this.top = this.top + Ventana.prototype.findPosY(document.getElementById(top));
		}
		this.divVentanaEmergente.style.top = this.top + "px";
	}
}
//-------------------------------------------------------------------------------------

/*------------------------setAppendLeft--------------------------------------------
Función     : setAppendLeft()
Descripción : Establece la posición 'x' de la ventana pero añadiendo el valor pasado por parámetro a la posición actual de 'x'.
Uso         : setAppendLeft(left)
Argumentos  : *left*  - Es el 'id' de un objeto html o puede ser un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAppendLeft = function (left){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (left)){
		//es un valor numerico.
			this.left = this.left + left;
		}	 
		else{
			//es un objeto html.
			this.left = this.left + Ventana.prototype.findPosX(document.getElementById(left));
		}
		this.divVentanaEmergente.style.left = this.left + "px";
	}
}
//-------------------------------------------------------------------------------------


/*------------------------setRemoveTop--------------------------------------------
Función     : setRemoveTop()
Descripción : Establece la posición 'y' de la ventana pero quitando el valor pasado por parámetro a la posición actual de 'y'.
Uso         : setRemoveTop(top)
Argumentos  : *top*  - Es el 'id' de un objeto html o puede ser un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setRemoveTop = function (top){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (top)){
		//es un valor numerico.
			this.top = this.top - top;
		}	 
		else{
			//es un objeto html.
			this.top = this.top - Ventana.prototype.findPosY(document.getElementById(top));
		}
		if (this.top<0){
			this.top=0;
		}
		this.divVentanaEmergente.style.top = this.top + "px";
	}
}
//-------------------------------------------------------------------------------------

/*------------------------setRemoveLeft--------------------------------------------
Función     : setRemoveLeft()
Descripción : Establece la posición 'x' de la ventana pero quitando el valor pasado por parámetro a la posición actual de 'x'.
Uso         : setRemoveLeft(left)
Argumentos  : *left*  - Es el 'id' de un objeto html o puede ser un valor numérico.
-------------------------------------------------------------------------------------*/
Ventana.prototype.setRemoveLeft = function (left){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (!isNaN (left)){
		//es un valor numerico.
			this.left = this.left - left;
		}	 
		else{
			//es un objeto html.
			this.left = this.left - Ventana.prototype.findPosX(document.getElementById(left));
		}
		if (this.left<0){
			this.left=0;
		}
		this.divVentanaEmergente.style.left = this.left + "px";
	}
}
//-------------------------------------------------------------------------------------



/*------------------------getObjectWindowPopup--------------------------------------------
Función     : getObjectWindowPopup()
Descripción : Devuelve el objeto que representa a la ventana emergente del objeto que se llama.
Ejemplo:
	Si tenemos un textarea en el div de la ventana emergente al que queremos acceder deberiamos hacer
	lo siguiente:
						
						var ventanaDiv = ventana.getObjectWindowPopup();
						textareaMio = ventanaDiv.getElementsByTagName("textarea")[0];
						('getElementsByTagName' nos retorna un array del tipo de etiqueta que le decimos, entonces de este
						array cogemos la etiqueta u objeto que nos interesa)
	

Uso         : getObjectWindowPopup()
-------------------------------------------------------------------------------------*/
Ventana.prototype.getObjectWindowPopup = function (){
	return thisVentanaDiv = document.getElementById(this.idVentana);
}
//-------------------------------------------------------------------------------------


/*------------------------getElementsByAttribute--------------------------------------------
Función     : getElementsByAttribute()
Descripción : Devuelve un array de objetos de el/los objeto/s que le hemos indicado por parámetro.

Parámetros:

					* strTagName (obligatorio) --> nombre del tag html que queremos buscar.
					* strAttributeName (obligatorio) --> nombre del atributo del tag que queremos buscar.
					* strAttributeValue (no es obligatorio)--> valor que tiene que tener el atributo.
	
Ejemplos de uso:
						
						var obj = ventana.getElementsByAttribute('input','type','checkbox');
						obj.length (hace referencia al array de objetos que son tag html 'input' y su atributo 'type'=checkbox).
						----------------------------------------------------------------------
						var obj = ventana.getElementsByAttribute('input','id','insertarMail');
						obj[0].value (hace referencia a el valor del input con id=insertarMail).
					

Uso         : getElementsByAttribute(strTagName, strAttributeName, strAttributeValue)

Retorna			: Devuelve un array de objetos, en donde puede haber 0,1 o N objetos.
-------------------------------------------------------------------------------------*/
Ventana.prototype.getElementsByAttribute = function (strTagName, strAttributeName, strAttributeValue){
	
	var oElm = this.getObjectWindowPopup();
	var arrElements = oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\s)" + strAttributeValue + "(\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}
//-------------------------------------------------------------------------------------


/*------------------------getElementsExternByAttribute--------------------------------------------
Función     : getElementsExternByAttribute()
Descripción : Devuelve un array de objetos de el/los objeto/s que le hemos indicado por parámetro.

Parámetros:

					* oElm (obligatorio) --> nodo padre desde el cual queremos buscar.
					* strTagName (obligatorio) --> nombre del tag html que queremos buscar, si ponemos '*' buscamos todos.
					* strAttributeName (obligatorio) --> nombre del atributo del tag que queremos buscar.
					* strAttributeValue (no es obligatorio)--> valor que tiene que tener el atributo.
	
Ejemplos de uso:
					
						var obj = ventana.getElementsExternByAttribute(document.body,'*','type','checkbox');
						obj.length;
						//Hace referencia al array de objetos que son tag html TODOS (*), busca en todos los tags HTML
						//que se encuentren en 'document.body' y que su atributo 'type'=checkbox.
						----------------------------------------------------------------------
						var obj = ventana.getElementsExternByAttribute(document.body,'input','id','insertarMail');
						obj[0].value; 
						//Hace referencia a el valor del input con id=insertarMail y que se encuentre dentro de 'document.body'.
						----------------------------------------------------------------------
						var obj = ventana.getElementsExternByAttribute(document.getElementById('divContenido'),'input','id','insertarMail');
						obj[0].value;
						//Hace referencia a el valor del input con id=insertarMail y que se encuetren dentro del 
						//objeto 'divContenido'.
							

Uso         : getElementsExternByAttribute(oElm,strTagName, strAttributeName, strAttributeValue)

Retorna			: Devuelve un array de objetos, en donde puede haber 0,1 o N objetos.
-------------------------------------------------------------------------------------*/
Ventana.prototype.getElementsExternByAttribute = function (oElm,strTagName, strAttributeName, strAttributeValue){
	
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\s)" + strAttributeValue + "(\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}
//-------------------------------------------------------------------------------------




/*------------------------setAlinearTituloDerecha--------------------------------------------
Función     : setAlinearTituloDerecha()
Descripción : Establece el título alineado hacia la derecha.
Uso         : setAlinearTituloDerecha()
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAlinearTituloDerecha = function (){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (this.mostrarTitulo){
			//ponemos espacios al titulo según alineación.
			this.alineacionTitulo='right';
			this.textoTitulo = this.textoTitulo + "&nbsp;";
			//no sigue el estandar de DOM (innerHTML).
			this.eTituloTD.innerHTML = this.textoTitulo;
			//alineacion del titulo.
			this.eTituloTD.align=this.alineacionTitulo;
		}
	}
}
//-------------------------------------------------------------------------------------



/*------------------------setAlinearTituloCentro--------------------------------------------
Función     : setAlinearTituloCentro()
Descripción : Establece el título alineado hacia el centro.
Uso         : setAlinearTituloCentro()
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAlinearTituloCentro = function (){
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (this.mostrarTitulo){
			//ponemos espacios al titulo según alineación.
			this.alineacionTitulo='center';
			//alineacion del titulo.
			this.eTituloTD.align=this.alineacionTitulo;
		}
	}
}
//-------------------------------------------------------------------------------------




/*------------------------setAlinearTituloIzquierda--------------------------------------------
 Función     : setAlinearTituloIzquierda()
 Descripción : Establece el título alineado hacia la izquierda.
 Uso         : setAlinearTituloIzquierda()
-------------------------------------------------------------------------------------*/
Ventana.prototype.setAlinearTituloIzquierda = function (){
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (this.mostrarTitulo){
			//ponemos espacios al titulo según alineación.
			this.alineacionTitulo='left';
			this.textoTitulo = "&nbsp;" + this.textoTitulo;
			//no sigue el estandar de DOM (innerHTML).
			this.eTituloTD.innerHTML = this.textoTitulo;
			//alineacion del titulo.
			this.eTituloTD.align=this.alineacionTitulo;
		}
	}
}
//-------------------------------------------------------------------------------------



/*------------------------setContenido--------------------------------------------
 Función     : setContenido()
 Descripción : Establece un nuevo contenido para la ventana, le pasamos el nombre del 'id' de un div.
 Uso         : setContenido(idDivContenido)
 Argumentos  : *idDivContenido*  - Es el 'id' de un objeto de tipo '[object HTMLDivElement]',(NO FUNCIONA EN IE)..
-------------------------------------------------------------------------------------*/
Ventana.prototype.setContenido = function (idDivContenido){
	
	if (this.divVentanaEmergente!=null && this.divVentanaEmergente!=undefined){
		if (idDivContenido!=null && idDivContenido!=undefined){
			var divAgregar = document.getElementById(idDivContenido);
			if (divAgregar!=null && divAgregar!=undefined){
				//if (divAgregar=='[object HTMLDivElement]'){
					this.eContenidoTD.innerHTML = document.getElementById(idDivContenido).innerHTML;
				//}
			}
		}
	}
}
//-------------------------------------------------------------------------------------



/*------------------------LTrim--------------------------------------------
 Función     : LTrim()
 Descripción : Quita los espacios en blanco del comienzo del string recibido.
 Uso         : LTrim(valor)
 Argumentos  : *valor*  - String con el valor a quitar espacios en blanco del principio.
-------------------------------------------------------------------------------------*/
Ventana.prototype.LTrim = function (valor){
	var re = /\s*((\S+\s*)*)/;
	return valor.replace(re, "$1");
}
//-------------------------------------------------------------------------------------


/*------------------------RTrim--------------------------------------------
 Función     : RTrim()
 Descripción : Quita los espacios en blanco del final del string recibido.
 Uso         : RTrim(valor)
 Argumentos  : *valor*  - String con el valor a quitar espacios en blanco del final.
-------------------------------------------------------------------------------------*/
Ventana.prototype.RTrim = function (valor){
	var re = /((\s*\S+)*)\s*/;
	return valor.replace(re, "$1");
}
//-------------------------------------------------------------------------------------



/*------------------------trim--------------------------------------------
 Función     : trim()
 Descripción : Quita los espacios en blanco del principio y final del string recibido.
 Uso         : trim(valor)
 Argumentos  : *valor*  - String con el valor a quitar espacios en blanco del principio y final.
-------------------------------------------------------------------------------------*/
Ventana.prototype.trim = function (valor){
	return Ventana.prototype.LTrim(Ventana.prototype.RTrim(valor));
}
//-------------------------------------------------------------------------------------




/* ---------------------------------------------------------------------- 
  Función     : crearVentana()
  Descripción : crea una nueva ventana, si ya existe devuelve boolean true.
  Uso         : crearVentana(left,top,ancho,alto,idDivContenido,idVentana,[textoTitulo],[colorVentana],[mostrarCerrar])
  Argumentos  : *left*(int/objeto html)   - Posición 'x' de la ventana, puede ser un valor numérico o un objeto html del cual obtenemos su left.
	              *top*(int/objeto html) 		- Posición 'y' de la ventana, puede ser un valor numérico o un objeto html del cual obtenemos su top.
								*ancho*(int)        			- Ancho que queremos que tenga la ventana, es un valor numérico.
								*alto*(int)        				- Alto que queremos que tenga la ventana, es un valor numérico.
	              *idDivContenido*(string)  - Es el 'id' del div que contiene el contenido html que queremos agregar a la ventana,
	              se recibe el nombre del tag 'id' del objeto div, si este objeto no es de tipo '[object HTMLDivElement]' no se agregará a la ventana popup.
                
                *idVentana*(int)    		  - Valor numérico que usaremos para identificar cada ventana que creamos, debe ser único y de valor numérico,el div principal
                de la ventana emergente tendrá un id que será '"ventanaEmergente"+idVentana'.
                
                *textoTitulo*(string)    	- Título de la ventana.
                *colorVentana(string)*    - Color de la ventana.
                *mostrarCerrar(boolean)*  - Mostrar o no el botón cerrar en la ventana.
 ---------------------------------------------------------------------- */



function crearVentana(left,top,ancho,alto,idDivContenido,idVentana,textoTitulo,colorVentana,mostrarCerrar)
{
	//si existe la ventana, ya esta creada la devolvemos
	if (document.getElementById(veNombreVentanaUnico+idVentana)) {
		//return document.getElementById(veNombreVentanaUnico+idVentana);
		//si ya existe retorna true.
		return true;
	}
	else{
	//sino creamos la ventana
		return new Ventana(left,top,ancho,alto,idDivContenido,idVentana,textoTitulo,colorVentana,mostrarCerrar);
	}  
}

