//Programado por  Ricardo Mora para la CUAED- UNAM -------------------------------

//ricardo@sustanciadigital.com----------------------------------------------------
//morari2008@hotmail.com----------------------------------------------------------
//-----------------------------------------------------------
//++++Si buscas resultados distintos, no hagas siempre lo mismo. Albert Einstein++++


//++++Si buscas resultados distintos, no hagas siempre lo mismo. Albert Einstein++++

//Programacion para  el LigthBox
//Programacion para  el LigthBox
//Programacion para  el LigthBox

//Instrucciones 
//Instrucciones 
//Instrucciones 
//Instrucciones 
//Instrucciones:  para  aplicar  este script son necesarios los siguientes aspectos:






//1. para  llamar al ligthbox  es necesario el siguiente llamado ejemplo:  <a  onClick="pag('u01_p50.html', 'FUENTES DE CONSULTA',500,900)"> texto con link</a>

//2. S� el link esta dentro de un iframe al mismo nivel de la p�gina es necesario agregar "parent." ejemplo  <a  onClick="parent.pag('u01_p50.html', 'FUENTES DE CONSULTA')"> texto con link</a>

//3. 'u01_p50.html'  esto corresponde a  la p�gina que quieres que se muestre  en el ligthbox

//4. 'FUENTES DE CONSULTA' esto corresponde al t�tulo dentro del ligthbox 

//5. '500' esto corresponde a la altura del marco  del  contenido

//6. '900' esto corresponde al ancho  del marco  del  contenido





var Altoinicial=450;// corresponde al alto del span contenedor Y NO ALA CAJA ENTERA 
var AnchoF= 900; // corresponde al anho del span contenedor 
var ColorF= "#fff";  // corresponde al color de fondo del span
//span contiene en su interior dos  tablas una para el titulo  y la otra  para  el iframe
var colorTit="#000";  // color del titulo de la caja
var imagenCerraF="img/x.jpg";  // corresponde  a la imagen  boton de cierre




//No editar 
//No editar 
//No editar 
//No editar 
//No editar 

//Nombre de ID usados: CapaFondo, oCapa1,  titulo, tabla_flotante, flotante


var AltoF= Altoinicial+40; 
document.write ("<span id='CapaFondo'  onClick=restaurar2('oCapa1');  style='position:fixed; display:inline; WIDTH:100%; HEIGHT:0px; top:0px; left:0px;  background-color: #000000;  padding: 0px 0px 0px 0px;  z-index:110; -khtml-opacity: 0.50; -moz-opacity: 0.50; filter: alpha(opacity=50); opacity: .50;  '></span><span  id='AumentarDisminuirLB' style='position:fixed; top:-100px; right:0px; width:210px; height:24px; border:#FFF 0px solid; background-image: url(img/controlesventanaLB.png); background-repeat:no-repeat; background-position:bottom right;  z-index:110; '><span style='position:absolute; top:4px; left:5px; color:#999; font-size:12px;'>Controles de la ventana</span><span style='position:absolute; top:2px; right:70px; width:20px; height:20px; border:#CCC 0px solid;  z-index:99; '><a onClick='AumentarAncho();'><img src='img/anchoLB.png' width='20' height='20' border='0' title='Aumenta el ancho'/></a></span><span  style='position:absolute; top:2px; right:47px; width:20px; height:20px;  border:#CCC 0px solid;  z-index:200; '><a onClick='AumentarAlto();'><img src='img/altoLB.png' width='20' height='20' border='0' title='Aumenta el alto'/></a></span><span style='position:absolute; top:2px; right:24px; width:20px; height:20px;   border:#CCC 0px solid;  z-index:200; '><a onClick='AumentarAncho(); AumentarAlto();'><img src='img/ampliarLB.png' width='20' height='20' border='0' title='Aumenta el alto y ancho'/></a></span><span style='position:absolute; top:2px; right:2px; width:20px; height:20px;   border:#CCC 0px solid;  z-index:200; '><a onClick='restaurarTamanoLB();'><img src='img/restablecerLB.png' width='20' height='20' border='0' title='Tama�o original'/></a></span></span>");


document.write ("<span id='oCapa1' style='position:fixed; width:"+AnchoF+"px; height:"+AltoF+"px; top:-570px; left:-816px;  background-color:"+ColorF+"; border-style:solid; border-color:#000000; border-width:1px; padding: 0px 0px 0px 0px; overflow:visible; z-index:151; -khtml-opacity: 0.0; -moz-opacity: 0.0; filter: alpha(opacity=0); opacity: .0; '> <table width='100%' height='20' border='0' cellspacing='0' cellpadding='0' style='border-bottom:solid; border-color:#000000; border-width:0px;'><tr><td width='90%' id='titulo' name='titulo' style='color:"+colorTit+"; font-size:12px; font-family:Verdana, Geneva, sans-serif; font-weight:bolder;'>&nbsp; &nbsp;  </td><td align='right'><div style='position:absolute; top:1px; right:35px; width:15px; height:15px; cursor:pointer;'><a onClick='redirigirLB()'><img src='img/ventana.png' width='22' height='18' border='0' title='ver en otra ventana'/></a></div><div align='center' style=' position:absolute; top:1px; right:10px; width:15px; height:15px; vertical-align:middle; background-color:#000;  border:solid; border-color: #CCC; border-width:0px;'> <a  onClick=restaurar2('oCapa1'); style='color:#FFF; font-size:14px; text-decoration:none; cursor:pointer;'><img src='"+imagenCerraF+"' width='22' height='18' border='0' title='cerrar'/></a></div></td></tr></table><table id='tabla_flotante' width='100%' bgcolor='#ffffff' height='500' border='0' cellspacing='0' cellpadding='0'><tr><td valign='top' style='border-top:solid; border-color:#000000; border-width:1px; font-weight:bolder;'><iframe name='flotante' id='flotante' src='img/cargando.jpg' width='100%' height='100%'   frameborder='0' scrolling='yes'></iframe></td> </tr></table></span>");



//var cuerpoRef = document.getElementsByTagName("body")[0];
//var altobody= document.cuerpoRef.style.height;
//alert("hola");
//alert(cuerpoRef);
//No editar 
//No editar 
//No editar 
//No editar 
//No editar 

//window.onresize=restaurar6('oCapa1');
//programacion pendiente
//programacion pendiente
	var  ligaslightbox =new Array();
	var  ligaslightbox2 =new Array();
	var  ligaslightbox3 =new Array();
	var  nuevapagina="";

function listado(){
		 ligaslightbox=document.getElementsByTagName("a");
	//alert(ligaslightbox.length);
	
	//ESTO  SI FUnCIONA
		for (u=1; u<=ligaslightbox.length; u++){
		
		aa=document.getElementsByTagName("a")[u].getAttribute('lbAction') ;
		
		
		if (aa == "yes"){
			ligaslightbox2.push(u);
				alert(ligaslightbox2);
				//urlX=document.getElementsByTagName("a")[u].getAttribute('lbUrl') ;
				//ligaslightbox3.push(urlX);
				//alert(ligaslightbox3);
				//alert(ligaslightbox2.length);
				//alert(bb[0]);
				bbx=document.getElementsByTagName("a")[u].getAttribute('onclick') ;
		
		XX=String(bbx);
		
		var posicion = XX.indexOf('pag(')+4;
		pos=XX.substring(posicion)
		//alert(posicion + pos);
		//contartexto=pos.length;
		contartexto2= pos.indexOf(')');
		pos3=pos.substring(0, contartexto2)
		ligaslightbox3.push(pos3)
		//alert(pos3);
		nuevapagina=pos3;
			}
		
		
		
		
		}
	
		
	/*	for (u=1; u<=ligaslightbox.length; u++){
		
		aa=document.getElementsByTagName("a")[u].getAttribute('onclick') ;
		
		XX=String(aa);
		
		var posicion = XX.indexOf('pag(')+4;
		pos=XX.substring(posicion)
		//alert(posicion + pos);
		//contartexto=pos.length;
		contartexto2= pos.indexOf(')');
		pos3=pos.substring(0, contartexto2)
		//alert(pos3);
		nuevapagina=pos3;
			
		
		}*/
		
		
}



	
	
	
	

function cambiarLB(e){
	//alert(ligaslightbox2);
	//alert(ligaslightbox3);
	//alert(nuevapagina);
	ordenarInfo=nuevapagina.split(",");
	parametro1=ordenarInfo[0].substring(1)
	//alert(parametro1);
	parametro1A=parametro1.length-1;
	parametro1B=parametro1.substring(0, parametro1A )
	alert(parametro1B);
	
	pag(parametro1B);
	
	
	}
// Fin programacion pendiente


function arrayX (){
	//alert("S");
	
	for (u=1; u<=ligaslightbox3.length; u++){
		if(continuarX == ligaslightbox3[u]){
			alert(ligaslightbox3[u]);
			}
		}
	
	
	}



var continuarX="";
var paginaActulaLB="";
var tituloActualLB="";
var altoActualLB=AltoF;
var anchoActualLB=AnchoF;
//El boton en el flash o html llama a las funciones  en el siguiente orden "pag(); Restaurar(); valor();"
function pag(pagina, titu, alto, ancho){
	
//continuarX=pagina;
//arrayX ();


	// cambia  l el interior del iframe
	parent.flotante.location=pagina;
	//programaci�n para escribir de manera din�mica el titulo de la ventana 
	if (titu == null){
		document.getElementById('titulo').innerHTML="";
		}
		else {
			document.getElementById('titulo').innerHTML= titu;
			}
			
	// si  el llamado a la  funcion tiene ALTO lo aplica
		if (alto == null){
			document.getElementById('oCapa1').style.height= AltoF+25+"px"; // la caja
			document.getElementById('tabla_flotante').style.height=AltoF+"px";//tabla envolvente de iframe
			document.getElementById('flotante').style.height= AltoF+"px";//iframe de contenido
		}
		else {
						
			document.getElementById('oCapa1').style.height= alto+25+"px";
			document.getElementById('tabla_flotante').style.height= alto+"px";
			document.getElementById('flotante').style.height= alto+"px";
			
			altoActualLB=alto;
			}
			
		// si  el link  que llamo  la funcion tiene ANCHO  lo aplica	
			if (ancho == null){
			document.getElementById('oCapa1').style.width= AnchoF+"px";
			document.getElementById('tabla_flotante').style.width= AnchoF+"px";
			document.getElementById('flotante').style.width= AnchoF+"px";
		}
		else {
						
			document.getElementById('oCapa1').style.width= ancho+"px";
			document.getElementById('tabla_flotante').style.width= ancho+"px";
			document.getElementById('flotante').style.width= ancho+"px";
			
			anchoActualLB=ancho;
			}
			
			
			
	Restaurar('oCapa1');
	valor('oCapa1');
	
	paginaActulaLB=pagina;
	tituloActualLB=titu;
	
	

	
	}


	
var alto= 0;
var capa ="";
var activado="false";

//esta funcion recibe el nombre de la capa que se movera
function valor(dato){ 
capa= dato;

anima();
}

//esta  funcion activa  la funcion anima2
function anima(){ 
alturabody=screen.height+200;
//alturabody=document.body.scrollHeight;//????????????
alturabody2=document.body.scrollWidth;//???????????


//elemento5=document.getElementById('contenedor_principal'); ?????????????????????????????????
elemento4=document.getElementById('CapaFondo');

//coloca la capa  5px de altura
elemento3=document.getElementById('oCapa1');
elemento3.style.top=25+"px";
document.getElementById('AumentarDisminuirLB').style.top=0+"px";
//coloca la capa al centro horizontal
media=alturabody2-elemento3.offsetWidth; //??????????????????????

media2= Math.round(media/2);

elemento3.style.left=media2+"px";

//genera la capa negra traslucida


if (document.all){elemento4.style.height=alturabody+"px";}// ????????????????????????????
else if (document.getElementById){elemento4.style.height= window.innerHeight+"px";} //?????????????


activado="true";

//tiempo=setInterval ("anima2()",100);
document.getElementById('oCapa1').style.opacity=1;
document.getElementById('oCapa1').style.MozOpacity=1;
if (navigator.appName.indexOf("Explorer") != -1){
document.getElementById('oCapa1').filters.alpha.opacity=100;
}

}

// desplaza la capa y desactiva la animacion
var decimal= 0.0;
var decimal2= 0;

function anima2(){ 

decimal= decimal+0.10;
decimal2= decimal2+ 10; 
//alert(decimal, decimal2);
document.getElementById('oCapa1').style.opacity=decimal;
document.getElementById('oCapa1').style.MozOpacity=decimal;
if (navigator.appName.indexOf("Explorer") != -1){
document.getElementById('oCapa1').filters.alpha.opacity=decimal2;
}

alto +=10;

if (alto >= 100 ){
clearInterval (tiempo);
alto =0;
decimal= 0.0;
decimal2= 0;

}
}



//restablece las capas fuera de la  ventana 
function Restaurar(capa){ 
elemento1=document.getElementById(capa);
elemento1.style.top=-570+"px";
elemento1.style.left=100+"px";
elemento1.style.visibility="visible";
}




//este script es similar al de arriba pero  oculta la capa
//*******************************************************************************
//*******************************************************************************
//*******************************************************************************
//*******************************************************************************
var alto2= 0;
var capa2 ="";

function restaurar2(dato){ 
capa2= dato;
restaurar3();
}

function restaurar3(){ 
//arriba=setInterval ("restaurar4()",10);
elemento4=document.getElementById(capa2);
elemento4.style.top=-1500+"px";
document.getElementById('AumentarDisminuirLB').style.top=-100+"px";

document.getElementById(capa).style.opacity=0.0;
document.getElementById(capa).style.MozOpacity=0.0;
	if (navigator.appName.indexOf("Explorer") != -1){
	/* para IE6&7 */ 
	document.getElementById(capa).filters.alpha.opacity=0;
	}

elemento4=document.getElementById('CapaFondo');
elemento4.style.height=1+"px";

activado="false";


// al eliminar  visualmente el frame  le carga  una imagen, cuya finalidad es la  de  evitar 
//que se quede cargado  el html anterior, ya que si se tarda un poco se puede ver en lo que sustituye
parent.flotante.location="img/cargando.jpg";
}

//*******************************************************************************
//*******************************************************************************
//*******************************************************************************
//*******************************************************************************


// este script se llama  cuando   se redimenciona  el navegador "<body  onresize=restaurar6('oCapa1');  >"
function restaurar6(){ 
//alert("h");
alturabody=screen.height+200;
//alturabody=document.body.scrollHeight;//????????????
alturabody2=document.body.scrollWidth;//???????????


if (activado== "true"){

elemento4=document.getElementById('CapaFondo');

//coloca la capa  5px de altura
elemento3=document.getElementById('oCapa1');
elemento3.style.top=25+"px";

//coloca la capa al centro horizontal
media=alturabody2-elemento3.offsetWidth; //??????????????????????????????''

media2= Math.round(media/2);

elemento3.style.left=media2+"px";

//genera la capa negra traslucida
if (document.all){elemento4.style.height=alturabody+"px";}
else if (document.getElementById){elemento4.style.height= window.innerHeight+"px";}


}

}


//Botones   superior  derecha  para  redimenzionar  la caja del lightbox

//boton redirigir que se muestra  en el marco de la  ventana,  abre la misma  p�gina  pero en otra  ventana
function redirigirLB(){
	//alert(paginaActulaLB);
	anchomonitor=screen.width;
	altomonitor=screen.height;
	window.open(paginaActulaLB, 'ventana',"width=1024,height=600, scrollbars=YES, resizes=yes") 
	}




function AumentarAncho(){ 
//alert("h");
alturabody=screen.height+200;
//alturabody=document.body.scrollHeight;//????????????
alturabody2=document.body.scrollWidth;//???????????

ele1=document.getElementById('oCapa1');
ele2=document.getElementById('tabla_flotante');
ele3= document.getElementById('flotante');


if(ele2.offsetWidth <= alturabody2-90 ){
//if(ele2.offsetWidth <= 1100 ){
document.getElementById('oCapa1').style.width= ele1.offsetWidth+60+"px";
document.getElementById('tabla_flotante').style.width= ele2.offsetWidth+60+"px";
document.getElementById('flotante').style.width= ele3.offsetWidth+60+"px";
}

if (activado== "true"){

	elemento4=document.getElementById('CapaFondo');

	//coloca la capa  5px de altura
	elemento3=document.getElementById('oCapa1');
	elemento3.style.top=25+"px";



	//coloca la capa al centro horizontal
	media=alturabody2-elemento3.offsetWidth; //??????????????????????????????''

	media2= Math.round(media/2);

	elemento3.style.left=media2+"px";

	//genera la capa negra traslucida
	if (document.all){elemento4.style.height=alturabody+"px";}
	else if (document.getElementById){elemento4.style.height= window.innerHeight+"px";}

}

}



function AumentarAlto(valor){ 
//alert("h");
alturabody=screen.height+200;
//alturabody=document.body.scrollHeight;//????????????
alturabody2=document.body.scrollWidth;//???????????

ele1=document.getElementById('oCapa1');
ele2=document.getElementById('tabla_flotante');
ele3= document.getElementById('flotante');

pass=Number(document.documentElement.clientHeight);
if(ele2.offsetHeight+100 < pass ){
//alert(ele2.offsetHeight +"/"+pass);
document.getElementById('oCapa1').style.height= ele1.offsetHeight+60+"px";
document.getElementById('tabla_flotante').style.height= ele2.offsetHeight+60+"px";
document.getElementById('flotante').style.height= ele3.offsetHeight+60+"px";
}

if (activado== "true"){

	elemento4=document.getElementById('CapaFondo');

	//coloca la capa  5px de altura
	elemento3=document.getElementById('oCapa1');
	elemento3.style.top=25+"px";



	//coloca la capa al centro horizontal
	media=alturabody2-elemento3.offsetWidth; //??????????????????????????????''

	media2= Math.round(media/2);

	elemento3.style.left=media2+"px";

	//genera la capa negra traslucida
	if (document.all){elemento4.style.height=alturabody+"px";}
	else if (document.getElementById){elemento4.style.height= window.innerHeight+"px";}

}

}



function restaurarTamanoLB(){ 

			document.getElementById('oCapa1').style.height= altoActualLB+25+"px";
			document.getElementById('tabla_flotante').style.height= altoActualLB+"px";
			document.getElementById('flotante').style.height= altoActualLB+"px";
			
			document.getElementById('oCapa1').style.width= anchoActualLB+"px";
			document.getElementById('tabla_flotante').style.width= anchoActualLB+"px";
			document.getElementById('flotante').style.width= anchoActualLB+"px";


if (activado== "true"){

	elemento4=document.getElementById('CapaFondo');

	//coloca la capa  5px de altura
	elemento3=document.getElementById('oCapa1');
	elemento3.style.top=25+"px";



	//coloca la capa al centro horizontal
	media=alturabody2-elemento3.offsetWidth; //??????????????????????????????''

	media2= Math.round(media/2);

	elemento3.style.left=media2+"px";

	//genera la capa negra traslucida
	if (document.all){elemento4.style.height=alturabody+"px";}
	else if (document.getElementById){elemento4.style.height= window.innerHeight+"px";}

}

}



	



//Programado por  Ricardo Mora para la CUAED- UNAM -------------------------------

//ricardo@sustanciadigital.com  ----------------------------------------------------
//morari2008@hotmail.com----------------------------------------------------------
//-----------------------------------------------------------
//++++Si buscas resultados distintos, no hagas siempre lo mismo. Albert Einstein++++


//++++Si buscas resultados distintos, no hagas siempre lo mismo. Albert Einstein++++
