//  $Id: script.js,v 1.3 2007/05/30 04:21:36 mclark Exp $
//  Copyright (C)2007 Matthew Clark. All Rights Reserved.

//  text trimming

function trim(text) {
  if (text.length > 0) {
    while (text.substring(0,1) == ' ')
      text = text.substring(1, text.length);
    while (text.substring(text.length - 1, text.length) == ' ')
      text = text.substring(0, text.length - 1);
  };
  return text;
}

//  finding an element

function get_element(id) {
  if (document.getElementById)
    return document.getElementById(id);
  else if (document.all)
    return document.all[id];
  return null;
}

//  inner text

function get_inner(obj) {
  if (typeof(obj) == 'string')
    obj = get_element(obj);
  return obj ? (document.all ? obj.innerText : obj.innerHTML) : '';
}
function set_inner(obj, text) {
  if (typeof(obj) == 'string')
    obj = get_element(obj);
  if (obj) {
    if (document.all)
      obj.innerText = text;
    else
      obj.innerHTML = text;
  }
}