/*************************************************************************
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*************************************************************************/

bannerObjects = {};
function bannerObj(id,delay) {
  this.id = id; this.delay = delay; this.items = []; this.timer = null;
  bannerObjects[this.id] = this;
  this.animString = "bannerObjects." + this.id;
}

bannerObj.prototype.ctr = 0;
bannerObj.prototype.addItem = function(sHtml) {
 	this.items[this.items.length] = sHtml;
}

bannerObj.prototype.rotate = function() {
  var el = document.getElementById(this.id);
  el.innerHTML = this.items[this.ctr];
  if (this.ctr < this.items.length-1) this.ctr++;
  else this.ctr = 0;
  this.timer = setTimeout(this.animString + ".rotate()", this.delay);
}

bannerObj.prototype.setMouseEvents = function() {
  var el = document.getElementById(this.id);
  
  el.onmouseover = function(e) {
    clearTimeout(bannerObjects[this.id].timer);
  }
  
  el.onmouseout = function(e) {
    e = e? e: window.event;
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( this != toEl && !contained(toEl, this) ) {
      var animStr = bannerObjects[this.id].animString;
      bannerObjects[this.id].timer = setTimeout(animStr + ".rotate()",500);
    }
  }  

  // returns true of oNode is contained by oCont (container)
  function contained(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode.parentNode ) {
      oNode = oNode.parentNode;
      if ( oNode == oCont ) return true;
    }
    return false;
  }
  
}

// adapted from act_api.js by Dan Pupius of www.13thparallel.org
var imageHandler = {
  imgs: new Array(),
  path: "",
  preload: function () {
    for (var i=0; i<arguments.length; i++) {
      var img = new Image();
      img.src = this.path + arguments[i];
      this.imgs.push(img);
    }
  }
}

// from www.13thparallel.org
if (Array.prototype && !Array.prototype.push) {
	Array.prototype.push = function() {
		for (var i=0; i<arguments.length; i++) this[this.length] = arguments[i];
		return this.length;
	};
}

