/*FLICKR */
function getFlickrPhotoSet(photoSetID, w, h, target) {
	 var apiKey = '54917d7a00afd05f21a2267d04846304';
	 var returnedData;
	 if(isNaN(photoSetID)) {
		  jQuery.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photos.search&api_key=' + apiKey + '&tags=' + photoSetID + '&tag_mode=all&format=json&jsoncallback=?', function(data){
				returnedData = data;
				processPhotos(returnedData, w, h, target);
		  });	
	 } else {
		  jQuery.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=' + apiKey + '&photoset_id=' + photoSetID + '&format=json&jsoncallback=?',  function(data){
				returnedData = data;
				processPhotos(returnedData, w, h, target);
		  });
	 }
}
function processPhotos(data, w, h, target) {
	var flickrHtml = "<div id=\""+target+"gallery\">";
	jQuery.each(data.photoset.photo, function(i,item){ 
		var photoURL = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg';
	 	flickrHtml += "<img src=\"" + photoURL + "\" width=\"" + w + "\" height=\"" + h + "\" />";
	});
	 flickrHtml += "</div>";
	 $('#' + target).empty();
	 $('#' + target).html(flickrHtml);
	 setUpSlideShow(target);
}
function setUpSlideShow(target) {
	jQuery('#'+target+'gallery').cycle({
		fx:     'scrollRight'
	});
}
