//module for talldan
(function(talldan, $, undefined){
	var flickr = {};
}(window.talldan = window.talldan || {}, jQuery));


// module for flickr
(function(flickr, $, undefined){
	// private member vars
	var appendTarget = '';
	
	// public - commence the jquery ajax get call using JSONP
	flickr.loadImages = function(target){
		appendTarget = target
		$.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?id=43519866@N00&lang=en-us&format=json&jsoncallback=?', flickrCallback);
	};
	
	// private - callback function that adds the nessecary html markup to the page
	var flickrCallback = function(result){
		$.each(result.items, function(i, item){
			// create a new image object
			img = new Image();
			
			// append the image
			$(img).attr({
				title: item.title
			}).css({
				display: 'none'
			}).appendTo(appendTarget)
			.wrap('<li/>')
			.wrap('<a href="' + item.link + '" target="_blank" />');
			
			// the load event
			$(img).load(function(){
				$(this).fadeIn('slow');
			});
						
			// set the source, which when loaded triggers the load event
			$(img).attr('src', item.media.m);
		});
	};		  
}(window.talldan.flickr = window.talldan.flickr || {}, jQuery));




