$(document).ready(function()
	{

		// Put hash into simpler variable
		hash = window.location.hash;
		
		// Auto-populate form fields with their titles
		$('.populate').each(function(){
			var e = $(this);
			if (!e.val()) { e.val(e.attr('title')); }
			e.focus(function(){
				var e = $(this);
				if (e.attr('title') == e.val()) { e.val(''); }
			});
					
			e.blur(function(){
				var e = $(this);
				if (!e.val()) { e.val(e.attr('title')); }
			});
		});	

		// Scroll to top
		$("a[href=#top]").click(function()
			{
				$("html, body").animate(
					{ scrollTop:0 }, 500
				);
				return false;
			}
		);
		
		// Show hide/show comments
		$("div#entry-comment-toggle").show();			

		if(hash.match(/comment/)){
			$("p.comments-toggle").toggle();
		} else {
			$("div#comments").hide();
		}
		
		$("p.comments-toggle a").click(function(){
			$("p.comments-toggle").toggle();
			$("div#comments").slideToggle();
			return false;
		});
		
		
		// Subscription gift option alert
		var note = $("form.subscription-form #subscription-note");
		$(note).hide();
		$("form.subscription-form input[rel=hide-msg]").click(function(){
			$(note).fadeOut();
		});
		$("form.subscription-form input[rel=show-msg]").click(function(){
			$(note).fadeIn();
		});
		
	}
);

// Configuration for AddThis button
var addthis_config = {
	'services_exclude': 'print',
	'services_compact': 'facebook,twitter,email,gmail,digg,myspace,google,delicious,stumbleupon,instapaper'
}