
	var cargada_1 = true;
	var cargada_2 = false;
	var cargada_3 = false;
	var cargada_4 = false;
	var cargada_5 = false;
	var cargada_6 = false;
	var cargada_7 = false;
	var cargada_8 = false;
	var cargada_9 = false;
	var cargada_10 = false;

var http = createRequestObject();
var httpPost = createRequestObject();

	function opacity(id, opacStart, opacEnd, millisec) { 
		//speed for each frame 
		var speed = Math.round(millisec / 100); 
		var timer = 0; 

		//determine the direction for the blending, if start and end are the same nothing happens 
		if(opacStart > opacEnd) { 
			for(i = opacStart; i >= opacEnd; i--) { 
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
				timer++; 
			} 
		} else if(opacStart < opacEnd) { 
			for(i = opacStart; i <= opacEnd; i++) 
				{ 
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
				timer++; 
			} 
		} 
	} 

	//change the opacity for different browsers 
	function changeOpac(opacity, id) { 
		var object = document.getElementById(id).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")"; 
	} 

	//set the opacity for different browsers 
	function setOpac(opacity, imagefile) { 
		var imageid = "foto_g";
		 		 
		//make new image 
		document.getElementById(imageid).src = "/fotos/wal/foto_" + imagefile + ".jpg"; 
		//make image transparent 
		changeOpac(0, imageid);
		var object = document.getElementById(imageid).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")";
		hex-=1; // increase color darkness
		document.getElementById("opcionesentrada1").style.color = "rgb("+hex+","+hex+","+hex+")";
//		document.getElementById("opcionesentrada2").style.color = "rgb("+hex+","+hex+","+hex+")";
//		document.getElementById("opcionesentrada3").style.color = "rgb("+hex+","+hex+","+hex+")";
	} 

	hex=50 // Initial color value.

	function fadetext() { 
	  if(document.getElementById("opcionesentrada").style.display == "none") document.getElementById("opcionesentrada").style.display = "block";
	  if(hex<255) { //If color is not black yet
		hex+=11; // increase color darkness
		document.getElementById("opcionesentrada1").style.color = "rgb("+hex+","+hex+","+hex+")";
//		document.getElementById("opcionesentrada2").style.color = "rgb("+hex+","+hex+","+hex+")";
//		document.getElementById("opcionesentrada3").style.color = "rgb("+hex+","+hex+","+hex+")";
		setTimeout("fadetext()",20); 
	  }
	  //else
		//hex=255 //reset hex value
	}


	function blendimage(imagefile) { 
		if(document.getElementById("textoaux").style.display == "block") {
			var formu = document.frm;
			var idHist = formu.id.value;
			var cad = fotos[idHist][imagefile-1];
			var arr = cad.split("#");
			var path_foto = arr[3];
			var arr2 = path_foto.split("/");
			var nombre_foto = arr2[arr2.length - 1];
			verFoto(nombre_foto);
			return;
		}
		var divid = "capafoto";
		var imageid = "foto_g";
		var millisec = 1200;
		//millisec = millisec + 2000;
		var speed = Math.round(millisec / 100); 
		var timer = 0; 
		//set the current image as background 
		
		//document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
		 
		//make image transparent 
		changeOpac(0, imageid); 
		 

		 var id = document.frm.id.value;
		 if(id == 0) {
			var listaIdsHist = document.frm.listaIdsHist.value;
			arr = listaIdsHist.split(",");
			id = arr[0];
		 }
		//make new image 
//alert(id + "---" + imagefile);
		eval("document.getElementById(imageid).src = pict_" + id + "_" + imagefile + ".src");
		//document.getElementById(imageid).src = "/fotos/wal/foto_" + imagefile + ".jpg"; 

		

		//fade in image 
		for(i = 0; i <= 100; i++) { 
			setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
			timer++; 
		} 
		
		if(document.getElementById(divid).style.display == "none") document.getElementById(divid).style.display = "block";
		//eval("document.getElementById('piefoto').innerHTML = pie_" + id + "_" + imagefile);
	} 

	function blendimage2(imagefile) {
		fadetext();
		blendimage(imagefile);
		//if(imagefile == document.frm.idfoto.value) return;
		listaIds = document.frm.listaIds.value;
		arr = listaIds.split(",");
		var carg;


		for(var i=0; i<arr.length;i++) {
			eval("carg = cargada_" + (i+1));
			if(!carg) {
				eval("cargada_" + (i+1) + " = true;");
				if(imagefile == document.frm.idfoto.value) i++;
				val = arr[i];
				arr2 = val.split("##");
				document.frm.id.value = arr2[0];
				window.setTimeout("nada("+arr2[2]+");", 4000);

				break;
			}
		}
	}

	function nada(i) {
		blendimage2(i);
		return;
	}
	
	function inicio() {
		
		var numFotos = document.frm.numFotos.value;
		var id = document.frm.id.value;
		var fotosrc;
		var fotograndesrc;
		var foto;
		var fotogrande;
		var aux;

		for(var i=1;i<numFotos;i++) {
			if(i == 1) {
				eval("fotograndesrc = pict_"+id+"_"+i+".src;");
				aux = fotograndesrc.substring(fotograndesrc.indexOf("foto_") + 5);
				indaux = aux.indexOf("jpg")-1;
				fotogrande = aux.substring(0, indaux);

				fotogrande = 1;
			}
			eval("fotosrc = pict_peq_"+id+"_"+i+".src;");
			aux = fotosrc.substring(fotosrc.indexOf("foto_peq_") + 9);
			indaux = aux.indexOf("jpg")-1;
			aux = aux.substring(0, indaux);
			foto = "<a href='javascript:blendimage("+i+");'><img src='"+fotosrc+"'></a>";
			//alert(foto);
			eval("document.getElementById('foto_pequena_"+i+"').innerHTML = \"" + foto + "\"");
		}
		blendimage(fotogrande);
		inicio2();
	}

	function inicio2() {
		if(document.getElementById("capafoto").style.display == "none") document.getElementById("capafoto").style.display = "block";
		//if(document.getElementById("enlacehistoria").style.display == "none") document.getElementById("enlacehistoria").style.display = "block";
	}

	function hist() {
		document.getElementById("historia").style.display = (document.getElementById("historia").style.display == "none")?"block":"none";
	}


	function createRequestObject() {
		var ro;
		var browser = navigator.appName;

		if(browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
			ro = new XMLHttpRequest();
		}
		return ro;
	}  

	function summary() {
		document.getElementById("enlacebio").style.color = "white";
		document.getElementById("enlacecontact").style.color = "white";
		document.getElementById("enlacesummary").style.color = "red";
		var formu = document.frm;
		var idHist = formu.id.value;
		http.open("get", "summary.php?id="+idHist+"&r=" + Math.random());
		http.onreadystatechange = actualizaSumario;
		http.send(null);
	}

	function verFoto(nombre_foto) {
		document.getElementById("enlacesummary").style.color = "white";
		document.getElementById("enlacebio").style.color = "white";
		document.getElementById("enlacecontact").style.color = "white";
		var formu = document.frm;
		var idHist = formu.id.value;
		http.open("get", "foto.php?id="+idHist+"&nombre_foto=" + nombre_foto + "&r=" + Math.random());
		http.onreadystatechange = actualizaFoto;
		http.send(null);
	}

	
	function bio() {
		document.getElementById("enlacesummary").style.color = "white";
		document.getElementById("enlacecontact").style.color = "white";

		document.getElementById("enlacebio").style.color = "red";
		var formu = document.frm;
		var idHist = formu.id.value;
		http.open("get", "bio.php?r=" + Math.random());
		http.onreadystatechange = actualizaSumario;
		http.send(null);
	}

	function contact() {
		document.getElementById("enlacesummary").style.color = "white";
		document.getElementById("enlacebio").style.color = "white";

		document.getElementById("enlacecontact").style.color = "red";
		var formu = document.frm;
		var idHist = formu.id.value;
		http.open("get", "contact.php?r=" + Math.random());
		http.onreadystatechange = actualizaSumario;
		http.send(null);
	}

	function actualizaSumario() {
		if(http.readyState == 4){
			window.document.getElementById("textoaux").style.display = "block";
			var response = http.responseText;
			window.document.getElementById("capafoto").innerHTML = response;
		}
	}

	function actualizaFoto() {
		if(http.readyState == 4){
			var response = http.responseText;
			
			window.document.getElementById("capafoto").innerHTML = response;
		}
	}

	function sendComment() {
		var frm = document.frmContacto;	
		frm.accion.value = "enviar";
		httpPost.open("post", "contact2.php?r=" + Math.random(), true);
		httpPost.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		httpPost.onreadystatechange = actualizaEnvio;
		httpPost.send(getParametros(frm));
	}

	function actualizaEnvio() {
		if(httpPost.readyState == 4){
			window.document.getElementById("textoaux").style.display = "block";
			var response = httpPost.responseText;
			window.document.getElementById("capafoto").innerHTML = response;
		}
	}

		function getParametros(formu) {
		var parametros = "";
		for(var i=0;i<formu.length;i++) {
			if(formu.elements[i].type == "button" || formu.elements[i].type == "reset" || formu.elements[i].type == "submit") continue;
			
			if(parametros != "") {
				if (formu.elements[i].type == "radio" || formu.elements[i].type == "checkbox") {
					if (formu.elements[i].checked) {
						parametros += "&" + formu.elements[i].name + "=" + formu.elements[i].value;	
					}
				}
				else {
					parametros += "&" + formu.elements[i].name + "=" + encodeURIComponent(formu.elements[i].value);
				}
			}
			else {
				if (formu.elements[i].type == "radio" || formu.elements[i].type == "checkbox") {
					if (formu.elements[i].checked) {
						parametros += formu.elements[i].name + "=" + formu.elements[i].value;	
					}
				}
				else {
					parametros += formu.elements[i].name + "=" + encodeURIComponent(formu.elements[i].value);
				}
			}
		}	
		return parametros;
	}


