// ----------------------------------------------------------------------
// Javascript tools
// ----------------------------------------------------------------------
// _("foo") - shortcut to getElementById
// debug("message") - scroll message into <div id="debug"> if present
// show("id") / hide("id") / toggle("id") show/hide/toggle display of div
// ----------------------------------------------------------------------
//  Copyright 1998-2008 "Nosey" Nick Waterman
//  Distributed under the GNU GPL V2 license.
//
//  This software is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License as
//  published by the Free Software Foundation; either version 2 of the
//  License, or (at your option) any later version.
//
//  This software is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this software; If not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
//  MA  02111-1307 USA

function _(a) {
  return document.getElementById(a) || a;
}

var debuglist = [ "", "", "", "", "", "", "", "", "", "" ];
var debugno = 1;

function debug(a) {
  var div = _("debug");
  if (!div) { return; }
  
  debuglist.shift();
  debuglist.push(debugno++ + ": " + a);
  div.innerHTML = debuglist.join("<br />");
}

function show(id) {
   // what if it was supposed to be table-cell or something?
  _(id).style.display = "block";
}

function hide(id) {
  _(id).style.display = "none";
}

function toggle(id) {
  var style = _(id).style;
  if (style.display == "block") {
    style.display = "none";
  } else {
    style.display = "block";
  }
}
