rotLogo.restartDelay = 500; // delay onmouseout to restart rotation

rotLogos = {}; // globally accessible reference to object 

function rotLogo(id, delay, mouseEvents) {
    this.id = id;
    this.delay = delay;
    this.items = [];
    this.ctr = 0;
    this.timer = null;
    rotLogos[this.id] = this;
    this.animString = "rotLogos." + this.id;
    if (mouseEvents)
	rotLogo.setMouseEvents(this.id);
};

rotLogo.prototype.add = function(html) {
 	this.items[this.items.length] = html;
};

rotLogo.prototype.rotate = function() {
    clearTimeout(this.timer);
    this.timer = null;
    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);
    }
};

rotLogo.setMouseEvents = function(id) {
    var el = document.getElementById(id);
    if (el) {
        el.onmouseover = rotLogo.pause;
        el.onmouseout = rotLogo.resume;
    }
};

rotLogo.pause = function() { 
    var curObj = rotLogos[this.id];
    if (curObj) {
	clearTimeout(curObj.timer);
	curObj.timer = null;
    }
};
 
rotLogo.resume = function(e) {
    e = e ? e: window.event;
    var toEl = e.relatedTarget ? e.relatedTarget : e.toElement;
    if (this != toEl && !contained(toEl, this)) {
        var curObj = rotLogos[this.id];
        if (curObj)
            curObj.timer = setTimeout(curObj.animString + ".rotate()", rotLogo.restartDelay);
    }
};

function contained(oNode, oCont) {
    if (!oNode) return;
    while (oNode = oNode.parentNode)
	if (oNode == oCont) return true;
    return false;
};
