// JavaScript Document
var multiGaleria;
var multiAncla;
var multiEscenario;
var multiDescripcionItem;
var multiImagen;

function CrearGaleria(divGaleria){
multiGaleria=divGaleria;	
multiAncla = document.getElementById(multiGaleria).getElementsByTagName("a");
// Se comienza a construir la capa que contendra a la Galeria en Grande
//ContenedorGaleria
		var ContenedorGaleria = document.createElement('div');
		document.getElementsByTagName("body")[0].appendChild(ContenedorGaleria);
		ContenedorGaleria.id="CapaGaleria";
//ImagenGaleria	
		var AnclaImagen = document.createElement('a');
		var Imagen = document.createElement('img');
		ContenedorGaleria.appendChild(AnclaImagen);	
		AnclaImagen.id = "idAnclaImagen";
		AnclaImagen.appendChild(Imagen);
		Imagen.id="Imagen";
//DescripcionImagen		
		var AnclaDescripcion = document.createElement('a');
		var DescripcionImagen = document.createTextNode("Descripcion");
		ContenedorGaleria.appendChild(AnclaDescripcion);
		AnclaDescripcion.id = "idDescripcion";	
		AnclaDescripcion.href = "#";	
		AnclaDescripcion.appendChild(DescripcionImagen);			
		for (var x=0,i=multiAncla.length;x<i;x++){
		multiAncla[x].onclick = ActivaCapa;
		}
}	

//Se oculta la capa
function ocultarCapa() {
document.getElementById("CapaGaleria").style.height="0"; // IE5 Mac
document.getElementById("CapaGaleria").style.overflow="hidden"; // IE5 Mac
document.getElementById("CapaGaleria").style.display="none";
// Se remueve la opacidad de atras
document.getElementById("contenidotexto").className="none";
}

function ActivaCapa() {
multiEscenario = document.getElementById("CapaGaleria");
multiDescripcionItem = document.getElementById("idDescripcion");
multiImagen = document.getElementById("idAnclaImagen").getElementsByTagName("img")[0];
// Se opaca la parte de atras
	document.getElementById("contenidotexto").className="transparencia";
// IE5 Mac (ligas fantasmas)
// this.blur();
// esto para resetar un error en  IE Mac (ver declaracion en  (OcultarCapa())	
	multiEscenario.style.height="100%";
	multiEscenario.style.display="block";
	multiImagen.src = this.href.replace(this.hash,"");
	multiImagen.alt = this.getElementsByTagName("img")[0].alt;
	multiImagen.onclick = ocultarCapa;
// Se estiliza el cursos para IE5
	multiImagen.className = "manita";
	multiImagen.title = "Cerrar Foto";
// setting the height - mainly for IE - the second one is for IE5
	multiEscenario.style.height = (document.documentElement.clientHeight > 0) ? document.documentElement.clientHeight+"px" : document.body.clientHeight+"px";
// setting the width for IE 5 so there is no gap near the scrollbar
	if(document.documentElement.clientHeight == 0)multiEscenario.style.width=document.body.clientWidth+"px" ;
// setting the title and description
		multiDescripcionItem.firstChild.data = this.title;
// if there is a long description in there, we use it as href value of the short description and we give it a title to. If there is none we make sure we reset values previously set and we do not let the user follow the "empty" link
	if(this.getElementsByTagName("img")[0].longDesc){
		multiDescripcionItem.href = this.getElementsByTagName("img")[0].longDesc;	
// appendData() breaks IE5 Win
		multiDescripcionItem.firstChild.data=this.title+" [more info...]";
		multiDescripcionItem.title = "Follow this link for more Information";	
	}else{
		multiDescripcionItem.removeAttribute("href");	
		multiDescripcionItem.title = "";	
}
return false;	
}
