$(document).ready(function() {
	$('#header').click(function() {
		window.location.href = oelna.blog.url;
	});
	
	//hide the popovers when not needed
	$('body').click(function() {
		$('#archives-2, #linkcat-4, #meta-2, #rss-links').fadeOut('fast');
	});
	//the same for the iphone
	$('body').bind('touchstart', function() {
		$('#archives-2, #linkcat-4, #meta-2, #rss-links').fadeOut('fast');
	});
	

	$('#popovers li a').click(function(e) {
		//hide all popovers currently showing
		$('#archives-2, #linkcat-4, #meta-2, #rss-links').slideUp('fast');
		
		var target = $(this).attr('rel');
		var position = $(this).offset();
		var width = $('#'+target).css('width');
		
		var left = parseInt($('#po-meta').offset().left)+parseInt($('#po-meta').css('width'))-parseInt($('#'+target).css('width'))-parseInt($('#'+target).css('borderRightWidth'))-2;
		
		//$('#'+target).css({top: (position.top+16)+'px', left: (800-width)+'px'}).slideDown();
		$('#'+target).css('left', left+'px').slideDown();
		return false;
	});
	
	//$('.form-submit #submit').hide().after('<span><a id="comment-submit-button" href="#submit-form" class="black-button">Post</a></span>');
	$('#comment-submit-button').click(function() {
		$('#commentform').submit();
		return false;
	});
	
	setupZoom();
	
	//track with gooogle analytics (now handled by async tracking code)
	if(oelna.blog.ga_account != '') {
		oelna.blog.tracker = _gat._getTracker(oelna.blog.ga_account);
		oelna.blog.tracker._trackPageview();
	}
});
