
var args = {theme:"light_square",show_title: false,default_width:640,default_height:400}

$(".play-video,.lightbox").prettyPhoto(args);
 
$('#playall').prettyPhoto(args);

/* pulls flickr stream for each germ */
$('#viewing-gallery').each(function(){
	 var $this = $(this),
	 	set_id = $this.attr('data-set');
	
  $.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=238bb5f8a6fca1c583f7e45dd2ea4137&photoset_id='+set_id+'=&format=json&jsoncallback=?', function(data){
	  
	if(data.stat === 'fail'){
			$this.html('<div class="no-photos">Photos ... on the way</div>');
	} else {
		var timer = 100;
		$.each(data.photoset.photo, function(i,obj){
			
			var square_url = 'http://farm' + obj.farm + '.static.flickr.com/' + obj.server + '/' + obj.id + '_' + obj.secret + '_s.jpg',
				large_url = square_url.replace('_s.jpg', '_b.jpg'),
				el_class = 'item',
		 		inner_html = '<a rel="gallery['+set_id+']" href="'+large_url+'" target="_blank">';

	     		inner_html += '<img title="'+obj.title+'" src="'+square_url+'" alt="'+obj.title+'" />';
    	 		inner_html += '</a>'

    	 		if((i + 1) % 8 === 0){
					el_class += ' end';
				}
				 
				$el = $('<div class="'+el_class+'"></div>');
	 		 	$el.css('display','none');
		 		$this.append($el);
				$el.html(inner_html);
				
				$el.delay(timer * i).fadeIn(300);
			
		
		 	
		});
		$this.append('<div class="clearfix"></div>');
	}
	  
	});
	
	setTimeout(function(){
		 $this.find('a').prettyPhoto({theme:"light_square",show_title: false});	
	},700);
});
/* --- end of flickr stream */



