function initialiseComments()
{
  $(".stdbutton").css("display","none");
  $(".jsbutton").css("display","block");
}

function showLoading(btnid)
{
  $(btnid).attr("src","/images/loading.gif");
}

function hideLoading(btnid,originalsrc)
{
  $(btnid).attr("src",originalsrc);
}

function loadComments(btnid,pageid,commentspage)
{
  btnid = "#" + btnid;
  var oldsrc = $(btnid).attr("src");
  showLoading(btnid);

  var jqxhr = $.post("/com/comments_show_section.php",
    {page_id : pageid,
     comm_page : commentspage},
    function(responseText) {
      $("#commentsection").html(responseText);
      initialiseComments();
      hideLoading(btnid,oldsrc);
    },
    "html" )
  .error(function() {
    hideLoading(btnid,oldsrc);
    alert("Sorry, there was an error when trying to load additional comments."); })
}

function showMore(commentid)
{
  var pid = "#comm" + commentid;
  var jqxhr = $.post("/com/comments_show_more.php",
    {id : commentid},
    function(responseText) {
      $(pid).html(responseText);
    },
    "html" )
  .error(function() {
    alert('Sorry, there was an error when trying to load the full comment text. <a href="javascript:showMore(' + commentid + ');">Try again</a>');
    })
}

