// General function that opens up popup windows with the given // parameters set.
function openWindow(url, name, width, height, left, top,
  directories, scrollbars, location, menubar, status, toolbar) {
  
  if (!width)       width       = 400;
  if (!height)      height      = 400;
  if (!left)        left        = 10;
  if (!top)         top         = 10;
  if (!directories) directories = 0;
  if (!scrollbars)  scrollbars  = 0;
  if (!location)    location    = 0;
  if (!menubar)     menubar     = 0;
  if (!status)      status      = 0;
  if (!toolbar)     toolbar     = 0;
  
  var properties = 'width=' + width + ',height=' + height + ',top=' + top +
    ',directories=' + directories + ',scrollbars=' + scrollbars + ',location=' +
    location + ',menubar=' + menubar + ',status=' + status + ',toolbar=' + toolbar;
  
  if (url && name) {
    return window.open(url, name, properties);
  }
} // openWindow


function getFirstChildNode(element, tagName) {
  if (element && (element.childNodes.length > 0)) {
    for (var i = 0; i < element.childNodes.length; i++) {
      var child = element.childNodes[i];
      
      if ((child.nodeType == 1) && (child.tagName == tagName)) {
        return child;
      }
    }
  }
  
  return null;
} // getFirstChildNode

function getNode(collection, tagName, className) {
  if (collection.length > 0) {
    for (var i = 0; i < collection.length; i++) {
      var child = collection[i];
      
      if ((child.nodeType == 1) && (child.tagName == tagName) &&
        (child.className.indexOf(className) >= 0)) {
        return child;
      }
    }
  }
  
  return null;
} // getNode

function getNodes(collection, tagName, className) {
  var nodes = new Array();
  
  if (collection.length > 0) {
    for (var i = 0; i < collection.length; i++) {
      var child = collection[i];
      
      if ((child.nodeType == 1) && (child.tagName == tagName) &&
          (child.className.indexOf(className) >= 0)) {
        nodes.push(child);
      }
    }
  }
  
  return nodes;
} // getNodes

function addEvent(obj, evType, fn) {
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, false);
    return true;
  } else if (obj.attachEvent) {
    var r = obj.attachEvent("on" + evType, fn);
    return r;
  } else {
    return false;
  }
} // addEvent

