﻿var Hash = function(h) { this._data = new Object() }; function Hash$add(key, value) { if (!key || typeof (value) === 'undefined') return false; this._data[key] = { key: key, value: value }; return true }; function Hash$getItem(key) { if (!key) return undefined; var item = this._data[key]; if (typeof (item) !== 'undefined') { return item.value } else { delete this._data[key]; return undefined } }; Hash.prototype = { _data: null, _keys: null, add: Hash$add, get: Hash$getItem }; Hash.__typeName = 'Hash'; Hash.__class = true; var speed = 30; var isMSIE = (navigator.appName == "Microsoft Internet Explorer"); function getElementsByPath(path) { var temp = []; if (typeof (path) == "string") { var par = { element: "", att: "" }; par.element = path.split(".")[0]; par.att = path.split(".")[1] } else { return } var elements = document.getElementsByTagName(par.element); for (var i = 0, len = elements.length; i < len; i++) { if (elements[i].getAttribute(par.att)) { temp.push(elements[i]) } } return temp } function abstractad(ele) { if (!ele) return } abstractad.prototype.move = function() { }; function adUp(ele) { this.base = abstractad; var ref = this; this.iScrollAmount = 1; this.oMarquee = ele; this.oMarquee.style.cssText = "text-align:left;margin:0px;padding:0px;border:1px;overflow:hidden;white-space:nowrap;"; this.content = this.oMarquee.innerHTML; this.omqdemo = document.createElement("div"); this.omqdemo.style.cssText = "margin:0px;padding:0px;border:0px;"; this.oMarquee.innerHTML = ""; this.omqdemo.innerHTML = ref.content; this.oMarquee.appendChild(this.omqdemo); this.w = this.oMarquee.offsetHeight; this.odl = this.omqdemo.offsetHeight; var x = parseInt(this.w / this.odl) + 1; for (var i = 0; i < x; i++) { var o = this.omqdemo.cloneNode(true); this.oMarquee.appendChild(o) } } adUp.prototype = new abstractad(); adUp.prototype.move = function() { this.oMarquee.scrollTop += this.iScrollAmount; var ol = this.oMarquee.scrollTop; if (this.odl - ol <= 0) { this.oMarquee.scrollTop = 0 } }; function adDown(ele) { this.base = abstractad; var ref = this; this.iScrollAmount = 1; this.oMarquee = ele; this.oMarquee.style.cssText = "text-align:left;margin:0px;padding:0px;border:1px;overflow:hidden;white-space:nowrap;"; this.content = this.oMarquee.innerHTML; this.omqdemo = document.createElement("div"); this.omqdemo.style.cssText = "margin:0px;padding:0px;border:0px;"; this.oMarquee.innerHTML = ""; this.omqdemo.innerHTML = ref.content; this.oMarquee.appendChild(this.omqdemo); this.w = this.oMarquee.offsetHeight; this.odl = this.omqdemo.offsetHeight; var x = parseInt(this.w / this.odl) + 1; for (var i = 0; i < x; i++) { var o = this.omqdemo.cloneNode(true); this.oMarquee.appendChild(o) } } adDown.prototype = new abstractad(); adDown.prototype.move = function() { this.oMarquee.scrollTop -= this.iScrollAmount; var ol = this.oMarquee.scrollTop; if (this.odl - ol >= ol) { this.oMarquee.scrollTop = 10000 } }; function adLeft(ele) { var ref = this; this.iScrollAmount = 1; this.oMarquee = ele; this.oMarquee.style.cssText = "line-height:30px;text-align:left;margin:0px;padding:0px;border:1px;overflow:hidden;white-space:nowrap;"; this.content = ref.oMarquee.innerHTML; this.omqdemo = document.createElement("span"); this.omqdemo.style.cssText = "margin:0px;padding:0px;border:0px;"; this.omqdemo.innerHTML = ref.content; this.oMarquee.innerHTML = ""; this.oMarquee.appendChild(ref.omqdemo); this.w = this.oMarquee.offsetWidth; this.odl = this.omqdemo.offsetWidth; var x = parseInt(ref.w / ref.odl) + 1; for (var i = 0; i < x; i++) { var o = this.omqdemo.cloneNode(true); this.oMarquee.appendChild(o) } } adLeft.prototype = new abstractad(); adLeft.prototype.move = function() { this.oMarquee.scrollLeft += this.iScrollAmount; var ol = this.oMarquee.scrollLeft; if (isMSIE) { if (this.odl - ol <= 0) { this.oMarquee.scrollLeft = 0 } } else { if (this.odl - ol <= -10) { this.oMarquee.scrollLeft = 2 } } }; function adRight(ele) { var ref = this; this.iScrollAmount = 1; this.oMarquee = ele; this.oMarquee.style.cssText = "line-height:30px;text-align:left;margin:0px;padding:0px;border:1px;overflow:hidden;white-space:nowrap;"; this.content = ref.oMarquee.innerHTML; this.omqdemo = document.createElement("span"); this.omqdemo.style.cssText = "margin:0px;padding:0px;border:0px;"; this.omqdemo.innerHTML = ref.content; this.oMarquee.innerHTML = ""; this.oMarquee.appendChild(ref.omqdemo); this.w = this.oMarquee.offsetWidth; this.odl = this.omqdemo.offsetWidth; var x = parseInt(ref.w / ref.odl) + 1; for (var i = 0; i < x; i++) { var o = this.omqdemo.cloneNode(true); this.oMarquee.appendChild(o) } } adRight.prototype = new abstractad(); adRight.prototype.move = function() { this.oMarquee.scrollLeft -= this.iScrollAmount; var ol = this.oMarquee.scrollLeft; if (isMSIE) { if (this.odl - ol >= this.odl) { this.oMarquee.scrollLeft = 2000 } } else { if (this.odl - ol >= this.odl) { this.oMarquee.scrollLeft = 2000 } } }; function floatLeft(ele) { this.obj = ele; this.obj.style.cssText = "left:0px;POSITION:absolute;TOP:10px;"; this.lastScrollY = 0 } floatLeft.prototype = new abstractad(); floatLeft.prototype.move = function() { var diffY = document.documentElement.scrollTop; var percent1 = .1 * (diffY - this.lastScrollY); if (percent1 > 0) { percent1 = Math.ceil(percent1) } else { percent1 = Math.floor(percent1) } curY = Math.ceil(this.obj.style.top.replace(/px/, " ")); curY += percent1; this.obj.style.top = curY + "px"; this.lastScrollY = this.lastScrollY + percent1 }; function floatRight(ele) { this.obj = ele; this.obj.style.cssText = "right:0px;POSITION:absolute;TOP:10px;"; this.lastScrollY = 0 } floatRight.prototype = new abstractad(); floatRight.prototype.move = function() { var diffY = document.documentElement.scrollTop; var percent = .1 * (diffY - this.lastScrollY); if (percent > 0) { percent = Math.ceil(percent) } else { percent = Math.floor(percent) } curY = Math.ceil(this.obj.style.top.replace(/px/, " ")); curY += percent; this.obj.style.top = curY + "px"; this.lastScrollY = this.lastScrollY + percent }; function floatad(ele) { this.obj = ele; this.xPos = 300; this.yPos = 200; this.step = 1; this.height = 0; this.Hoffset = 0; this.Woffset = 0; this.yon = 0; this.xon = 0; this.interval; this.obj.style.cssText = "Z-INDEX: 100; LEFT: 2px; POSITION: absolute; TOP: 43px;visibility: visible;"; this.obj.style.top = this.yPos + "px" } floatad.prototype = new abstractad(); floatad.prototype.move = function() { var width = document.documentElement.clientWidth; this.height = document.documentElement.clientHeight; this.Hoffset = this.obj.offsetHeight; this.Woffset = this.obj.offsetWidth; this.obj.style.left = this.xPos + document.documentElement.scrollLeft + "px"; this.obj.style.top = this.yPos + document.documentElement.scrollTop + "px"; if (this.yon) { this.yPos = this.yPos + this.step } else { this.yPos = this.yPos - this.step } if (this.yPos < 0) { this.yon = 1; this.yPos = 0 } if (this.yPos >= (this.height - this.Hoffset)) { this.yon = 0; this.yPos = (this.height - this.Hoffset) } if (this.xon) { this.xPos = this.xPos + this.step } else { this.xPos = this.xPos - this.step } if (this.xPos < 0) { this.xon = 1; this.xPos = 0 } if (this.xPos >= (width - this.Woffset)) { this.xon = 0; this.xPos = (width - this.Woffset) } }; function adfac() { } adfac.prototype.getinstance = function(style, i) { var ht = new Hash(); switch (style) { case "up": ht.add(i, new adUp(getElementsByPath("div.adstyle")[i - 1])); var MyMar = setInterval(function() { ht.get(i).move() }, speed); getElementsByPath("div.adstyle")[i - 1].onmouseover = function() { clearInterval(MyMar) }; getElementsByPath("div.adstyle")[i - 1].onmouseout = function() { MyMar = setInterval(function() { ht.get(i).move() }, speed) }; break; case "down": ht.add(i, new adDown(getElementsByPath("div.adstyle")[i - 1])); var MyMar = setInterval(function() { ht.get(i).move() }, speed); getElementsByPath("div.adstyle")[i - 1].onmouseover = function() { clearInterval(MyMar) }; getElementsByPath("div.adstyle")[i - 1].onmouseout = function() { MyMar = setInterval(function() { ht.get(i).move() }, speed) }; break; case "left": ht.add(i, new adLeft(getElementsByPath("div.adstyle")[i - 1])); var MyMar = setInterval(function() { ht.get(i).move() }, speed); getElementsByPath("div.adstyle")[i - 1].onmouseover = function() { clearInterval(MyMar) }; getElementsByPath("div.adstyle")[i - 1].onmouseout = function() { MyMar = setInterval(function() { ht.get(i).move() }, speed) }; break; case "right": ht.add(i, new adRight(getElementsByPath("div.adstyle")[i - 1])); var MyMar = setInterval(function() { ht.get(i).move() }, speed); getElementsByPath("div.adstyle")[i - 1].onmouseover = function() { clearInterval(MyMar) }; getElementsByPath("div.adstyle")[i - 1].onmouseout = function() { MyMar = setInterval(function() { ht.get(i).move() }, speed) }; break; case "fleft": ht.add(i, new floatLeft(getElementsByPath("div.adstyle")[i - 1])); setInterval(function() { ht.get(i).move() }, 1); break; case "fright": ht.add(i, new floatRight(getElementsByPath("div.adstyle")[i - 1])); setInterval(function() { ht.get(i).move() }, 1); break; case "float": ht.add(i, new floatad(getElementsByPath("div.adstyle")[i - 1])); var MyMar = setInterval(function() { ht.get(i).move() }, speed); getElementsByPath("div.adstyle")[i - 1].onmouseover = function() { clearInterval(MyMar) }; getElementsByPath("div.adstyle")[i - 1].onmouseout = function() { MyMar = setInterval(function() { ht.get(i).move() }, speed) }; break } }; window.onload = function() { var fac = new adfac(); var t = getElementsByPath("div.adstyle"); for (var i = 0, le = t.length; i < le; i++) { var str = t[i].getAttribute("adstyle"); fac.getinstance(str, i + 1) } };