// JavaScript Document
function ver_Imagen_Grande(imagen) {
	if ((imagen == null) || (!imagen.src)) imagen=this;
	if (window.ventana) ventana.close();
	id = imagen.src.replace(/.*peques\//, "");
	id = "foto"+id.replace(/\..*/, "");
	for (i = 0; i < imagenes_Grandes.length; i++) {
		if (imagenes_Grandes[i].id == id) {
			imagen_Grande = imagenes_Grandes[i];
		}
	}
	if (!imagen_Grande) return;
	documento = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	documento += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
	documento += '<head>\n';
	documento += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\n';
	documento += '<title>Fotograf&iacute;a de Valencia</title>\n';
	documento += '<link href="/estilos/foto.css" rel="stylesheet" type="text/css" />\n';
	documento += '</head>\n';
	documento += '<body>\n';
	w = imagen_Grande.width;
	h = imagen_Grande.height;
	if (w>0 && h>0) {
		documento += '<img src="'+imagen_Grande.src+'" width="'+ w +'" height="'+ h +'"/>\n';
	} else {
		documento += '<img src="'+imagen_Grande.src+'" />\n';
	}
	documento += '</body>\n</html>\n';
	ventana = window.open('','ventana','width='+w+',height='+h);
	ventana.document.open();
	ventana.document.write(documento);
	ventana.document.close();
}

function busca_Imagenes_Pequenyas() {
	j = 0;
	window.imagenes_Grandes = new Array();
	buscado = /peques\//
	imagenes_Pequenyas = document.getElementsByTagName("img");
	for (i=0; i < imagenes_Pequenyas.length; i++) {
		if( imagenes_Pequenyas[i].src.match(buscado) ) {
			imagenes_Grandes[j] = new Image;
			imagenes_Grandes[j].src = imagenes_Pequenyas[i].src.replace(buscado, "");
			id = imagenes_Pequenyas[i].src.replace(/.*peques\//, "");
			id = "foto"+id.replace(/\..*/, "");
			imagenes_Grandes[j].name = id;
			imagenes_Grandes[j].id = id;
			j++;
			imagenes_Pequenyas[i].onmousedown = ver_Imagen_Grande;
		}
	}
	mas = document.getElementsByTagName("div");
	for (i=0; i < mas.length; i++) {
		if( mas[i].className == "ampliar" ) {
			imagen = mas[i].nextSibling;
			while ((imagen != null) && (imagen.nodeName != "IMG")) imagen = imagen.nextSibling;
			if (imagen != null) {
				mas[i].imagen = imagen;
				mas[i].onclick = mostrar_imagen;
			}
		}
	}
}

function mostrar_imagen() {
	ver_Imagen_Grande(this.imagen)
}
