var vLoadIMG;
var myLoadIMGTimer = null;

document.observe("dom:loaded", configAlbum );

function configAlbum()  {
	vFotos = $("fotos").select("a");
	vFotos.each( function (vLink) {
		vHref = vLink.readAttribute( "href" );
		vTexto = vLink.down().readAttribute("alt");
		vLink.writeAttribute( {href:"#"} );
		vLink.observe( 'click' , ChangeIMG.bindAsEventListener( vLink , vHref , vTexto ) ); 
	})
}

function ChangeIMG( vCaller , vURL , vTxt )
{
	if( myLoadIMGTimer )
		{myLoadIMGTimer.stop()}
	$("loading").style.display = "block";
	vLoadIMG = new Image()
	vLoadIMG.src = vURL;
	$("descricao").innerHTML = vTxt;
	myLoadIMGTimer = new PeriodicalExecuter( function (pe) {
		if( vLoadIMG.complete )
		{
			$("IMGPrincipal").src = vLoadIMG.src;
			$("loading").style.display = "none";
			pe.stop();
		}
	} , 0.5 )
 

}