
// BenW project thumbs handling
// theo.van.eijndhoven@chello.nl 2005

	function bigFotoClick(e)
	{
		var foto = currentFoto + 1;
		if ( foto >= fotos.length )
			foto = 0;
		switchFoto(foto);
	}
	
	var currentFoto = -1;
	function switchFoto(fotoNbr)
	{
		// because safari refuses to update the big image
		// we drop and re-create the img element from/in the dom-tree
		
		var foto = document.getElementById('project');
		var parentDiv = foto.parentNode;
		
		if ( foto ) parentDiv.removeChild(foto);
		
		foto = document.createElement("img");
		foto.src = fotos[fotoNbr];
		foto.id = "project";
		
		foto.onclick = bigFotoClick;
		if ( foto.captureEvents ) foto.captureEvents(Event.CLICK);
		
		parentDiv.appendChild(foto);
		
		if ( currentFoto > -1 )
			document.getElementById('thumb'+currentFoto).style.borderColor = "white";
			
		document.getElementById('thumb'+fotoNbr).style.borderColor = "#458898";
		currentFoto = fotoNbr;	
	}

	function writeThumbs(images)
	{
    var i;
    for ( i = 0; i < images.length; i++ )
    	document.write("<img id='thumb" + i + "' src='" + images[i] + "' onclick='switchFoto(" + i + ")' />");
	}
