function load_this(gallery) {
  var url = '/gallery/images.php?gallery=' + gallery;
	// notice the use of a proxy to circumvent the Same Origin Policy.
	
	$.getJSON(url, function(data) {
		
		
		$('#folders').html( data.folders );
		$('#images').html( '' );
		$('#images').html( data.images );
		$('#crumbs').html( data.crumbs );
		
		var imagesToShow = $('#images').children();
		var countImagesToShow = imagesToShow.size();
		var countImageShown = 0;
		var timer = 0;

		$('div#images a[rel=lightbox]').lightBox();
		$crumbs = $('#crumbs a');
		
		var interval = setInterval( function() {
		  
			if( countImageShown > countImagesToShow ) {
				clearInterval(interval);
			} else {
			  imagesToShow.eq( countImageShown ).fadeIn(1500);
				countImageShown++;
			}
		}, 150);
		
		if( $crumbs.size() > 1 ) {
		  $('div#crumbs').append('<a href="' + $crumbs.eq($crumbs.size() -2).attr('href') + '">Go back</a>');
		}
	});
}

$(function () {

  load_this('');
  
});