//////////////////////7 GENERO TABLA DE FOTOS DE FORMA DINAMICA ///////////
/*
	***************   FUNCIONAMIENTO DE LA JS.  ************+

	En arrayfotos recibos las siguientes posiciones

	arrayfotos [0]= new Array ("essaouira10.JPG","Puerto de Essaouira","carpeta_miniaturas","carpeta_fotos","TN_");
	arrayfotos [1]= new Array ("essaouira11.JPG","Parrilladas en Essaouira","","",""); //foto sin miniatura

	[0] -> Nombre del fichero JPG
	[1] -> Texto de la imagen
	[2] -> Path del TN_FOTO
	[3] -> Path de la FOTO
	[4] -> PREFIJO MINIATURA (Nombre Miniatura = [4]+[0])

			Se llama así desde el html:

			<script src="../../css/compongofotos.js"></script> 
			<script>
			var pathjs = "../../";
			var arrayfotos = new Array ();
			arrayfotos [0]= new Array ("essaouira10.JPG","Puerto de Essaouira","","","TN_");
			arrayfotos [1]= new Array ("MARRAKECH8.JPG","Marrakech","","","TN_");
			arrayfotos [2]= new Array ("MARRAKECH9.JPG","Marrakech","","","");
			</script>
			<body>
				<script>this.document.write(dameTablaFotos (arrayfotos,"Marrakech Essaouira 2005"));</script>
			</body>

*/

function dameTablaFotos (arrayfotos,tituloTabla) {


var cuentoFoto = 0; // es la posición del arrayfoto que está tratando
var cuentoFila =0;
var filasTabla = parseInt(eval(arrayfotos.length / 4))+1; // Calculo las filas <tr> que necesitaré para la tabla

var tabla='';

 if (tituloTabla != "")
 { // TABLA CON TITULO
	tabla +='<table width="100%"><tr><td colspan="4"><table class="titulo_hoja" border ="0" width ="100%">'+
			'<tr><td class="titulo_hoja">'+tituloTabla +'</td><td class="titulo_hoja" align="right">www.enlamochila.com</td></tr>'+
			'</table></td></tr>'+
			'</table><br>'+		  // final del encabezado de la tabla
			'<table width ="100%">'
}

for (t=0;t<filasTabla ;t++ )
{


 tabla += '<tr>';
			for (i=cuentoFoto;i<cuentoFoto + 4; i++ )
			{



			if (!arrayfotos [i])
			{
				tabla +='<td width="25%">&nbsp;</td>'; // No hay foto para esta celda
			}


		  else{
				// Dibujo Celda con foto
				if (arrayfotos [i][3] !="" && arrayfotos [i][2] != "") // Mandamos el path de las imágenes desde el array
				{	
					tabla += '<td width="25%"><div align="center"><span style="cursor:hand"><A id="'+arrayfotos [i][3]+'/'+arrayfotos [i][0]+'" texto="'+arrayfotos [i][1]+'" onClick="veofoto(this.id,this.texto)"><IMG SRC="'+arrayfotos [i][2]+'/'+arrayfotos [i][4]+arrayfotos [i][0]+'"   height = "90px" alt="'+arrayfotos [i][1]+'"><BR>'+arrayfotos [i][1]+'</A></span></div></td>';
				}
				if ( arrayfotos [i][3] =="" && arrayfotos [i][2] == "") // Imágenes con paths "","" ->la imagen está en el directorio de la página
				{
					tabla += '<td width="25%"><div align="center"><span style="cursor:hand"><A id="'+arrayfotos [i][0]+'" texto="'+arrayfotos [i][1]+'" onClick="veofoto(this.id,this.texto)"><IMG SRC="'+arrayfotos [i][4]+arrayfotos [i][0]+'"   height= "90px" alt="'+arrayfotos [i][1]+'"><BR>'+arrayfotos [i][1]+'</A></span></div></td>';
				}				


			  }

			} //final del for

		cuentoFoto = cuentoFoto + 4;
		cuentoFila ++

tabla += '</tr>';
tabla += '<tr ><td colspan="4" height="3" bgcolor="#A6C0DB"></td></td></tr>'; // Meto una linea horizonal en la tabla


 }



return (tabla);


}


function dameTablaFotosLightbox (arrayfotos,tituloTabla)  {

	/*
		He de devolver por cada foto una linea como esta:
		<a href="fotosstorini/santorini01.jpg" rel="lightbox"><img src="fotosstorini/TN_santorini01.jpg" width="100"  alt="" /></a>

		Se le llama asI: this.document.write(dameTablaFotosLightbox (arrayfotos,""));
		VER: santorini.htm
	*/


	var cuentoFoto = 0; // es la posición del arrayfoto que está tratando
	var cuentoFila =0;
	var filasTabla = parseInt(eval(arrayfotos.length / 4)); // Calculo las filas <tr> que necesitaré para la tabla
	
	var tabla='';

	if (tituloTabla != "")
	{ // TABLA CON TITULO
		tabla +='<table width="100%"><tr><td colspan="4"><table class="titulo_hoja" border ="0" width ="100%">'+
				'<tr><td class="titulo_hoja">'+tituloTabla +'</td><td class="titulo_hoja" align="right">www.enlamochila.com</td></tr>'+
				'</table></td></tr>'+
				'</table><br>'+		  // final del encabezado de la tabla
				'<table width ="100%">'
	}

	for (t=0;t<filasTabla ;t++ )
	{
			tabla += '<tr>';
				for (i=cuentoFoto;i<cuentoFoto + 4; i++ )
				{
				if (!arrayfotos [i])
				{
					tabla +='<td width="25%">&nbsp;</td>'; // No hay foto para esta celda
				}
				else{
				// Dibujo Celda con foto
					if (arrayfotos [i][3] !="" && arrayfotos [i][2] != "") // Mandamos el path de las imágenes desde el array
					{	
					tabla += '<td width="25%" align="center" ><A href="'+arrayfotos [i][3]+'/'+arrayfotos [i][0]+'" rel="lightbox['+arrayfotos [i][1]+']" title="'+arrayfotos [i][1]+'">';
					tabla += '<IMG SRC="'+arrayfotos [i][2]+'/'+arrayfotos [i][4]+arrayfotos [i][0]+'"   height = "90px"  border="0" ></A></td>';
					}

					
					if ( arrayfotos [i][3] =="" && arrayfotos [i][2] == "") // Imágenes con paths "","" ->la imagen está en el directorio de la página
					{
					tabla += '<td width="25%" align="center" ><div align="center"><span style="cursor:hand"><A id="'+arrayfotos [i][0]+'" rel="lightbox['+arrayfotos [i][1]+']" title="'+arrayfotos [i][1]+'">';
					tabla += '<IMG SRC="'+arrayfotos [i][4]+arrayfotos [i][0]+'"   height= "90px" border="0" ></A></span></div></td>';
					}				



			}
	} //final del for
	
			cuentoFoto = cuentoFoto + 4;
			cuentoFila ++



			tabla += '</tr>';
			tabla += '<tr ><td colspan="4">	<hr class="separadorAzul"></td></tr>'; // Meto una linea horizonal en la tabla				


	
	 }



return (tabla);
}




////////////////////////////// ABRO VENTANA PARA MOSTRAR FOTO //////////
function veofoto (foto,texto) {

			if (texto==undefined){	/*Con Mozilla texto llega undefined, genero titulo, depende URL foto.*/
				texto="Fotos de www.enlamochila.com"
				if (foto.indexOf('TAI') >0){texto='Tailandia 2004'}
				else{texto="Fotos de www.enlamochila.com"}
			} 


	ventana= window.open("",'_blank'," width =750px,height=650px,  location=no,resizable=no")
	ventana.document.write(

	'<link href="http://www.enlamochila.com/css/colores.css" rel="stylesheet" type="text/css">'+
	
	'<table width="100%" border="0" bordercolor="#006666" class="titulo_hoja">'+
		' <tr> '+
			'<td width="70%" class="titulo_hoja" >'+texto+'</td>'+
			'<td width="30%" class="titulo_hoja" ><div align="right"><font color="#CCCCCC" size="4" >www.enlamochila.com</font></div></td>'+
		'  </tr>'+
	'</table><br>'+
	
	'<table width="100%" border="0" bgcolor="#E7E7F2">'+
		'<tr>'+
			'<td align="center"><IMG SRC="'+foto+'" height="480" ALT="'+foto+'"></td>'+
		'</tr>'+
	'</table>'+
	'<div onClick="window.close()" align="center"><strong><span style="cursor:hand">Pincha aqu&iacute; para cerrar esta ventana[X]</span></strong></div>')

}
