// Clears the form
function clear_new() {
var message = document.getElementById('message');
var author = document.getElementById('author');
message.value = '';
author.value = '';
}

// toggles the message form from visible to hidden
function swapPost()
{
 var isVisible = $('#postMessage').is(':visible');
 if(isVisible)
 {
  $("#postLink").html("Оставить&nbsp;сообщение");
  $("#postMessage").hide();
 }
 else
 {
  $("#postLink").html("Спрятать форму");
  $("#postMessage").show();
 }
}

// загрузка сообщений из БД в контейнер messages
function show_messages()
{
 $.ajax(
 {
  type: "GET",
  url: "/gb/show_gb.php?page="+$("#page").val(),
  cache: false,
  success: function(html)
  {
   $("#messages").html(html);
  },
  error: function(xhr, ajaxOptions, thrownError)
  {
   alert(xhr.status);
   alert(thrownError);
  }
 });
}

function show_first_messages()
{
 $.ajax(
 {
  type: "GET",
  url: "/gb/show_gb.php",
  cache: false,
  success: function(html)
  {
   $("#messages").html(html);
  },
 });
}

