var Site={start:function(){if($('accordion'))Site.showAccordion();},showAccordion:function(){$('accordion').style['display']="block";var accordion=new Accordion('h3.atStart','div.atStart',{opacity:false,show:0,alwaysHide:true,onActive:function(toggler,element){toggler.setStyle('color','#FF981F');},onBackground:function(toggler,element){toggler.setStyle('color','#ececec');}},$('accordion'));}};window.addEvent('domready',Site.start);Hash.Cookie=new Class({Extends:Cookie,options:{autoSave:true},initialize:function(B,A){this.parent(B,A);this.load();},save:function(){var A=JSON.encode(this.hash);if(!A||A.length>4096){return false;}if(A=="{}"){this.dispose();}else{this.write(A);}return true;},load:function(){this.hash=new Hash(JSON.decode(this.read(),true));return this;}});Hash.Cookie.implement((function(){var A={};Hash.each(Hash.prototype,function(C,B){A[B]=function(){var D=C.apply(this.hash,arguments);if(this.options.autoSave){this.save();}return D;};});return A;})());Fx.Slide=new Class({Extends:Fx,options:{mode:'vertical'},initialize:function(element,options){this.addEvent('complete',function(){this.open=(this.wrapper['offset'+this.layout.capitalize()]!=0);if(this.open&&Browser.Engine.webkit419)this.element.dispose().inject(this.wrapper)},true);this.element=this.subject=$(element);this.parent(options);var wrapper=this.element.retrieve('wrapper');this.wrapper=wrapper||new Element('div',{styles:$extend(this.element.getStyles('margin','position'),{'overflow':'hidden'})}).wraps(this.element);this.element.store('wrapper',this.wrapper).setStyle('margin',0);this.now=[];this.open=true},vertical:function(){this.margin='margin-top';this.layout='height';this.offset=this.element.offsetHeight},horizontal:function(){this.margin='margin-left';this.layout='width';this.offset=this.element.offsetWidth},set:function(now){this.element.setStyle(this.margin,now[0]);this.wrapper.setStyle(this.layout,now[1]);return this},compute:function(from,to,delta){var now=[];var x=2;x.times(function(i){now[i]=Fx.compute(from[i],to[i],delta)});return now},start:function(how,mode){if(!this.check(arguments.callee,how,mode))return this;this[mode||this.options.mode]();var margin=this.element.getStyle(this.margin).toInt();var layout=this.wrapper.getStyle(this.layout).toInt();var caseIn=[[margin,layout],[0,this.offset]];var caseOut=[[margin,layout],[-this.offset,0]];var start;switch(how){case'in':start=caseIn;break;case'out':start=caseOut;break;case'toggle':start=(this.wrapper['offset'+this.layout.capitalize()]==0)?caseIn:caseOut}return this.parent(start[0],start[1])},slideIn:function(mode){return this.start('in',mode)},slideOut:function(mode){return this.start('out',mode)},hide:function(mode){this[mode||this.options.mode]();this.open=false;return this.set([-this.offset,0])},show:function(mode){this[mode||this.options.mode]();this.open=true;return this.set([0,this.offset])},toggle:function(mode){return this.start('toggle',mode)}});Element.Properties.slide={set:function(options){var slide=this.retrieve('slide');if(slide)slide.cancel();return this.eliminate('slide').store('slide:options',$extend({link:'cancel'},options))},get:function(options){if(options||!this.retrieve('slide')){if(options||!this.retrieve('slide:options'))this.set('slide',options);this.store('slide',new Fx.Slide(this,this.retrieve('slide:options')))}return this.retrieve('slide')}};Element.implement({slide:function(how,mode){how=how||'toggle';var slide=this.get('slide'),toggle;switch(how){case'hide':slide.hide(mode);break;case'show':slide.show(mode);break;case'toggle':var flag=this.retrieve('slide:flag',slide.open);slide[(flag)?'slideOut':'slideIn'](mode);this.store('slide:flag',!flag);toggle=true;break;default:slide.start(how,mode)}if(!toggle)this.eliminate('slide:flag');return this}});var noobSlide=new Class({initialize:function(params){this.items=params.items;this.mode=params.mode||'horizontal';this.fade=params.fade||false;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||8000;this.autoPlay=params.autoPlay||false;this._play=null;this.handles=params.handles||null;if(this.handles){this.addHandleButtons(this.handles);}
this.buttons={previous:[],next:[],play:[],playback:[],stop:[]};if(params.addButtons){for(var action in params.addButtons){this.addActionButtons(action,$type(params.addButtons[action])=='array'?params.addButtons[action]:[params.addButtons[action]]);}}
if(this.fade)
{this.orderItems()
this.fading((params.startItem||0),true,true);}
else
{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);}},orderItems:function(){for(i=0;i<this.items.length;i++)
{this.items[i].setStyle('position','absolute')
this.items[i].setStyle('left','0px');this.items[i].setStyle('z-index',i+1);if(i>0)
{this.items[i].fade('out');}}},addHandleButtons:function(handles){for(var i=0;i<handles.length;i++){if(this.fade)
{handles[i].addEvent(this.handle_event,this.fading.bind(this,[i,true]));}
else
{handles[i].addEvent(this.handle_event,this.walk.bind(this,[i,true]));}}},addActionButtons:function(action,buttons){for(var i=0;i<buttons.length;i++){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'playback':buttons[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'previous',false]));break;case'stop':buttons[i].addEvent(this.button_event,this.stop.bind(this));break;}
this.buttons[action].push(buttons[i]);}},previous:function(manual){if(this.fade)
{this.fading((this.currentIndex>0?this.currentIndex-1:this.items.length-1),manual);}
else
{this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),manual);}},next:function(manual){if(this.fade)
{this.fading((this.currentIndex<this.items.length-1?this.currentIndex+1:0),manual);}
else
{this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),manual);}},play:function(interval,direction,wait){this.stop();if(!wait){this[direction](false);}
this._play=this[direction].periodical(interval,this,[false]);},stop:function(){$clear(this._play);},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));}}},fading:function(item,manual,noFx){if(item!=this.currentIndex){this.lastIndex=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.items[this.lastIndex].fade('out');this.items[this.currentIndex].fade('in');}
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));}}}});
