	function celdaPulsada (celda){


		var ultimaCeldaPulsada =document.getElementById('celdaSeleccionada').value; 
		if (document.getElementById('celdaSeleccionada').value )
		{
		document.getElementById(ultimaCeldaPulsada).className="restauroCeldaPulsada";
		}

		document.getElementById(celda).className="celdaPulsada";
		document.getElementById('celdaSeleccionada').value= celda;

	}


function ningunaCeldaPulsada () {
	var celda = document.getElementById('celdaSeleccionada').value;
	document.getElementById(celda).className = className="restauroCeldaPulsada";


}




function damePiePagina () {
return '			<a href="http://www.enlamochila.com"  style="color: #7f7f7f;" target="_parent">www.enlamochila.com</a></div>';
}



function dameBotonera (botonpulsado,arrayBotones) {




var filasTabla = eval(arrayBotones.length / 4); // Calculo las filas <tr> que necesitaré para la tabla

var devuelvo =' 			<center><table id="nuevaTablaBotones" border="0" align="center"  width="95%">';
//		devuelvo += '	<TR>';
	var cuentoFoto = 0;
		var cuentoFila =0;
for (t=0;t<filasTabla ;t++ )
{
		devuelvo += '	<TR>';


				for (i=cuentoFoto;i<cuentoFoto + 4; i++ )
				{
				if (!arrayBotones [i]) {devuelvo +='<td width="25%" style="background-color: white">&nbsp;</td>'; // No hay foto para esta celda
				}
				 
				 else { 
				 			devuelvo += '<TD width="25%"><div id='+arrayBotones[i][0]+' onClick="celdaPulsada(this.id)"><a href="'+arrayBotones[i][2]+'" >'+arrayBotones[i][1]+'</a></div></TD>';
				 }


		}

cuentoFoto = cuentoFoto + 4;
cuentoFila ++

		devuelvo += '			</TR>';	


}



devuelvo += '			</table></center>';



var capa = document.getElementById('enlaceBotonesTabla');
  capa.innerHTML =devuelvo;

celdaPulsada(botonpulsado)

}




///////////////////////////////////////////////////
function cociente () {
return 1%2
}
function dameTablaFotosLightbox (arrayfotos,tituloTabla,n)  {
// Si recibo n controlo que si es 3 serán imágenes a 200 x 150 px hago tabla de tres filas.

if (!n){n=4} //si no recibo el parAmetro, n serA 4.


	/*
		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 = eval(arrayfotos.length / n); // Calculo las filas <tr> que necesitaré para la tabla
	
	
	var tabla='';

	if (tituloTabla != "")
	{ // TABLA CON TITULO
		tabla +='<table width="100%" align="center"><tr><td colspan="'+n+'"><table class="titulo_hoja" border ="0" width ="100%" >'+
				'<tr><td class="titulo_hoja">'+tituloTabla +'</td><td class="titulo_hoja" >www.enlamochila.com</td></tr>'+
				'</table></td></tr>'+
				'</table><br>'+		  // final del encabezado de la tabla
				'<table width ="100%"><tr><td>' + filasTabla + '</td></tr>';
	}
tabla += 				'<table width ="100%" id="tablaFotosDinamica">';
//tabla += 				'<table width ="100%"><tr><td>parseInt(eval(arrayfotos.length / 4))' + filasTabla + '\n arrayfotos.length' + arrayfotos.length  + '\n '+arrayfotos.length%4+'</td></tr>';


	for (t=0;t<filasTabla ;t++ )
	{
			tabla += '<tr>';
				for (i=cuentoFoto;i<cuentoFoto + n; 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]+'" style = "text-decoration:none">';
					tabla += '<IMG SRC="'+arrayfotos [i][2]+'/'+arrayfotos [i][4]+arrayfotos [i][0]+'"    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]+'" style = "text-decoration:none">';

					tabla += '<IMG SRC="'+arrayfotos [i][4]+arrayfotos [i][0]+'"    border="0" ></A></span></div></td>';
					}				



			}
	} //final del for
	
			cuentoFoto = cuentoFoto + n;
			cuentoFila ++



			tabla += '</tr>';
			tabla += '<tr ><td colspan="'+n+'">	<hr></td></tr>'; // Meto una linea horizonal en la tabla				


	
	 }
tabla += '</table>';
return  tabla;

}







function abroPopUp (url,porcent){
	//Se pueden enviar el % del tamaño de la venta como parAmetro, si no se indica, lo abra al 90 %
	if (!porcent) {porcent= 0.90};
	window.open(url,'_blank'," width ="+parseInt(screen.width * porcent )+"px,height="+parseInt(screen.height * porcent)+"px,  location=no,resizable=yes,scrollbars=yes,top=0px,left=0px")
}

function pintoIframe (url,capa,altura) {
	var devuelvo = "<iframe src='"+url+"' width=718 height="+altura+" frameborder='0' scrolling='auto' ";
	 devuelvo +="style='position: absolute;left: 0px;'></iframe>"
	document.getElementById(capa).innerHTML = devuelvo ;
}
