﻿var Riser = {
	
	api_key: 'a01d83c781d7477a6745fb6cc598fee0',//'59f274e3514f672180c069409c7b745f', 
	secret: '27e29ce1c6485b75',
	user_id:'47320488@N04',
	container:'#flickr_imgs',
	num_pics: 8,
	flickr:function(){
	var _self = this;
		
		    fli_method = 'flickr.photosets.getPhotos',
		    set_id = '72157626746306429',//'72157626693726353';
			
			api_call = 'http://api.flickr.com/services/rest/?method=' + fli_method + '&api_key=' + this.api_key + '&photoset_id=' + set_id + '&extras=url_sq&format=json&jsoncallback=?';
		
			$.ajax({
				type: "GET",
				url: api_call,
				dataType: "json",
				success: function (data) {
					
					var _container = _self.container;
					var pics = data.photoset.photo;
					
					//Image loaded handler
					img_loaded = function(){
						
						$(this).hide()
							   .fadeIn();
					};
					
					
					$(pics).each(function(i, photo){
					
						if (i < _self.num_pics) {
						
						var pic_width = photo.width_sq;
						var pic_height = photo.height_sq;
						var pic_url = photo.url_sq;
						var pic_id = "bi_photo_"+i; //Hard coded file suffix convention 
					
						var my_img = $('<img></img>').attr('src', pic_url);
						
						if ($.browser.msie){ //if MSIE add queries to fool IE and have it reload the img everytime, therefore no cashing for IE!! 
							my_img.attr('src', pic_url + '?random=' + (new Date()).getTime());	
						}
						
						my_img 
						.attr('height', pic_height)
						.attr('width', pic_width)
						.hide()
						.bind("load",img_loaded)
						.appendTo($('<div></div>').addClass('_img_loading').css({
							'width': pic_width + 'px',
							'height':pic_height+ 'px'
						}))
						;
						
						my_img
						.appendTo(_container)
						.wrap('<a href="/about/spy-cam/" />');
						
						}else{
						
						return false;
						}
						
					});
					
				}
			});//End of Ajax	

	}//End of Flickr
};//End of Riser

/*$(document).ready(function() {

	Riser.flickr();

});*/
