function behaviors(){
    // Close all unselected tabs.
    $("div.TabSection").hide();
    $("ul.Tabs > li").removeClass('Selected');
    
    // Show the default; Recent Comments
    $("#RecentComments").show();
    $("li.One").addClass('Selected');
    
    // Set up click functions for the Recent Comments tab.
	$("li.One").click( function()
	{
        $("ul.Tabs > li").removeClass('Selected');
        $("div.TabSection").hide();

        if (this.className.indexOf("Selected") > -1) {
            $("#RecentComments").show();
            return;
        }
        $(this).addClass('Selected');
        $("#RecentComments").show();
        return false;
	});

    // Set up click functions for the Recent Comments tab.
	$("li.Two").click( function()
	{
        $("ul.Tabs > li").removeClass('Selected');
        $("div.TabSection").hide();

        if (this.className.indexOf("Selected") > -1) {
            $("#OnThisDay").show();
            return;
        }
        $(this).addClass('Selected');
        $("#OnThisDay").show();
        return false;
	});

	//Set up the comment preview
	$("#PreviewButton").click(function(){

		$.ajax({
			type: "POST",
			url: "/_rest/comment_preview.php",
			data: "text=" + $("#CommentText").val(),
			success: function(html){
				$("#CommentPreview").html(html);
			}
		});

		$("#CommentPreview").fadeIn();

		return false;


	});
}

$(document).ready( behaviors );

function LoadMoreComments(PostId, Start, Length)
{
	CommentCount = CommentCount + Length;
	
	var Url = '/_rest/get_comments.php?p=' + PostId + '&s=' + Start + '&l=' + Length;
	var MoreComments = $.ajax({ url: Url, cache: false, success: function(html){ $("#MoreComments").append(html); 	$('#DisplayedCommentCount').html(CommentCount); }});


}
