/*js for flickr slideshow by ubuntu4life 2008-02-26*/

$(function(){

$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?format=json&id="+uflickrid+"&tags="+uflicktags+"&jsoncallback=?",
        function(data){

	if(data.items.length!= 0){
          $.each(data.items, function(i,item){
            imgstr='<img title="'+item.title+'" src="'+item.media.m.replace(/_m/g,"_s").replace("farm2.static.flickr.com","69.147.90.156").replace("farm1.static.flickr.com","68.142.232.116")+'" />';
            $("<a></a>").attr("href",item.link).html(imgstr).appendTo("#demo");
		$("#ajax").hide();
		$("#runcode").css("margin-right","0");

       });

//after img loaded resize them to uwidth and ucolumns
//control the with and columns,rows

$("#ubuntu4life").css("width",uflickrWidth+1+"px");
$("#ubuntu4life .updown a").css("width",uflickrWidth+"px");
imgtempwidth = uflickrWidth/uflickrColumns;
$("#ubuntu4life #demo img").css("width",imgtempwidth-10+"px");
$("#ubuntu4life #demo").css("height",imgtempwidth*uflickrRows+"px");


$("#ubuntu4life #scrolltotop").click(function(){if(offsetN > (default_show_photos/3-1)*(imgtempwidth+2)){alert("Sorry,You have reach the bottom")}else{slideit(imgtempwidth);}})
$("#ubuntu4life #scrolltobottom").click(function(){if(offsetN < imgtempwidth){alert("Sorry,You have reach the top")}else{slideit(-1*imgtempwidth);}})


	}else{
		$("#demo").html("<span style='color:#c00'>Sorry,No photos with this id or tags.Please check ID or tags  again.</span>");
		$("#ajax").hide();
		$("#runcode").css("margin-right","0");
	}

});

$("#ubuntu4life img").mouseover(function(){$(this).css({opacity:"1"}).animate({opacity:".1"},300).animate({opacity:"1"},200);})


$("#ubuntu4life .updown a").click(function(){$(this).blur();return false;})

var offsetN = 0;
default_show_photos = 15;

function slideit(n){
offsetN = offsetN + n;
$("#ubuntu4life #demo").animate({scrollTop: offsetN}, 1500);
}


})

