$(document).ready(function(){

	$("#submit").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});


	$(".allowed-tags a").click(function(){

		try {
			var sTag = $(this).text(), eTag = "";
			for (i = 1; i < sTag.length; i++) {
				if (sTag.charAt(i) != " " && sTag.charAt(i) != ">") {
					eTag += sTag.charAt(i);
				} else {
					break;
				}
			}
			$('#comment').replaceSelection(sTag + $("#comment").getSelection().text + "</" + eTag + ">", true);
		} catch(e) {
			alert(e);
		}

		return false;
	});

	$(".reply").click(function(){
		var text = "<a href=\"" + $(this).prev().find(".commentDate").attr("href") + "\">@" + $(this).prev().find("b").eq(0).text() + "</a>: ";
		$('#comment').replaceSelection(text, true);

		return false;
	});

});
