
function ModalWin(clases,imagenes,botones,resizable,movible,modal,bool_destroy)
{
	this.BLOCK          = navigator.appName=="Netscape"?"table":"block";
	this.clases         = clases;
	this.imagenes       = imagenes;
	this.botones        = botones;
	//this.
	this.bool           = false;
	this.resizable      = resizable;
	this.movible        = movible;
	

	this.contentObject  = null;
	this.modal          = true;
	this.pixel_dif      = 0;
	this.minimizedWidth = 75;
	this.izquierdaWidth = 150;
	this.cap_minimized  = null;
	this.vdleft         = 0;
	this.vdtop          = 0;
	this.cabeVsVentL    = 0;
	this.cabeVsVentT    = 0;
	this.contVsVentL    = 0;
	this.contVsVentT    = 0;
	this.salto          = 100;
	this.estado         = 0;
	this.timer          = null;
	// Group: Propiedades -> DOM References
  // ________________________________________________________________________
	/*
		var: cellTitle
		
		Contiene una referencia al objeto que contendrá el título de la ventana.
	*/
	this.cellTitle      = null;
	
	/*
		var: ventana
		
		Contiene una referencia al contenedor total del sistema.
	*/
	this.ventana        = null;
	/*
		var: contentObject
		
		Referencia al objeto en el que se ubicará el contenido de la ventana
	*/	
	/*
		var: botPleg
		
		Referencia al botón de plegado.
	*/
	this.botPleg        = null;
	/*
		var: botMini
		
		Referencia al botón de minimizado.
	*/	
	this.botMini        = null;
	/*
		var: botMaxi
		
		Referencia al botón de maximizado.
	*/	
	this.botMaxi        = null;
	/*
		var: botClos
		
		Referencia al botón de cerrar ventana.
	*/
	this.botClos        = null;
	/*
		var: botFond
		
		Referencia al botón de llevar al fondo.
	*/
	this.botFond        = null;
	this.mini           = null;
	this.reloador       = null;
	this.key_capture    = "";
	this.last_key       = "";
	// Group: Propiedades -> tipos simples 
	/*
		var: vdzoom
		
		Porcentaje de tamaño del original al disminuir la ventana (solo IE).
	*/
	this.vdzoom         = 50;
	/*
		var: vdopacity
		
		Porcentaje opacidad de las ventanas que no tienen el foco.
	*/
	this.vdopacity      = 100;
	this.moopacity      = 30;
//	this.deriba         = 18;
	this.oz             = this;
	this.msg_carga      = "Cargando... ";
	this.constructor();
};

// Group: Métodos

ModalWin.prototype.constructor=function()
{
	var spa,tabll,tbody,tr,td,spa2,img;
	var tabll1,tbody1,tr1,td1,spaP;
	var tabll2,tbody2,tr2,td2;
	if(this.modal)
	{
		this.modal=document.createElement("SPAN");
		this.modal.style.position="absolute";
		this.modal.style.left=0;
		this.modal.style.top=0;
		this.modal.style.zIndex=1000;
		this.modal.style.width=document.body.clientWidth;
		this.modal.style.height=document.body.clientHeight;
		this.modal.style.display="block";
		this.modal.style.backgroundColor="#000000";
		this.modal.style.filter="alpha(opacity="+this.moopacity+")";
		this.modal.style.opacity=this.moopacity/100;
		this.modal=document.body.appendChild(this.modal);	
	}

	tabll2=document.createElement("TABLE");
	tbody2=document.createElement("TBODY");
	tabll2.creada=true;
	tabll2.cellSpacing=0;
	tabll2.cellPadding=0;
	
	tr2=document.createElement("TR");
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	td2.appendChild(spa);
	tr2.appendChild(td2);
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	
	
	tabll1=document.createElement("TABLE");
	tabll1.cellSpacing=0;
	tabll1.cellPadding=0;
	tbody1=document.createElement("TBODY");
	tr1=document.createElement("TR");
	td1=document.createElement("TD");
	td1.style.width="5000";
	this.cellTitle=tr1.appendChild(td1);
	td1=document.createElement("TD");
	td1=tr1.appendChild(td1);
	img=this.imagenes[0].cloneNode(true);
	img.onclick=function(){this.oz.close();};
	img.oz=this;
	img.style.cursor="pointer";
	td1.appendChild(img);
	tbody1.appendChild(tr1);
	tabll1.appendChild(tbody1);
	spa.appendChild(tabll1);

	td2.appendChild(spa);
	tr2.appendChild(td2);
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	spa=td2.appendChild(spa);
	tr2.appendChild(td2);
	tbody2.appendChild(tr2);
	
	
	tr2=document.createElement("TR");
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	td2.appendChild(spa);
	tr2.appendChild(td2);		
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	this.contentObject=td2.appendChild(spa);
	tr2.appendChild(td2);	
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	td2.appendChild(spa);
	tr2.appendChild(td2);
	tbody2.appendChild(tr2);

	tr2=document.createElement("TR");
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	td2.appendChild(spa);
	tr2.appendChild(td2);
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	td2.appendChild(spa);
	tr2.appendChild(td2);
	td2=document.createElement("TD");
	spa=document.createElement("SPAN");
	td2.appendChild(spa);
	tr2.appendChild(td2);
	tbody2.appendChild(tr2);

	spa=document.createElement("SPAN");
	spa.style.position="absolute";
	spa.oz=this;
	spa.style.filter="alpha(opacity="+this.vdopacity+")";
	spa.style.opacity=this.vdopacity/100;
	spa.style.border=this.pixel_dif>0?this.pixel_dif+"px solid #7700ff":"";
	spa.style.display=this.BLOCK;
	spa.style.top=0;
	spa.style.left=0;
	spa.style.height=40;
	spa.style.width=40;
	
	tabll2.appendChild(tbody2);
	tabll2=spa.appendChild(tabll2);
	
	
	this.ventana=document.body.appendChild(spa);
	this.ventana.style.zIndex=this.modal.style.zIndex+1;
	this.ventana.className=this.clases[0];
	this.cellTitle.className=this.clases[1];


//Cuadrar elementos.

return;
	
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-	
//cerrar
	td1=document.createElement("TD");
	td1.className=this.clases[1];
	td1.style.cursor="hand";
	td1.oz=this;
	td1.onclick=this.close;
	img=new Image();
	img.src=this.imagenes[0].src;
	img.alt=this.imagenes[0].alt;
	img.height=this.imagenes[0].height;
	img.width=this.imagenes[0].width;
	spa2=document.createElement("SPAN");
	spa2.style.textAlign="center";
	spa2.style.width=12;
	spa2.style.paddingLeft=2;
	spa2.appendChild(img);
	td1.appendChild(spa2);
	td1.style.textAlign="right";
	tr1.appendChild(td1);
	this.botClos=tr1.appendChild(td1);
	if(!this.botones[0])this.botClos.style.display="none";
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-	

	spa2=document.createElement("SPAN");
	spa2.style.overflow="hidden";
	spa2.style.overflowX="auto";
	spa2.style.overflowY="auto";
	spa2.style.border=this.pixel_dif>0?this.pixel_dif+"px solid green":"";
	spa2.style.zIndex=1;
	this.contentObject=td.appendChild(spa2);
	tr.appendChild(td);
	tbody.appendChild(tr);
	tabll.appendChild(tbody);
	spa.appendChild(tabll);
	spa=td2.appendChild(spa);	
	tr2.appendChild(td2);	
	tbody2.appendChild(tr2);	
	tabll2.appendChild(tbody2);		
	spaP.appendChild(tabll2);	
	spaP.oz=this;
	this.ventana=document.body.appendChild(spaP);	
	this.ventana.INalpha=spaP.firstChild;	
	this.ventana.style.display="block";	
	if(this.resizable)
	{
		spa=document.createElement("SPAN");
		spa.style.position="absolute";
		spa.style.cursor="se-resize";
		spa.style.zIndex=9000;
		spa.resize=true;
		spa.oz=this;
		spa.style.filter="alpha(opacity=100)";
		spa.onmousedown=this.mouseDownR;
		img=new Image();
		img.src=this.imagenes[7].src;
		img.alt=this.imagenes[7].alt;
		img.height=this.imagenes[7].height;
		img.width=this.imagenes[7].width;
		spa.appendChild(img);
		this.ventana.angulo=this.ventana.firstChild.rows[0].cells[0].appendChild(spa);	
	}
	spa=document.createElement("SPAN");
	spa.style.position="absolute";
	spa.oz=this;
	spa.style.backgroundColor="#0000ff";
	spa.style.filter="alpha(opacity=0)";
	spa.style.border=this.pixel_dif>0?this.pixel_dif+"px solid #770000":"";
	spa.onmousedown=this.clickCubierta;	
	spa.style.display="block";
	this.ventana.cubierta=this.contentObject.parentNode.appendChild(spa);
	
	spa=document.createElement("SPAN");
	spa.style.position="absolute";
	spa.oz=this;
	spa.style.backgroundColor="transparent";
	spa.style.filter="alpha(opacity=40)";
	spa.style.border=this.pixel_dif>0?this.pixel_dif+"px solid #7700ff":"";
	spa.style.display="block";
	spa.style.top=0;
	spa.style.left=0;
	spa.style.height=document.body.offsetHeight;
	spa.style.width=document.body.offsetWidth;
	this.ventana.traspanel=document.body.appendChild(spa);

};


/* 
    Function: close
    
    Cierra una ventana.
    
    Uso:
    		
    		foo.close();

    Vea también:

				<ModalWin.makeCloseAll>, <ModalWin.minToClose>    		    		
*/
ModalWin.prototype.close=function()
{
	if(this.bool)
		this.showHide();
	else
		this.destroy();	
};


/* 
    Function: moveTo
    
    
    Mover la ventana a un punto determinado.
    
    Uso:
    		
    		foo.moveTo(left,top);
    
    Parametros:
    	
    		left - Distancia absoluta izquierda.
    		top  - Distancia absoluta arriba.
    		
    Vea también:

				<ModalWin.center>    		
*/
ModalWin.prototype.moveTo=function(dIzq,dTop)
{
	this.ventana.style.left=dIzq;
	this.ventana.style.top=dTop;
};

ModalWin.prototype.showHide=function(visi)
{
	this.ventana.style.display=(visi == "none") ? visi : this.BLOCK;
	try{this.modal.style.display=(visi == "none") ? visi : this.BLOCK;}catch(o){};
};


/* 
    Function: setTitle
    
    Establecer el título de la ventana
    
    Uso:
    		
    		foo.setTitle(title);    
    		
    Parámetros:
    		
    		title - Cadena de texto que puede contener código HTML.
    		
    Vea también:

				<ModalWin.setContent>    		
*/
ModalWin.prototype.setTitle=function(title)
{
	this.cellTitle.innerHTML=title;
	this.cellTitle.title=this.cellTitle.innerText;
	return;
};
/* 
    Function: setContent
    
    Establece el contenido de la ventana.
    
    Uso:
    		
    		foo.setContent(contenido);    
    		
    Parámetros:
    		
    		contenido - Lleva el contenido, pudiendo ser éste una cadena, número o un objeto del documento.
    		
    Retorna:
    
    		Lo mismo que recibe - Si la operación tuvo éxito.
    		-1                  - Si no se pudo realizar la operación.
    		
    Vea también:

				<ModalWin.setTitle>    		
*/
ModalWin.prototype.setContent=function(contenido)
{
	if(typeof(contenido)=="string" || typeof(contenido)=="number")
		this.contentObject.innerHTML=contenido;
	else 
		if (typeof(contenido)=="object")
		{
			try{contenido=this.contentObject.appendChild(contenido);}
			catch(e){contenido=-1;}
		}
	return contenido;
};
/* 
    Function: setSizeContent
    
    Ajusta el tamaño del contenido de la ventana al tamaño de la ventana.
    
    Uso:
    		
    		foo.setSizeContent();    
    
    Vea también:

		<ModalWin.setSize>
*/
ModalWin.prototype.setSizeContent=function()
{
	try{
	this.contentObject.firstChild.style.height=this.contentObject.clientHeight;
	this.contentObject.firstChild.style.width= this.contentObject.clientWidth;}
	catch(e){};
	return;
};

/* 
    Function: setSize
    
    Establece las dimensiones de la ventana.
    
    Uso:
    		
    		foo.setSize(ancho,alto,bool);    
    	
    Parámetros:
    
        ancho - Ancho para la ventana
        alto  - Alto para la ventana
        bool  - Opcional. Si lleva valor no se redimensionará el contenido.
        
    Vea también:

	<ModalWin.setSizeContent>
*/
ModalWin.prototype.setSize=function(ancho,alto)
{	
	if(alto>0)
		this.contentObject.style.height=alto;
	if(ancho>0)
		this.contentObject.style.width=ancho;


//	this.cellTitle.style.float="left";
//	this.xxxxx.style.float="right";
		
};

ModalWin.prototype.destroy=function()
{
	this.ventana.parentNode.removeChild(this.ventana);
	try{this.modal.parentNode.removeChild(this.modal);}catch(o){};
};

ModalWin.prototype.hallarLeftAbsoluto=function (elem,tag)
{
	var k=0;
	var ift;
	if(!tag)
		tag="BODY";
	if(typeof(tag)=="object")
		ift="elem!=tag";
	else
		ift="elem.tagName!=tag.toUpperCase()";
	while (eval(ift) && elem.tagName!="HTML")
	{
		k=k+elem.offsetLeft;
		elem=elem.offsetParent;
	}
	return k;
};
ModalWin.prototype.hallarTopAbsoluto=function (elem,tag)
{
	var k=0;
	var ift;
	if(!tag)
		tag="BODY";
	if(typeof(tag)=="object")
		ift="elem!=tag";
	else
		ift="elem.tagName!=tag.toUpperCase()";
	while (eval(ift) && elem.tagName!="HTML")
	{
		k=k+elem.offsetTop;
		elem=elem.offsetParent;
	}
	return k;
};
ModalWin.prototype.setContentOverflow=function (x,y)
{
	this.contentObject.style.overflowX=x;
	this.contentObject.style.overflowY=y;
};

/* 
    Function: center
    
    Centra la ventana según las dimensiones del explorador..
    
    Uso:
    		
    		foo.center();    
    		
    Vea también:

				<ModalWin.moveTo>
*/
ModalWin.prototype.center=function ()
{
	this.moveTo(
		document.body.clientWidth/2-this.ventana.offsetWidth/2,
		document.body.clientHeight/2-this.ventana.offsetHeight/2
		);
};

/* 
    Function: getCellContent
    
    Recupera el primer hijo (span) de cada celda del cuadro de la ventana, de forma que se puedan cambiar sus propiedades
    de estilo, o añadir contenido.
    
    Uso:
    		
    		foo.getCellContent(indCelda);    

    Parametros:
    	
    		indCelda - Numero de celda teniendo en cuenta la siguiente numeración
       
>             ___ ___________ __
>            |   |           |   |
>            | 0 |     1     | 2 |
>            |___|___________|___|        
>            |   |           |   |
>            | 3 |     4     | 5 |
>            |   |           |   |
>            |___|___________|___|        
>            |   |           |   |
>            | 6 |     7     | 8 |
>            |___|___________|___|
>
    		
    Vea también:

		<ModalWin.moveTo>
*/
ModalWin.prototype.getCellContent=function (ind)
{
	return this.ventana.firstChild.rows[Math.floor(ind/3)].cells[ind%3].firstChild;
};
/* 
    Function: getContainer
    
    Retorna el contenedor de la ventana.
    
    Uso:
    		
    		foo.getContainer();    

    Vea también:

		<ModalWin.moveTo>
*/
ModalWin.prototype.getContainer=function ()
{
	return this.ventana;
};



function open_prop(elem)
{
	var i,cad="",vvv;
	for(i in elem)
		cad=cad + i + " = " + elem[i] + "<br>";	
	vvv=window.open();
	vvv.document.write(cad);
};




