function refresh(name, set_id) {
	jQuery("#photo_gallery #list_of_images #ImageWraper").empty();
	$("#work_space").redrawShadow();
	$("h2#set_name").html(name);
	jQuery("#photo_gallery #list_of_images #ImageWraper").flickr({
		api_key: "b7b52f4208438a95aea74f6d03481d05",
		callback: liteboxCallback,
		photoset_id: set_id,
		type: "photoset",
		user_id: "48741121@N02",
		thumb_size: "m"
	});
	$("#work_space").ajaxComplete(function(request, settings){
		setTimeout(function(){$("#work_space").redrawShadow();}, 1000); 
	});
}

function liteboxCallback(el){
	$(el).litebox({
		nz:'0.8em',
		lu:'http://djlafemme.com/design/djlafemme/images/ajax-loader.gif',
		sc: "#000000",
		oc: "#000000"
	});
};

function GetSets(){
	var url = 'http://api.flickr.com/services/rest/?format=json&jsoncallback=?&api_key=b7b52f4208438a95aea74f6d03481d05&method=flickr.photosets.getList&user_id=48741121@N02';
	var sets_list = '';
	$.getJSON(url, function(data){
		if (data.stat == "ok"){
        		$('#list_of_albums').html('<ul class="sets_list"></ul>');
			jQuery.each(data.photosets.photoset, function() {
				sets_list += '<li><a href="javascript:void(0);" onclick="refresh(\'' + this.title._content + '\', \'' + this.id + '\')">' + this.title._content + '</a></li>';
			});
			$('#list_of_albums ul.sets_list').append(sets_list);
		}
	});
}

$(document).ready(function(){
	refresh('test', '72157623707172850');
	GetSets();
});
