
var pl4ying="false";var Show4ll="false";var w1dth="450px";var l3ft="0";var LatestNewsBanner=new Class({initialize:function(params){this.items=params.items;this.mode=params.mode||'horizontal';this.modes={horizontal:['left','width'],vertical:['top','height']};this.size=params.size||240;this.box=params.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+'px');this.button_event=params.button_event||'click';this.handle_event=params.handle_event||'click';this.onWalk=params.onWalk||null;this.currentIndex=null;this.previousIndex=null;this.nextIndex=null;this.interval=params.interval||5000;this.autoPlay=params.autoPlay||false;this.LNplay=null;this.handles=params.handles||null;if(this.handles){this.addHandleButtons(this.handles);}
this.buttons={previous:[],next:[],play:[],stop:[],showall:[]};if(params.addButtons){for(var action in params.addButtons){this.addActionButtons(action,$type(params.addButtons[action])=='array'?params.addButtons[action]:[params.addButtons[action]]);}}
this.fx=new Fx.Tween(this.box,$extend((params.fxOptions||{duration:500,wait:false}),{property:this.modes[this.mode][0]}));this.walk((params.startItem||0),true,true);},addHandleButtons:function(handles){for(var i=0;i<handles.length;i++){handles[i].addEvent(this.handle_event,this.walk.bind(this,[i,true]));handles[i].removeAttribute("href");}},addActionButtons:function(action,buttons){for(var i=0;i<buttons.length;i++){buttons[i].removeAttribute("href");switch(action){case'previous':buttons[i].addEvent(this.button_event,this.previous.bind(this,[true]));break;case'next':buttons[i].addEvent(this.button_event,this.next.bind(this,[true]));break;case'play':buttons[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'next',false]));break;case'stop':buttons[i].addEvent(this.button_event,this.stop.bind(this));break;case'showall':buttons[i].addEvent(this.button_event,this.showall.bind(this));break;}
this.buttons[action].push(buttons[i]);}},previous:function(manual){this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),manual);},next:function(manual){this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),manual);},play:function(interval,direction,wait){if(pl4ying=="false"){this.stop();if(!wait){this[direction](false);}
document.id('NewsBtn').setProperties({src:'img/pause.gif',alt:'pause news items',title:'pause news items'});document.id('NewsToggle').setProperty('title','pause news items');pl4ying="true";this.LNplay=this[direction].periodical(interval,this,[false]);}else{document.id('NewsBtn').setProperties({src:'img/play.gif',alt:'play news items',title:'play news items'});document.id('NewsToggle').setProperty('title','play news items');$clear(this.LNplay);pl4ying="false";}},stop:function(){$clear(this.LNplay);},showall:function(){if(Show4ll=="false"){w1dth=document.id('LatestNewsBox').getStyle('width');l3ft=document.id('LatestNewsBox').getStyle('left');$clear(this.LNplay);document.id('LatestNewsSurround').setProperty('class','ShowAllNews');document.id('LatestNewsBox').setStyles({width:460,height:0});document.id('showall').set('text','Return to slide show');document.id('showall').setProperty('title','Return to slide show');Show4ll="true";}else{document.id('LatestNewsSurround').setProperty('class','newsbanner');document.id('LatestNewsBox').setStyle(this.modes[this.mode][1],(this.size*this.items.length)+'px');document.id('showall').set('text','Show All');document.id('showall').setProperty('title','Show All');document.id('LatestNewsBox').setStyles({width:w1dth,left:l3ft});Show4ll="false";document.id('NewsBtn').setProperties({src:'img/play.gif',alt:'play news items',title:'play news items'});document.id('NewsToggle').setProperty('title','play news items');}},walk:function(item,manual,noFx){if(item!=this.currentIndex){this.currentIndex=item;this.previousIndex=this.currentIndex+(this.currentIndex>0?-1:this.items.length-1);this.nextIndex=this.currentIndex+(this.currentIndex<this.items.length-1?1:1-this.items.length);if(manual){this.stop();}
if(noFx){this.fx.cancel().set((this.size*-this.currentIndex)+'px');}else{this.fx.start(this.size*-this.currentIndex);}
if(manual&&this.autoPlay){this.play(this.interval,'next',true);}
if(this.onWalk){this.onWalk((this.items[this.currentIndex]||null),(this.handles&&this.handles[this.currentIndex]?this.handles[this.currentIndex]:null));}}}});var InFocusPart=InFocusPart||{};InFocusPart.Rotater=new Class({Implements:[Options,Events],options:{transitionDuration:180,startIndex:0},initialize:function(slides,options){this.setOptions(options);this.slides=$$(slides);this.createFx();this.showSlide(this.options.startIndex);return this;},toElement:function(){return this.container;},createFx:function(){if(!this.slideFx)this.slideFx=new Fx.Elements(this.slides,{duration:this.options.transitionDuration});this.slides.each(function(slide){slide.setStyle('opacity',0);});},showSlide:function(slideIndex){var action={};this.slides.each(function(slide,index){if(index==slideIndex&&index!=this.currentSlide){action[index.toString()]={opacity:1};}else{action[index.toString()]={opacity:0};}},this);this.fireEvent('onShowSlide',slideIndex);this.currentSlide=slideIndex;this.slideFx.start(action);return this;},stop:function(){$clear(this.slideshowInt);this.fireEvent('onStop');return this;},rotate:function(){current=this.currentSlide;next=(current+1>=this.slides.length)?0:current+1;this.showSlide(next);this.fireEvent('onRotate',next);return this;}});InFocusPart.Tabs=new Class({Extends:InFocusPart.Rotater,options:{transitionDuration:180,hash:true},initialize:function(tabs,slides,options){this.setOptions(options);this.tabs=$$(tabs+' li');this.tabsA=$$(tabs+' a');this.createTabs();if(this.options.hash&&window.location.hash){var hash=window.location.hash.substring(1);this.tabsA.each(function(el,index){if(el.id==hash){options.startIndex=index;}});}
this.parent(slides,options);return this;},createTabs:function(){this.tabsA.each(function(tab,index){tab.addEvent('mouseenter',function(event){event.stop();this.showSlide(index);this.stop();}.bind(this));tab.addEvent('focus',function(event){event.stop();this.showSlide(index);this.stop();}.bind(this));}.bind(this));},activateTab:function(tabIndex){this.tabs.removeClass('active');this.tabsA.removeClass('active');this.tabs[tabIndex].addClass('active');this.tabsA[tabIndex].addClass('active');},showSlide:function(slideIndex){if(slideIndex==this.currentSlide)return;this.activateTab(slideIndex);this.parent(slideIndex);return this;}});
