//-- M. Valmaseda 2008
//-- Este fichero recoge los comentarios correspondientes a las fotos B&W de
//-- la página web www.valmam.com.es. 


/* Esta variable es el número útil de fotos en el álbum */

     var numTHUMBS = 44;


/* Este array contiene los valores de los comentarios */

imgArray = [
' Santoña: A pole in the middle of the estuary',
' Santoña: Fisher at work',
' Santander, Colegiata of Castañeda',
' Suances\'s lighthouse',
' the end of the way',
' dry sailing',
' little brother',
' Easter procession in Malaga 2009',
' flowerpots in Cuacos',
' going back to home at the end of the work',
' old facade',
' golden ragwort (Senecio aurues)',
' Comment',
' sunflowers (Helianthus annuus)',
' sunflowers (Helianthus annuus)',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' good morning!',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Venice\'s street',
' Venice\'s Gran Canal',
' Venice; Santa Maria della Salute',
' Comment',
' selfportrait',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment',
' Comment'
]
;

/*   ------------------- The functions --------------------   */

 onerror=handleErr;

 function handleErr(msg,url,l) {
 	//-- Handle the error here and return true or false
	}

 function updatePhoto(url,index,isSuper) {

	if  ( isSuper == true ) {
                	var MainPHOTO = "<IMG ID=\"MainPhoto\" STYLE=\"border:12px solid white;\" OnClick=\"NextOne();\">" ;
		document.getElementById('IMGRECIPIENT').innerHTML = MainPHOTO;
		}
 	document.getElementById('MainPhoto').src=url;
        var iLen = String(url).length;
	var t = String(url).substring( iLen, iLen - 7 );
	t = String(t).substring(0, 3);
	t = t/1;		
   	document.getElementById('Ctitulo').innerHTML = imgArray[t-1];	
	}


 function ADJUSTHBWPHOTO() { 

      	var H = 750; //--document.getElementById('MainPhoto').height;//--good idea, but fixed hieght is better for tthe page!	
      	document.getElementById('MAINBOX').style.height= H ;
      	var THUMBstring = "<TABLE WIDTH=\"150\ HEIGHT=\"1000\" >";
	var FileName = "";
	for ( n= 1; n <= numTHUMBS; n++ ) {	
		if ( n  < 10 )              FileName = "B&WPhoto00" + n + ".jpg";
		if ( n  >= 10 && n < 100 )  FileName = "B&WPhoto0" + n + ".jpg";
		if ( n  >= 100 )            FileName = "B&WPhoto" + n + ".jpg";  
		THUMBstring = THUMBstring + "<TR><TD ALIGN=\"CENTER\"><A ONCLICK=\"updatePhoto('" + FileName
			+ "', 0, false); return false;\"><IMG SRC=\"" + FileName + "\" HSPACE=\"10\" VSPACE=\"2\""
			+ "\" WIDTH=\"100\"  ALT='" + imgArray[n-1] + "' STYLE=\"border:1px solid white;cursor:hand;\"></A></TD></TR>";		
		}	
	THUMBstring = THUMBstring + "</TABLE>";
	document.getElementById('MAINBOX').innerHTML = THUMBstring;
	}
 

function NextOne()  {
	
	var currentPhoto = document.getElementById('MainPhoto').src;
	var nt = 7; //-- padding plus extension
	var n = 3;
	var strnewt;
	var iLen = String(currentPhoto).length;
	var t = String(currentPhoto).substring( iLen, iLen - nt );
//alert ("1)   " + t);
	t = String(t).substring(0, n);
//alert ("2)   " + t); 
	t = t/1;
	var newt = t+1;
	if ( newt > numTHUMBS ) newt = 1;
	if ( newt > 0 && newt < 10 )	strnewt = "00" + newt;
	if ( newt > 9 && newt < 100 )	strnewt = "0" + newt;
	if ( newt > 99 ) strnewt = newt;
	var newPhoto = String(currentPhoto).substring( 0, iLen - nt ) + strnewt + ".jpg";
//alert (newPhoto);
	updatePhoto(newPhoto,0,false);

	}

//----------------------------------------------------------------------------------------------------------------------------

/*  end of file   */
