
// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will 
// be attatched to it.
var stacks = {};


// this call to jQuery gives us access to the globaal
// jQuery object. 
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other 
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);

// Javascript for stacks_in_6_page15
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_6_page15 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_6_page15 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	

//-- Flickr Slideshow Stack v2.0.1 by Joe Workman --//
$(document).ready(function() {
	/* Forming the query: */
	var username = $.trim("rajrana");
	var set = $.trim("72157624017636962");
	var group = $.trim("");
	var user_url = 'http://api.flickr.com/services/rest/?format=json&method=flickr.urls.lookupUser&jsoncallback=?&nojsoncallback=1&api_key=7a9a8fd7d352eb79fb8ddf7ed162effb&url=http://www.flickr.com/photos/' + username;
	var group_url = 'http://api.flickr.com/services/rest/?format=json&method=flickr.urls.lookupGroup&jsoncallback=?&nojsoncallback=1&api_key=7a9a8fd7d352eb79fb8ddf7ed162effb&url=http://www.flickr.com/groups/' + group;
	
	if (set) {
		create_flickr_slideshow('set_id='+ set);	
	}
	else if (username) {
		$.getJSON(user_url,function(data){
			if (data.user == null || data.user == undefined || data.user.id == null || data.user.id == undefined) {
			    // The Flickr NSID could not be found
				$('#stacks_in_6_page15 .flickr_slideshow').html('<p class="flickr_slideshow_error">Unable to find Flickr User ID for '+ username +'.</p>');
		 	}
			else {
				// The Flickr NSID was found
				create_flickr_slideshow('user_id='+ data.user.id);
			}
		});
	}
    else if (group) {
		$.getJSON(group_url,function(data){
			if (data.group == null || data.group == undefined || data.group.id == null || data.group.id == undefined) {
			    // The Flickr NSID could not be found
				$('#stacks_in_6_page15 .flickr_slideshow').html('<p class="flickr_slideshow_error">Unable to find Flickr Group ID for '+ group +'.</p>');
		 	}
			else {
				// The Flickr Group ID was found
				create_flickr_slideshow('group_id='+ data.group.id);
			}
		});	
	}
});
function create_flickr_slideshow(options) {
	var tags = $.trim("");
	var height = $.trim("400");
	var show_url = 'http://www.flickr.com/slideShow/index.gne?'+ options;
	if (tags) { 
		show_url = show_url +'&amp;tags='+ encodeURIComponent(tags);
	}	
	$('#stacks_in_6_page15 .flickr_slideshow').html('<iframe align="center" src="'+ show_url +'" frameBorder="0" width="100%" scrolling="no" height="'+ height +'px"></iframe>');
	return;    	        
};
//-- End Flickr Slideshow Stack --//

	return stack;
})(stacks.stacks_in_6_page15);



