Type.registerNamespace('SpottedScript.Controls.Banners.Generator');
SpottedScript.Controls.Banners.Generator.BannerRenderInfoType=function(){};SpottedScript.Controls.Banners.Generator.BannerRenderInfoType.prototype = {flash:1,html:2}
SpottedScript.Controls.Banners.Generator.BannerRenderInfoType.registerEnum('SpottedScript.Controls.Banners.Generator.BannerRenderInfoType',false);SpottedScript.Controls.Banners.Generator.BannerRenderInfo=function(){}
SpottedScript.Controls.Banners.Generator.BannerRenderInfo.prototype={bannerRenderInfoType:0,k:0,flashUrl:null,height:0,width:0,html:null,duration:0,miscNeedsClickHelper:false,flashVersion:null,linkTag:null,targetTag:null}
SpottedScript.Controls.Banners.Generator.Controller=function(view){this.$0=view;this.$2=Number.parseInvariant(this.$0.get_uiPosition().value);this.$1=Number.parseInvariant(this.$0.get_uiDuration().value);if(this.$0.get_uiK().value.length>0){this.$F=Number.parseInvariant(this.$0.get_uiK().value);this.$B();}window.setInterval(Function.createDelegate(this,this.$9),15000);if(!SpottedScript.Controls.Banners.Generator.Controller.$5){$addHandler(window.self,'keydown',Function.createDelegate(this,this.$7));$addHandler(window.self,'scroll',Function.createDelegate(this,this.$7));$addHandler(document.body,'click',Function.createDelegate(this,this.$7));SpottedScript.Controls.Banners.Generator.Controller.$5=true;}this.$6=Number.parseInvariant(this.$0.get_uiInactivityTimeoutDuration().value);this.oldRefreshBanners=SpottedScript.Controls.Banners.Generator.Controller.refreshAllBanners;SpottedScript.Controls.Banners.Generator.Controller.refreshAllBanners=Function.createDelegate(this,function(){
this.$D();if(this.oldRefreshBanners){this.oldRefreshBanners();}});}
SpottedScript.Controls.Banners.Generator.Controller.prototype={$0:null,$1:0,$2:0,$3:0,$6:0,oldRefreshBanners:null,$7:function($p0){Utils.Trace.write('User action');this.$A();},stopped:false,$9:function(){SpottedScript.Controls.Banners.Generator.Controller.$8+=15000;if(!this.stopped&&this.$6<SpottedScript.Controls.Banners.Generator.Controller.$8){Utils.Trace.write('User inactive. Stopping banner rotation');window.clearTimeout(this.$3);this.stopped=true;}},$A:function(){SpottedScript.Controls.Banners.Generator.Controller.$8=0;if(this.stopped){Utils.Trace.write('User active. Active banner rotation');this.$B();}},$B:function(){this.stopped=false;if(this.$1>0){this.$3=window.setTimeout(Function.createDelegate(this,this.$C),this.$1);}},$C:function(){Utils.Trace.write('Requesting new banners');if(this.$E()){this.$D();}else{this.$B();}},$D:function(){if(this.$2!==1&&this.$2!==2&&this.$2!==5){return;}try{window.clearTimeout(this.$3);Spotted.WebServices.Controls.Banners.Generator.Service.getBanner(this.$2,this.$0.get_uiPlaceKs().value,this.$0.get_uiMusicTypes().value,Function.createDelegate(this,this.$10),Function.createDelegate(null,Utils.Trace.webServiceFailure),null,5000);}catch($0){Utils.Trace.write($0.toString());Utils.Trace.write($0.message);}},$E:function(){var $0=document.body.scrollTop;var $1=jQuery(this.$0.get_uiBanner());return $0<$1.offset().top+$1.height();},$F:0,$10:function($p0,$p1,$p2){if($p0){if(this.$F!==$p0.k){this.$1=$p0.duration;$clearHandlers(this.$0.get_uiBanner());if($p0.bannerRenderInfoType===1){var $0=this.$0.get_uiBanner().id;var $1=new SWFObject($p0.flashUrl,$0+'_movie',$p0.width,$p0.height,$p0.flashVersion,'#ffffff');$1.addParam('wmode','transparent');$1.addParam('AllowScriptAccess','always');$1.addVariable('targetTag',$p0.targetTag);$1.addVariable('linkTag',$p0.linkTag);$1.addParam('loop','true');$1.addParam('menu','false');$1.write($0);if($p0.miscNeedsClickHelper){Utils.Trace.write('linkTag'+$p0.linkTag);var $2=document.createElement('DIV');$2.style.left=(0+Number.parseInvariant(this.$0.get_uiClickHelperLeft().value))+'px';$2.style.top=(0+Number.parseInvariant(this.$0.get_uiClickHelperLeft().value))+'px';$2.style.position='absolute';$2.style.zIndex=1;var $3=document.createElement('A');$3.href=$p0.linkTag;$3.target=$p0.targetTag;$3.style.border='solid 0px black';$3.className='NoStyle';var $4=document.createElement('IMG');$4.style.width=$p0.width+'px';$4.style.height=$p0.height+'px';$4.style.border='solid 0px black';$4.style.display='block';$4.src='/gfx/1pix.gif';$3.appendChild($4);$2.appendChild($3);this.$0.get_uiBanner().appendChild($2);}this.$F=$p0.k;}else{document.getElementById(this.$0.get_uiBanner().id).innerHTML=$p0.html;}$addHandler(this.$0.get_uiBanner(),'mouseover',Function.createDelegate(this,this.$11));}}else{}this.$B();},$11:function($p0){window.clearTimeout(this.$3);$clearHandlers(this.$0.get_uiBanner());}}
SpottedScript.Controls.Banners.Generator.View=function(clientId){this.clientId=clientId;}
SpottedScript.Controls.Banners.Generator.View.prototype={clientId:null,get_holder:function(){return document.getElementById(this.clientId+'_Holder');},get_uiBanner:function(){return document.getElementById(this.clientId+'_uiBanner');},get_uiPosition:function(){return document.getElementById(this.clientId+'_uiPosition');},get_uiK:function(){return document.getElementById(this.clientId+'_uiK');},get_uiMusicTypes:function(){return document.getElementById(this.clientId+'_uiMusicTypes');},get_uiPlaceKs:function(){return document.getElementById(this.clientId+'_uiPlaceKs');},get_uiDuration:function(){return document.getElementById(this.clientId+'_uiDuration');},get_uiInactivityTimeoutDuration:function(){return document.getElementById(this.clientId+'_uiInactivityTimeoutDuration');},get_uiClickHelperLeft:function(){return document.getElementById(this.clientId+'_uiClickHelperLeft');},get_uiClickHelperTop:function(){return document.getElementById(this.clientId+'_uiClickHelperTop');}}
SpottedScript.Controls.Banners.Generator.BannerRenderInfo.registerClass('SpottedScript.Controls.Banners.Generator.BannerRenderInfo');
SpottedScript.Controls.Banners.Generator.Controller.registerClass('SpottedScript.Controls.Banners.Generator.Controller');
SpottedScript.Controls.Banners.Generator.View.registerClass('SpottedScript.Controls.Banners.Generator.View');
SpottedScript.Controls.Banners.Generator.Controller.$5=false;
SpottedScript.Controls.Banners.Generator.Controller.refreshAllBanners=null;
SpottedScript.Controls.Banners.Generator.Controller.$8=0;
