var Utils = {
  available: (function(d) {
    return ((d = document).attachEvent || d.addEventListener)
      && d.getElementById;
  })(),
  str: function(x) {
    return x == null ? '' : ('' + x);
  },
  strip: function(x) {
    return x == null ? '' : ('' + x).replace(/^\s+|\s+$/g, '');
  },
  each: function(list, proc) {
    if (list != null && typeof(proc) == 'function')
      for (var l = list.length, i = 0; i < l; ++i)
        if (proc(list[i], i, l) === false) break;
  },
  classRegExp: function(x) {
    return new RegExp('(^|\\s)' + Utils.strip(x) + '(\\s|$)');
  },
  element: function(id) {
    return document.getElementById(id);
  },
  elements: function(tagName) {
    return document.getElementsByTagName(tagName);
  },
  children: function(element, tagName) {
    if (element != null && element.childNodes != null) {
      tagName = Utils.strip(tagName).toUpperCase();
      for (var c = element.childNodes, l = c.length, i = 0; i < l; ++i)
        if (c[i].tagName && c[i].tagName.toUpperCase() == tagName) return c[i];
    }
    return null;
  },
  show: function(element) {
    if (element && element.style) element.style.display = 'block';
  },
  showInline: function(element) {
    if (element && element.style) element.style.display = 'inline';
  },
  hide: function(element) {
    if (element && element.style) element.style.display = 'none';
  },
  addEvent: (function() {
    if (document.attachEvent) return function(target, kind, proc) {
      if (target && target.attachEvent) target.attachEvent('on' + kind, proc);
    };
    if (document.addEventListener) return function(target, kind, proc) {
      if (target && target.addEventListener)
        target.addEventListener(kind, proc, false);
    };
    return function() {};
  })()
};

