jQuery(document).ready(function(){
	jQuery('#the-posts .navigation a').live('click', function(e){
		e.preventDefault();
		var link = jQuery(this).attr('href');
		jQuery('html, body').animate( { scrollTop: 0 }, 'slow' );
		jQuery('#container').fadeTo(500, 0, function() {
			jQuery('#container').load(link + ' #content', function(){ jQuery('#container').fadeTo(500, 1); });
		});
	});
	
	jQuery('.comment-navigation a').live('click', function(e){
		e.preventDefault();
		var link = jQuery(this).attr('href');
		jQuery('html, body').animate( { scrollTop: jQuery('#the-comments-area').offset().top }, 'slow' );
		jQuery('#the-comments-area').fadeTo(500, 0, function() {
			jQuery('#the-comments-area').load(link + ' #the-comments', function(){ jQuery('#the-comments-area').fadeTo(500, 1); });
		});
	});
	
	jQuery('.tabs').each(function() {
		jQuery(this).prepend("<ul><\/ul>");
		jQuery(this).children('h2').each(function() {
			var id, caption, classhtml;
			id = jQuery(this).text().toLowerCase().replace(/[^a-z0-9]/g, '');
			caption = jQuery(this).text();
			if (jQuery(this).attr('class')) classhtml = ' class="' + jQuery(this).attr('class') + '"';
			jQuery(this).nextUntil('h2').wrapAll('<div id="'+id+'" />');
			jQuery(this).parent().children('ul:first').append('<li><a href="#'+id+'"'+classhtml+'><span>'+caption+"<\/span><\/a><\/li>");
			jQuery(this).hide();
		});
		
		jQuery(this).tabs();
		jQuery('.ui-tabs-nav li a', this).mouseup(function() { this.blur(); });
	});
});

function ga_plusone( obj ) {
	_gaq.push(["_trackEvent", "plusone", obj.state]);
}
