function GetPhoto( photoId ) {
  	$.getJSON(
		'/~gateway/flickr.cfc',
		//'http://localhost/kawasaki/httpdocs/~gateway/flickr.cfc',
	    { method : 'getPhoto', returnformat : 'json', photo : photoId },
		/*
	    When the JSON data has returned, fire this
	    callback function and pass in the JSON data
	    as it's argument.
		*/
		ShowPhoto
	);
}

function ShowPhoto( stPhoto ) {
	//Load image in the background
	var img = new Image();
	
	$(img)
		.load( function() {
			//Hide the image
			$(this).hide();
			
			//Remove Spinner
			$('#loader').fadeOut('fast');
			$('#flickr500').fadeOut('fast', function() {
				$(this).attr('src', stPhoto.IMAGE );
				$(this).attr('title', stPhoto.TITLE );
				$(this).fadeIn('fast');
			});

			//Update text areas
			$( '#media-info h2').text( stPhoto.TITLE );
			$( '#media-info p').text( stPhoto.DESCRIPTION );
			$( '#media-comments').html( stPhoto.COMMENTS );
			$( '#media-download').html( stPhoto.DOWNLOAD );

		})
		.error( function() {
			//Report error?
		})
		.attr('src', stPhoto.IMAGE );
}

$(document).ready(function(){
	$('#mycarousel').jcarousel({
        // Configuration goes here
    });
	
	$('#mycarousel img').click( function() {
		//Start loader
		$('#loader').fadeIn('fast');

		//Get new image
		GetPhoto( $(this).attr('id') );
		return false;
	});
});