var bannerAds=Class.create();bannerAds.prototype={initialize:function(c,a,b){this.options=Object.extend({updateTime:15,reshuffleAtComplete:false,flashContainerPath:"hitcontainer.swf",flashInstallerPath:"expressInstall.swf",width:"180",height:"150",className:"ad"},b||{});this.options.anchorExtra=Object.extend({target:"_blank"},this.options.anchorExtra||{});this.options.imageExtra=Object.extend({},this.options.imageExtra||{});this.feedUrl=c;this.feedIds=a||[];this.count=0;this.adObjs=[];this.randObj=null;this.updateTime=this.options.updateTime;this.stopAdCycle=false;this.histogram={"'":"%27","(":"%28",")":"%29","*":"%2A","~":"%7E","!":"%21","%20":"+","\u00DC":"%DC","\u00FC":"%FC","\u00C4":"%D4","\u00E4":"%E4","\u00D6":"%D6","\u00F6":"%F6","\u00DF":"%DF","\u20AC":"%80","\u0081":"%81","\u201A":"%82","\u0192":"%83","\u201E":"%84","\u2026":"%85","\u2020":"%86","\u2021":"%87","\u02C6":"%88","\u2030":"%89","\u0160":"%8A","\u2039":"%8B","\u0152":"%8C","\u008D":"%8D","\u017D":"%8E","\u008F":"%8F","\u0090":"%90","\u2018":"%91","\u2019":"%92","\u201C":"%93","\u201D":"%94","\u2022":"%95","\u2013":"%96","\u2014":"%97","\u02DC":"%98","\u2122":"%99","\u0161":"%9A","\u203A":"%9B","\u0153":"%9C","\u009D":"%9D","\u017E":"%9E","\u0178":"%9F"};this._initBehavior();this._initAjax()},setCount:function(a){this.count=a;this._initRandomizer()},_getFeedCount:function(){return this.feedIds.length},getCount:function(){return this.count},_initRandomizer:function(){this.randObj=new randomNumberPool(0,this.getCount()-1,this.options.reshuffleAtComplete)},_initUpdateTimer:function(){this._nextAd();if(this._getFeedCount()<this.getCount()){new PeriodicalExecuter(this._nextAd.bindAsEventListener(this),this.updateTime)}},_initAjax:function(){this._callAjax()},_nextAd:function(){if(this.stopAdCycle){return}for(var a,b=0;b<this._getFeedCount();b++){a=this.randObj.next();this._setAd(this.feedIds[b],this.adObjs[a])}},_setAd:function(f,b){if(b.flash){swfobject.embedSWF(this.options.flashContainerPath,f,this.options.width,this.options.height,"6.0.0",this.options.flashInstallerPath,{u:b.url,m:b.img},{wmode:"opaque",bgcolor:"#FFFFFF",scale:"noscale"},{"class":this.options.className})}else{var e=new Element("div");e.id=f;e.className=this.options.className;var c=new Element("a");for(var d in this.options.anchorExtra){c[d]=this.options.anchorExtra[d]}c.href=b.url;c.insert(b.obj,"bottom");e.insert(c,"bottom");this._addDefaultHandlers(e);$(f).replace(e)}},_isFlash:function(a){return a.substr(a.length-4).toLowerCase()==".swf"},_initBehavior:function(){for(var a=0;a<this.feedIds.length;a++){this._addDefaultHandlers($(this.feedIds[a]))}},_addDefaultHandlers:function(a){a.observe("mouseover",this._mouseOverResponse.bindAsEventListener(this));a.observe("mouseout",this._mouseOutResponse.bindAsEventListener(this))},_mouseOverResponse:function(){this.stopRotation()},_mouseOutResponse:function(){this.startRotation()},stopRotation:function(){this.stopAdCycle=true},startRotation:function(){this.stopAdCycle=false},_callAjax:function(){new Ajax.Request(this.feedUrl,{method:"get",onSuccess:this._ajaxResponse.bindAsEventListener(this),onFailure:this._ajaxError,asynchronous:true})},_ajaxResponse:function(e){var c=e.responseXML;if(c&&c.getElementsByTagName("feeds").length>0){var a=c.getElementsByTagName("feeds")[0];if(!a.getAttribute("count")||!a.getElementsByTagName("feed")){return}this.setCount(a.getAttribute("count"));a=a.getElementsByTagName("feed");for(var d=0;d<this.getCount();d++){this.adObjs[d]=this._createImageObject(this._urldecode(a[d].getAttribute("url")),a[d].getAttribute("img"))}if(this.getCount()<this._getFeedCount()){for(var f=null,b=0,d=this.getCount();d<this._getFeedCount();d++){b=this.randObj.next();f=this.adObjs[b];this.adObjs[d]=this._createImageObject(f.url,f.img)}this.setCount(this._getFeedCount())}this._initUpdateTimer()}},_createImageObject:function(a,d){var c={url:a,img:d,flash:d!=""&&this._isFlash(d),obj:null};if(!c.flash){c.obj=new Image(180,150);for(var b in this.options.imageExtra){c[b]=this.options.imageExtra[b]}c.obj.src=d}return c},_ajaxError:function(a){},_replaceStr:function(b,a,d){var c=[];c=d.split(b);return c.join(a)},_urldecode:function(c){var b=c.toString(),a="";for(a in this.histogram){b=this._replaceStr(this.histogram[a],a,b)}return decodeURIComponent(b)}};