
function __addEventListener(El,name,Callback){if(El.addEventListener!=null){El.addEventListener(name,Callback,false);}
else if(El.attachEvent!=null){El.attachEvent('on'+name,Callback);}
else{El['on'+name]=Callback;}}
function RotatingHeadlines(Id,defaultIdx){try{this.init(Id,defaultIdx);}
catch(ignore){var Me=this;var initClosure=function(){Me.init(Id,defaultIdx)}
__addEventListener(window,'load',initClosure);}}
RotatingHeadlines.prototype.panels=[];RotatingHeadlines.prototype.delay=7000;RotatingHeadlines.prototype.timerId=null;RotatingHeadlines.prototype.currentIdx;RotatingHeadlines.prototype.init=function(Id,defaultIdx){var elDiv=document.getElementById(Id);if(elDiv==null){throw'no element '+Id;}
var divs=elDiv.getElementsByTagName('DIV');for(var i=0;i<divs.length;i++){var elPanel=divs[i];if(elPanel.className.indexOf('panel')===0){var Panel=new HeadlinePanel(elPanel);if(this.panels.length!==defaultIdx){Panel.showPrepare();}
this.panels.push(Panel);}}
this.currentIdx=defaultIdx;this.startTimer();}
RotatingHeadlines.prototype.startTimer=function(){this.stopTimer();var Me=this;var intervalClosure=function(){Me.onInterval();}
this.timerId=setInterval(intervalClosure,this.delay);}
RotatingHeadlines.prototype.stopTimer=function(){if(this.timerId!=null){clearInterval(this.timerId);this.timerId=null;}}
RotatingHeadlines.prototype.onInterval=function(){this.nextPanel();}
RotatingHeadlines.prototype.nextPanel=function(){if(this.currentIdx==null){var nextIdx=0;}
else{var nextIdx=this.currentIdx+1;if(nextIdx===this.panels.length){nextIdx=0;}
var currentPanel=this.panels[this.currentIdx];currentPanel.hide();}
var Panel=this.panels[nextIdx];Panel.show();this.currentIdx=nextIdx;}
RotatingHeadlines.prototype.goPanel=function(index){if(this.currentIdx===index){return false;}
this.stopTimer();var currentPanel=this.panels[this.currentIdx];currentPanel.hide();var Panel=this.panels[index];Panel.show();this.currentIdx=index;return true;}
function HeadlinePanel(elDiv){this.id=elDiv.id;this.elDiv=elDiv;}
HeadlinePanel.prototype.show=function(){this.showPrepare();new Effect.Move(this.elDiv,{x:0,y:0,mode:'absolute'});}
HeadlinePanel.prototype.hide=function(){this.setDepth(0);new Effect.Opacity(this.elDiv,{duration:1.0,transition:Effect.Transitions.linear,from:1,to:0});}
HeadlinePanel.prototype.showPrepare=function(){this.elDiv.style.left='600px';new Effect.Opacity(this.elDiv,{duration:0,from:1,to:1});this.setDepth(1);}
HeadlinePanel.prototype.setDepth=function(z){this.elDiv.style.zIndex=z;}