$(document).ready(function($){
  var pageTracker = _gat._getTracker("UA-15305025-1");
  pageTracker._initData();
  pageTracker._trackPageview();
	$('#loadmore a').live('click', function() {
	$('#loadmore').load($('#loadmore a').attr("href")+' .content ol>li', {}, function() {$('#loadmore').replaceWith($('#loadmore').html());reZoom();});	
	return false;
})

$('.like a').live('click', function() {
	$.get($(this).attr("href"));
	var currentlikes = $(this).parent().nextAll(".likes").html().replace(/ likes?/,'');
	currentlikes++;
	var liketext = ' like';
	if(currentlikes!=1) {
		liketext+='s'
	}
	$(this).parent().nextAll('.likes').html(currentlikes+liketext);
	$(this).parent().removeClass('like').addClass('liked').empty().text('liked.');
	return false;
})

$('a.zoom').each(function(){
	var tempDiv = $(document.createElement('div'));
	var tempImg = $(document.createElement('img'));
	tempImg.attr('src',$(this).attr("href"));
	var tempId = 'zoomImage' + Math.floor(Math.random()*1000);
	tempDiv.attr("id", tempId);
	$(this).attr("href",'#'+tempId);
	tempDiv.append(tempImg);
	$(this).after(tempDiv);
	tempDiv.hide();
});

$('a.zoom').fZ();

});

reZoom = function() {
	$('a.zoom').each(function(){
		if($(this).attr("href").substring(0,1)!='#') {
			var tempDiv = $(document.createElement('div'));
			var tempImg = $(document.createElement('img'));
			tempImg.attr('src',$(this).attr("href"));
			var tempId = 'zoomImage' + Math.floor(Math.random()*1000);
			tempDiv.attr("id", tempId);
			$(this).attr("href",'#'+tempId);
			tempDiv.append(tempImg);
			$(this).after(tempDiv);
			tempDiv.hide();
		}
	});

	$('a.zoom').fZ();
}
