// Gallery

function gallery(){
var photo = $('photo');
var squarePhoto = $('square_photo');
var squareDescription = $('square_description');

var loadingImg = document.createElement('img');
squarePhoto.appendChild(loadingImg); 
loadingImg.src = 'loading.gif'
loadingImg.style.display = 'none';

var diapo = $('menu_diapo').getElementsByTagName("a");  
  for (i=0; i<diapo.length; i++) {
    diapo[i].onclick = function(){
      photo.style.display = 'none';
      loadingImg.style.display = 'inline';
      photo.src = this.href;
      photoTitle = this.getElementsByTagName('img')[0].alt;
      photoDescription = this.getElementsByTagName('span')[0].innerHTML;
      
      ImagesLoader=new Image();
        ImagesLoader.onload = function() {
          setTimeout(function() {
            loadingImg.style.display = 'none';
            photo.style.display = 'inline';
            squareDescription.innerHTML = "<b style='display:block'>"+photoTitle+"</b>"+photoDescription;
          },200);
        };
      ImagesLoader.src=this.href;
      return false;
    }
  }
}
