var addthis_pub = "threadsmedia";

$(document).ready(function(){
	$.getScript("http://threadsmedia.com/threads/showdown.js/", function(){
		//create the containing box for the live comment preview
		$("#post_comment").append("<div id=\"comment_preview\"><h3>Comment Preview</h3><div class=\"comment\"><p>&nbsp;</p></div></div>");

		//let's set up the converter for Markdown processing
		converter = new Showdown.converter();

		//refresh the preview on every key press
		var comment = '';
		$('#comment').keyup(function() {
			comment = $(this).val();
			comment = converter.makeHtml(comment); //process the text with Markdown
			$('#comment_preview .comment').html(comment);
		});
	});
	
	//create the Add This button before the comment area
	$("div.body").append("<a href='http://www.addthis.com/bookmark.php' class='add_this'><img src='http://s7.addthis.com/static/btn/sm-share-en.gif' width='83' height='16' alt='' /></a>");
	$.getScript("http://s7.addthis.com/js/152/addthis_widget.js", function(){
		$("a.add_this").mouseover(function(){
			return addthis_open(this, '', '[URL]', '[TITLE]');
		}).mouseout(function(){addthis_close();}).click(function(){
			return addthis_sendto();
		});
	});
});