//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.

MooTools.More={version:"1.2.3.1"};Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical"},initialize:function(b,a){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=document.id(b);this.parent(a);var c=this.element.retrieve("wrapper");
this.wrapper=c||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(a){this.element.setStyle(this.margin,a[0]);this.wrapper.setStyle(this.layout,a[1]);
return this;},compute:function(c,b,a){return[0,1].map(function(d){return Fx.compute(c[d],b[d],a);});},start:function(b,e){if(!this.check(b,e)){return this;
}this[e||this.options.mode]();var d=this.element.getStyle(this.margin).toInt();var c=this.wrapper.getStyle(this.layout).toInt();var a=[[d,c],[0,this.offset]];
var g=[[d,c],[-this.offset,0]];var f;switch(b){case"in":f=a;break;case"out":f=g;break;case"toggle":f=(c==0)?a:g;}return this.parent(f[0],f[1]);},slideIn:function(a){return this.start("in",a);
},slideOut:function(a){return this.start("out",a);},hide:function(a){this[a||this.options.mode]();this.open=false;return this.set([-this.offset,0]);},show:function(a){this[a||this.options.mode]();
this.open=true;return this.set([0,this.offset]);},toggle:function(a){return this.start("toggle",a);}});Element.Properties.slide={set:function(b){var a=this.retrieve("slide");
if(a){a.cancel();}return this.eliminate("slide").store("slide:options",$extend({link:"cancel"},b));},get:function(a){if(a||!this.retrieve("slide")){if(a||!this.retrieve("slide:options")){this.set("slide",a);
}this.store("slide",new Fx.Slide(this,this.retrieve("slide:options")));}return this.retrieve("slide");}};Element.implement({slide:function(d,e){d=d||"toggle";
var b=this.get("slide"),a;switch(d){case"hide":b.hide(e);break;case"show":b.show(e);break;case"toggle":var c=this.retrieve("slide:flag",b.open);b[c?"slideOut":"slideIn"](e);
this.store("slide:flag",!c);a=true;break;default:b.start(d,e);}if(!a){this.eliminate("slide:flag");}return this;}});


// START VIEWER
var viewer=new Class({mode:'rand',modes:['top','right','bottom','left','alpha'],sizes:{w:480,h:240},fxOptions:{duration:1500},interval:10000,initialize:function(a,b){if(b)for(var o in b)this[o]=b[o];if(this.buttons){this.buttons.previous.addEvent('click',this.previous.bind(this,[true]));this.buttons.next.addEvent('click',this.next.bind(this,[true]))}this._cItem=0;this._previous=null;this.items=a.setStyle('display','none');this.items[this._cItem].setStyle('display','block');this.disabled=false;this.attrs={left:['left',-this.sizes.w,0,'px'],top:['top',-this.sizes.h,0,'px'],right:['left',this.sizes.w,0,'px'],bottom:['top',this.sizes.h,0,'px'],alpha:['opacity',0,1,'']};this.rand=this.mode=='rand';this.sequence=typeof(this.mode)=='object'?this.mode:false;this.curseq=0;this.timer=null},walk:function(n,b){if(this._cItem!==n&&!this.disabled){this.disabled=true;if(b){this.stop()}if(this.rand){this.mode=this.modes.getRandom()}else if(this.sequence){this.mode=this.sequence[this.curseq];this.curseq+=this.curseq+1<this.sequence.length?1:-this.curseq}this._previous=this._cItem;this._cItem=n;var a=this.attrs[this.mode].associate(['p','f','t','u']);for(var i=0;i<this.items.length;i++){if(this._cItem===i){this.items[i].setStyles($extend({'display':'block','z-index':'2'},JSON.decode('{"'+a.p+'":"'+a.f+a.u+'"}')))}else if(this._previous===i){this.items[i].setStyles({'z-index':'1'})}else{this.items[i].setStyles({'display':'none','z-index':'0'})}}this.items[n].set('tween',$merge(this.fxOptions,{onComplete:this.onComplete.bind(this)})).tween(a.p,a.f,a.t)}},play:function(a){this.stop();if(!a){this.next()}this.timer=this.next.periodical(this.interval,this,[false])},stop:function(){$clear(this.timer)},next:function(a){this.walk(this._cItem+1<this.items.length?this._cItem+1:0,a)},previous:function(a){this.walk(this._cItem>0?this._cItem-1:this.items.length-1,a)},onComplete:function(){this.disabled=false;this.items[this._previous].setStyle('display','none');if(this.onWalk)this.onWalk(this._cItem)}});
// END VIEWER

window.addEvent('domready', function(){
																		 
	if($chk($('current-events'))){
		new viewer($('current-events').getChildren(),{
			mode: ['top']
		}).play(true);
	}			
	
	if($chk($('special-events'))){
		new viewer($('special-events').getChildren(),{
			mode: ['top']
		}).play(true);
	}
	
	var imageFaders = $$('.image_fader');
	imageFaders.each(function(el, i){
		new viewer(el.getChildren(),{
			mode: ['alpha'],
			interval:5000
		}).play(true);											 
	});
			
	var sliders = $$(".slider");
	var triggers = $$(".trigger");
	
	var slides = new Array();
	triggers.each(function(el, i) {
		slides.push(new Fx.Slide(sliders[i],{transition: Fx.Transitions.Sine.easeOut}));
		slides[i].hide();
		el.addEvent('click', function(e) {
			new Event(e).stop();
			slides[i].toggle();
		});
	});
			
});