		
	$(function() {	
		
		// COMMENTS
		$("div#comments").each(function() { $(this).find("div.comment:last").css("border-bottom","solid 1px #d9d9d9"); });
		
		$("div#comments a.reply").live('click', function(event) {
			event.preventDefault();
			var reply = $("div#comments div.reply").clone(true);
			$("div#comments div.reply").slideUp(600,function() { $(this).remove(); });
			$(reply).css("display","none");
			$(reply).find("input#comment_parent").val($(this).parent().parent().parent().find("input.comment_parent").val());
			$(this).parent().parent().parent().after(reply);
			$(reply).prev().css("border-bottom", "solid 1px #d9d9d9");
			$("div#comments div.reply").slideDown(600);
			$("a#cancel_reply").remove();
			$("div.form_actions").append("<a href='#' id='cancel_reply'>Cancel</a>");
		});
		
		$("a#cancel_reply").live('click', function(event) {
			event.preventDefault();
			$(this).remove();
			$("div#response").prev().css("border-bottom", "none");
			var reply = $("div#comments div.reply").clone(true);
			$("div#comments div.reply").slideUp(600,function() { $(this).remove(); });
			$(reply).css("display","none");
			$(reply).find("input#comment_parent").val(0);
			$("div#comments").append(reply);
			$("div#comments div.reply").slideDown(600);
		 });
		 
		$("div#comments div.reply a.submit").click(function() {
			if( $("input#author").val()==$("input#author").attr("title") || $("input#email").val()==$("input#email").attr("title") || $("textarea#comment").val()==$("textarea#comment").attr("title")) {
				alert("Please enter all the fields and try again.");
			} else {
				$("form#comment_form").submit();
			}
		});
		
		$("input.clear_on_focus").bind({
			focusin: function(){
				if($(this).val()==$(this).attr("title")) {
					$(this).val("");	
				}
			}, 
			focusout: function(){
				if($(this).val()=="") {
					$(this).val($(this).attr("title"));	
				}
			}
		});
	
		
	});
