if("undefined"==typeof ContentPlayer)var ContentPlayer={};var Observable=(function(){function $($){if($&&typeof $=="object"&&$.handleMessage)this.observers.push($)}function _($){var _=this.observers;for(var A=0;A<_.length;A++)_[A].handleMessage($)}return{addObserver:$,notify:_}})();function implement(_,$){for(var A in _)$[A]=_[A]}ContentPlayer.View=function($){this.container=$.container;this.data=$.data||null;this.tpl=$.tpl||"";this.curIndex=$.curIndex||0;this.needFadeIn=$.needFadeIn||false;this.observers=[];this.fadeInTimer=0;this.initOpacity=0.1;this.curOpacity=0.1;this.opacityDiff=0.1};ContentPlayer.View.prototype.init=function(){this.registerEvent();this.render()};ContentPlayer.View.prototype.registerEvent=function(){var $=this;on(this.container,"mouseover",function(_){$.notify({type:"STOP"})});on(this.container,"mouseout",function(_){$.notify({type:"PLAY",param:{step:1}})})};ContentPlayer.View.prototype.render=function(){this.container.innerHTML=Fe.format(this.tpl,this.data[this.curIndex])};ContentPlayer.View.prototype.fadeIn=function(){var $=this;window.clearInterval(this.fadeInTimer);this.curOpacity=this.initOpacity;this.fadeInTimer=window.setInterval(function(){var _;_=$.opacityDiff;if(Fe.Browser.isIE){if($.curOpacity<1){$.curOpacity+=_;$.container.style.filter="alpha(opacity="+$.curOpacity*100+")"}else{$.curOpacity=1;$.container.style.filter="alpha(opacity="+$.curOpacity*100+")";window.clearInterval(this.fadeInTimer)}}else if($.curOpacity<1){$.curOpacity+=_;$.container.style.opacity=$.curOpacity}else{$.curOpacity=1;$.container.style.opacity=$.curOpacity;window.clearInterval(this.fadeInTimer)}},50)};ContentPlayer.View.prototype.handleMessage=function($){var B,A,_,C,D,E;B=this.data;A=this.tpl;_=this.curIndex;C=B.length;switch($.type){case"NEXT":D=$.param.step;_=(_+D)%C;break;case"PREV":D=$.param.step;_=(C+_-D)%C;break;case"GOTO":E=$.param.index;_=E%C;break;default:return}this.curIndex=_;this.render();if(this.needFadeIn)this.fadeIn()};implement(Observable,ContentPlayer.View.prototype);ContentPlayer.ControlPanel=function($){this.getBtns=$.getBtns||function(){return[]};this.data=$.data||[];this.curIndex=$.curIndex||0;this.style=$.style||null;this.observers=[];this.imgCache=window[Math.random()]=[]};ContentPlayer.ControlPanel.prototype.init=function(){this.registerEvent();this.setStyle();this.imgPreload()};ContentPlayer.ControlPanel.prototype.next=function(A){var _,$;_=this.data.length;$=this.curIndex;this.curIndex=(_+$+A)%_;this.setStyle();this.notify({type:"NEXT",param:{step:A}})};ContentPlayer.ControlPanel.prototype.prev=function(A){var _,$;_=this.data.length;$=this.curIndex;this.curIndex=(_+$-A)%_;this.setStyle();this.notify({type:"PREV",param:{step:A}})};ContentPlayer.ControlPanel.prototype.go=function(){this.setStyle();this.notify({type:"GOTO",param:{index:this.curIndex}})};ContentPlayer.ControlPanel.prototype.registerEvent=function(){var $,_;_=this;$=this.getBtns();for(var A=0;A<$.length;A++)(function(){var C=$[A],B=A;on(C,"mousedown",function($){_.curIndex=B;_.setStyle();_.go()});on(C,"mouseover",function($){_.notify({type:"STOP"})});on(C,"mouseout",function($){_.notify({type:"PLAY",param:{step:1}})})})()};ContentPlayer.ControlPanel.prototype.setStyle=function(){var $;$=this.getBtns();for(var A=0,_=$.length;A<_;A++)if(A!=this.curIndex)$[A].className=this.style.off;else $[A].className=this.style.on};ContentPlayer.ControlPanel.prototype.handleMessage=function($){};ContentPlayer.ControlPanel.prototype.imgPreload=function(){var _,$;_=this.data;for(var A=0;A<_.length;A++)if(_[A].imgUrl){$=new Image();$.src=_[A].imgUrl;this.imgCache.push($)}};implement(Observable,ContentPlayer.ControlPanel.prototype);ContentPlayer.Model=function($){this.interval=$.interval||4000;$.container=$.mainViewContainer;$.tpl=$.mainViewTpl;$.needFadeIn=false;this.mv=new ContentPlayer.View($);$.container=$.subViewContainer;$.tpl=$.subViewTpl;$.needFadeIn=false;this.sv=new ContentPlayer.View($);this.cp=new ContentPlayer.ControlPanel($);this.timerId=0;this.observers=[];this.init()};ContentPlayer.Model.prototype.init=function(){this.mv.init();this.sv.init();this.cp.init();this.cp.addObserver(this.mv);this.cp.addObserver(this.sv);this.cp.addObserver(this);this.mv.addObserver(this);this.sv.addObserver(this)};ContentPlayer.Model.prototype.play=function(_){var $=this;this.stop();this.timerId=window.setInterval(function(){$.cp.next(_)},this.interval)};ContentPlayer.Model.prototype.stop=function(){window.clearInterval(this.timerId)};ContentPlayer.Model.prototype.handleMessage=function($){switch($.type){case"STOP":this.stop();break;case"PLAY":this.play($.param.step);break}}
