$(document).ready(function(){
	fetchZootool(0);
});

function fetchZootool(offset) {
	$.getJSON('http://zootool.com/api/users/items/?username=mattaitken&limit=50&offset=' + offset + '&apikey=4416077b3aa2dab610199eec6eba0afd&callback=?', function(data) {
		var items = [];
		$.each(data, function(i,item){
			if(item.type == "image") {
				var itemString = '<li class="' + item.type + '" title="' + item.title + '"><a href="' + item.referer + '"><img src="' + item.url + '" /></a></li>';
				/*$.each(item.tags, function(i, tag){
					itemString += '<a href="http://zootool.com/user/mattaitken/tag:' + tag + '" rel="tag">' + tag + '</a>';
				});
				itemString += '</div></li>';*/
				items.push(itemString);
			}
		});
					
		var newElements = $('<ul/>', {
			'class': 'zootool-list',
			html: items.join('\n')
		}).appendTo('#zootool');
	});
	
}

$(window).load(function(){
	$('#zootool ul').isotope({	
		itemSelector : 'li',
		resizable: 'true'
	});
});

$(window).smartresize(function(){
  $('#zootool ul').isotope();
});


/*
$(window).resize(function(){
	$('#zootool ul').isotope();
});

$(window).scroll(function (e) { 
      
});*/
