/************************************************************************* dw_banners.js version date: Feb 2004 This code is from Dynamic Web Coding at http://www.dyn-web.com/ Copyright 2001-4 by Sharon Paine See Terms of Use at http://www.dyn-web.com/bus/terms.html regarding conditions under which you may use this code. This notice must be retained in the code as is! *************************************************************************/ bannerObjects = {}; function bannerObj(id, delay, bMouse) { this.id = id; this.delay = delay; this.items = []; this.timer = null; bannerObjects[this.id] = this; this.animString = "bannerObjects." + this.id; if (bMouse) { // set up pause/resume onmouseover/out var el = document.getElementById(this.id); if (el) { el.onmouseover = bannerObj.clearTimer; el.onmouseout = bannerObj.restartTimer; } } } 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); if ( el && typeof el.innerHTML != "undefined" ) { 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); } } // these 2 functions called onmouseover/out of banner el bannerObj.clearTimer = function() { clearTimeout(bannerObjects[this.id].timer); } bannerObj.restartTimer = 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 = oNode.parentNode ) if ( oNode == oCont ) return true; return false; } // adapted from act_api.js by Dan Pupius of www.13thparallel.org var imageHandler = { imgs: [], path: "", preload: function() { var i, img; for (i=0; arguments[i]; i++) { img = new Image(); img.src = this.path + arguments[i]; this.imgs[this.imgs.length] = img; } } }