function enhanceAlbum() {
  $(".thumbnail a").each( function () {
    $(this)
    .click( function() {
      var curFoto = $(this);
      $.dimScreen(256, 0.5, function() {
        openBox(curFoto,null,null,true);
      });
      return false;
    });
  });

  $(".thumbnail .foto a").each( function () {
    $(this)
    .mouseover( function(e) {
      $(this).parents(".thumbnail").find(".info:has(.beschrijving)").css( { 'left' : e.pageX-85+'px' , 'top' : e.pageY+18+'px' }).show();
    })
    .mousemove( function(e) {
      $(this).parents(".thumbnail").find(".info:has(.beschrijving)").css( { 'left' : e.pageX-85+'px' , 'top' : e.pageY+18+'px' });
    })
    .mouseout( function(e) {
      $(this).parents(".thumbnail").find(".info:has(.beschrijving)").hide();
    });
  });
}

function fotoLightbox() {
  $(".download_full_img").each( function() {
    var imgFileName = $(this).find("a").attr("href").split("file=/")[1];
    var fullImgPath = $(".dialog_foto img").attr("src").split("/web/")[0];
    $(this).append('<img src="'+fullImgPath+'/thumbs/'+imgFileName+'" class="mini_thumb" />');
  });
}

var autoPlayTimer = null;

function activateAutoPlay(startNow) {
  $(".button_play").one("click", autoPlayStart );
  $(".button_stop").one("click", autoPlayStop );

  if (startNow) {
    autoPlayTimer = window.setTimeout("autoPlayNext()",4000);
  }
}

function autoPlayStart() {
  $("a.button_next, a.button_previous").each ( function() {
    $(this).attr("href",$(this).attr("href").indexOf("autoplay=false")==-1?$(this).attr("href")+"&autoplay=true":$(this).attr("href").replace("autoplay=false","autoplay=true"));
  }).click( function() { clearTimeout(autoPlayTimer); } );
  autoPlayTimer = window.setTimeout("autoPlayNext()",100);
  return false;
}

function autoPlayNext() {
  clearTimeout(autoPlayTimer);
  $("a.button_next").click();
}

function autoPlayStop() {
  $("a.button_next, a.button_previous").each ( function() {
    $(this).attr("href",$(this).attr("href").replace("autoplay=true","autoplay=false"));
  });
  clearTimeout(autoPlayTimer);
  $(this).removeClass("button_stop").addClass("button_play").one("click", autoPlayStart ).text("Start slideshow");
  return false;
}