$(window).bind('load', function() { $('div#flickr').hide().load_photos('69847762%40N00', 6); });

jQuery.fn.load_photos = function(user_id, count) {
	var $photos = $(this);
	$('div#loading_photos').show();
	$.ajax({
		url: '/intraspirit/latest_photos.php',
		data: 'user='+user_id+'&count='+count, 
		type: 'GET',
		dataType: 'json',
		timeout: 10000,
		cache: false,
		complete: function() {
			$('div#loading_photos').hide();
			$photos.show();
		},
		error: function() {
			$photos.append('<p><strong>Error:</strong> Couldn\'t get the latest photos.</p>');
		},
		success: function(data) {
			$.each(data.photos, function(i, photo) {
				$photos.append('<a href="'+data.user.photosurl+photo.id+'"><img class="flickr-photo" src="'+photo.url+'" alt="'+photo.title+'" title="'+photo.title+'" /></a>');
			});
		}
	});
}
