var wall_writingComment=false;
var wall_cl=false;
var wall_since = 0;
var wall_pu;

  Event.observe('wall_main', "click", function showForm(event)
  {
    if(wall_cl)
    { 
      wall_cl = false;
      wall_writingComment = false;
      return;
    }
    if(wall_writingComment)
      return;
    wall_writingComment = true;
    mX = Event.pointerX(event);
    mY = Event.pointerY(event);
    o = Element.cumulativeOffset(document.getElementById('wall_main'));
    X = mX - o[0];
    Y = mY - o[1];

    new Ajax.Updater('wall_main', '/wall/add_entry.php', {
      method: 'get',
      insertion: Insertion.Bottom,
      parameters: {X: X, Y: Y}}
    );

  });
  updateEntries(wall_since, true);

function wall_addEntry()
{
  body = document.getElementById("wall_body").value;
  author = document.getElementById("wall_author").value;
  x = document.getElementById("wall_x").value;
  y = document.getElementById("wall_y").value;
  Element.remove('wall_entry_form');  
  new Ajax.Request('/wall/add_entry.php', {
    method: 'get',
    parameters: {body: body, author: author, X: x, Y: y}
  });
  wall_cl = true;
}

function wall_close()
{
  wall_cl = true;
  Element.remove('wall_entry_form');
}

function updateEntries(x, evalS)
{
  new Ajax.Updater('wall_main', '/wall/show_entries.php',
  {
    method: 'get',
    insertion: Insertion.Bottom,
    evalScripts: evalS,
    parameters: {since: x}
  });
}
