var arrayFotos = new Array();
var arrayTextos = new Array();
var filtro;

var nCapaActual;

var foto_1;
var texto_1;

var arriba = 0;
var abajo = 137;

var xArribaIni = 137;
var xArriba = 137;
var xAbajoIni = 0;
var xAbajo = 0;

//Altura es el ZIndex
function cargar(idCapaFoto, idCapaTexto, altura) {
	var numero = arrayFotos.length;
	document.getElementById(idCapaFoto).zIndex=altura;
	document.getElementById(idCapaFoto).style.zIndex=altura;
	arrayFotos[numero] = new lObj(idCapaFoto);
	arrayTextos[numero] = new lObj(idCapaTexto);
	arrayFotos[numero].show(true);
	arrayTextos[numero].show(false);
}

function inicializar(nCapa) {
	this.filtro = new lObj('filtro');
	this.filtro.show(true);
	if (this.arrayTextos.length>0) {
		if (nCapa==0) {
			this.arrayTextos[0].show(true);
			this.nCapaActual = 0;
		}
		else {
			for (i=0;i<nCapa;i++) {
				inicializarAbajo(i);
			}
			this.arrayTextos[nCapa].show(true);
			this.nCapaActual = nCapa;
		}
	}
	this.filtro.show(false);
}

function atras() {
	if (this.nCapaActual>0) {
		subir();
	}
}

function adelante() {
	if (this.nCapaActual<(this.arrayTextos.length-1)) {
		bajar();
	}
}

function subir(){
	this.filtro.show(true);
	if (this.xArriba>this.arriba){
		this.xArriba += -4;
		this.arrayFotos[nCapaActual-1].moveTo(0, this.xArriba, false);
		setTimeout("subir()", 30);
	}
	else {
		this.arrayTextos[this.nCapaActual].show(false);
		this.arrayTextos[this.nCapaActual-1].show(true);
		this.nCapaActual--;
		this.xArriba = this.xArribaIni;
		this.filtro.show(false);
	}
}

function bajar(){
	this.filtro.show(true);
	if (this.xAbajo<this.abajo){
		this.xAbajo += 4;
		this.arrayFotos[nCapaActual].moveTo(0, this.xAbajo, false);
		setTimeout("bajar()", 30);
	}
	else {
		this.arrayTextos[this.nCapaActual].show(false);
		this.arrayTextos[this.nCapaActual+1].show(true);
		this.nCapaActual++;
		this.xAbajo = xAbajoIni;
		this.filtro.show(false);
	}
}

function inicializarAbajo(nCapa){
	this.arrayFotos[nCapa].moveTo(0, this.abajo, false);
}

function popimage(imagesrc,winwidth,winheight)
{
	var mLeft = (screen.width - winwidth) / 2;
	var mTop = (screen.height - winheight) / 2;
	var look='scrollbars=1,width='+winwidth+',height='+winheight+',top='+mTop+',left='+mLeft
	popwin=window.open("","Visor",look)
	popwin.document.open()
	popwin.document.write('<HTML><HEAD><title>Visor de Imagenes</title></HEAD><body><p align="center"><img src="'+imagesrc+'" HEIGHT=304>')
	popwin.document.write("<FORM><p align='center'><INPUT TYPE='button' VALUE='Cerrar' " +
	"onClick='window.close()'></p></FORM></body></HTML>");
	popwin.document.close()
}
