function htmlBanner(c, d) { var e = document.getElementById(c); var f = document.getElementById(d); this.initialize = function() { for (var i = 0; i < this.slides.length; ++i) { this.slides[i].itemPos = "slide-" + i.toString(); this.slides[i].style.position = "absolute"; this.slides[i].style.zIndex = 10; this.slides[i].style.left = -(Number(this.slides[0].offsetWidth) * i) + "px"; this.menuItems[i].idCount = "menu-" + i.toString(); this.menuItems[i].onclick = this.menuClick; this.menuItems[i].onmouseover = this.menuOver; this.menuItems[i].onmouseout = this.menuOut; this.menuItems[i].slideId = c + "-slide"; this.slides[i].slideId = c + "-slide"; if (i == this.currentItem) { this.menuItems[i].className = "active" } else { this.menuItems[i].className = "inActive" } } }; this.slideNext = function(b) { if (typeof (b) == "undefined") { b = this } clearTimeout(b.delayTimerId); b.delayTimerId = null; if (b.blocked) { b.startSlideCountDown() } if (b.menuItems.length == 0 || b.nextItem >= b.menuItems.length) { return } b.menuItems[b.currentItem].className = "inActive"; b.menuItems[b.nextItem].className = "active"; b.blocked = true; if (b.currentItem > b.nextItem) { var a = new Animator(0, Number(b.slides[0].offsetWidth), this.slides[b.currentItem], this.slides[b.nextItem]) } else { var a = new Animator(0, -Number(b.slides[0].offsetWidth), b.slides[b.currentItem], b.slides[b.nextItem]) } b.currentItem = b.nextItem; ++b.nextItem; if (b.nextItem >= b.slides.length) { b.nextItem = 0 } b.startSlideCountDown() }; this.startSlideCountDown = function() { if (!this.slides || this.slides.length == 0) { return } var a = this; this.delayTimerId = setTimeout(function() { a.slideNext(a) }, a.delay) }; this.menuClick = function() { if (window[this.slideId].blocked || Number(this.idCount.replace("menu-", "")) == window[this.slideId].currentItem) { return } if (window[this.slideId].delayTimerId != null) { clearTimeout(window[this.slideId].delayTimerId); window[this.slideId].delayTimerId = setTimeout(function() { window[this.slideId].slideNext(window[this.slideId]) }, window[this.slideId].delay) } window[this.slideId].nextItem = Number(this.idCount.replace("menu-", "")); window[this.slideId].slideNext(window[this.slideId]) }; this.slideNextPrev = function(a) { var b = window[this.slideId].currentItem + Number(a); if (window[this.slideId].blocked || b >= this.slides.length || b < 0) { return } if (window[this.slideId].delayTimerId != null) { clearTimeout(window[this.slideId].delayTimerId); window[this.slideId].delayTimerId = setTimeout(function() { window[this.slideId].slideNext(window[this.slideId]) }, window[this.slideId].delay) } window[this.slideId].nextItem = b; window[this.slideId].slideNext(window[this.slideId]) }; this.menuOver = function() { var a = Number(this.idCount.replace("menu-", "")); window[this.slideId].menuItems[a].className += " hover"; if (a == window[this.slideId].currentItem) { return } }; this.menuOut = function() { var a = Number(this.idCount.replace("menu-", "")); window[this.slideId].menuItems[a].className = window[this.slideId].menuItems[a].className.replace(" hover", ""); if (a == window[this.slideId].currentItem) { return } window[this.slideId].menuItems[a].className = window[this.slideId].menuItems[a].className.replace(" menuHover", "") }; if (!e || !f) { return }; window[c + "-slide"] = this; this.slides = null; this.menuItems = null; this.currentItem = 0; this.nextItem = 1; this.delay = 12000; this.delayTimerId = null; this.blocked = false; this.slides = e.getElementsByTagName("li"); for (var i = 0; i < this.slides.length; i++) { var s = document.createElement("span"); s.innerHTML = (i + 1).toString(); var l = document.createElement("li"); l.appendChild(s); f.appendChild(l) } this.menuItems = f.getElementsByTagName("li"); if (this.slides.length == 0 || this.menuItems.length == 0 || this.slides.length > this.menuItems.length) { return } this.initialize() } function Animator(a, b, c, d) { this.points = { 'from': a, 'to': b }; this.speed = 20; this.delayTimerId = null; window.animator = this; this.obj1 = c; this.obj2 = d; this.animDelta = (this.points.to - this.points.from); this.tweenAmount = [1, 3, 5, 7, 9, 10, 10, 10, 10, 10, 9, 7, 5, 3, 1, ]; this.currentFrame = 0; this.frameCount = this.tweenAmount.length; this.frames = []; this.newFrame = this.points.from; for (var i = 0; i < this.frameCount; i++) { this.newFrame += (this.animDelta * (this.tweenAmount[i] / 100)); this.frames[i] = this.newFrame } this.frames[this.frameCount - 1] = this.points.to; doAnim(this) }; function doAnim(a) { a.obj1.style.left = Math.ceil(a.frames[a.currentFrame]) + "px"; a.obj2.style.zIndex = 100; a.obj1.style.zIndex = 100; if (a.points.to < a.points.from) { a.obj2.style.left = Number(a.obj1.offsetWidth) + Math.ceil(a.frames[a.currentFrame]) + "px" } else { a.obj2.style.left = Math.ceil(a.frames[a.currentFrame]) - Number(a.obj1.offsetWidth) + "px" } a.currentFrame++; if (a.currentFrame >= a.frameCount) { a.currentFrame = 0; clearTimeout(a.delayTimerId); a.delayTimerId = null; window[a.obj1.slideId].blocked = false } else { a.delayTimerId = setTimeout(function() { doAnim(a) }, a.speed) } };
