$(document).ready(function() {

	//Tool tips
	var coords, tw, iw;
	$(".postmeta > *, .share a, .datebox").on("mouseover",function(e) {
		var tip=$(this).attr('title');
		if (typeof tip == "string") {
			$('body').append('<div class="tooltip scriptable" style="position:absolute;">'+tip+'</div>');
			tw = $(".tooltip.scriptable").width();
			coords=$(this).offset();
			$(".tooltip.scriptable").css("top",(coords.top-30)+"px").css("left",Math.round(coords.left-tw/2+4)+"px");
			$('.tooltip.scriptable').show();
		}
	}).on("mouseout",function() {
		$('.tooltip.scriptable').remove();
	});

	//Toggle post excerpts
	var showText='Show Excerpt';
	var hideText='Hide Excerpt';
	$('.toggle.show').prev().append(' <a href="#" class="toggleLink" title="'+hideText+'"><span>'+hideText+'</span></a>');
	$('.toggle:not(.show)').prev().append(' <a href="#" class="toggleLink show" title="'+showText+'"><span>'+showText+'</span></a>');
	$('.toggle:not(.show)').hide();
	$('a.toggleLink').click(function() {
		if ($(this).parent().next('.toggle').is(":visible")) {
			$(this).addClass('show');
			$(this).attr("title", "Show Excerpt");
		} else {
			$(this).removeClass('show');
			$(this).attr("title", "Hide Excerpt");
		}
		$(this).parent().next('.toggle').slideToggle('fast');
		return false;
	});
});
