/* Eitido (c) 2010 - Norman Geiersbach */
var Animation=new Class({Implements:[Options],options:{autodisplay:true,autostart:false,count:0,delay:'long',horizontal:true,loop:false,width:0,height:0},current:0,element:null,image:null,timer:null,isRunning:false,initialize:function(element,image,options){this.setOptions(options);this.options.delay=Animation.Delay[this.options.delay]||this.options.delay.toInt();this.element=($type(element)=='string')?$(element):element;if($chk(image))this.element.setStyle('background-image',image);if(this.options.width==0)this.options.width=this.element.getStyle('width').toInt();if(this.options.height==0)this.options.height=this.element.getStyle('height').toInt();if(this.options.count==0){var imgUrl=this.element.getStyle('background-image');if(imgUrl.contains('url('))imgUrl=imgUrl.substring(5,imgUrl.length-2);var img=new Image();img.src=imgUrl;this.checkLoad.delay(1,this,img);}
if(this.options.autostart)this.start();},checkLoad:function(img){if(img!=null){if((img.complete)&&(img.width>0)){this.options.horizontal=img.width>img.height;this.options.count=(this.options.horizontal?img.width/this.options.width:img.height/this.options.height).toInt();if(this.options.autostart)this.start();}else this.checkLoad.delay(1,this,img);}},start:function(){if((this.options.count>0)&&(this.options.width>0)){if(this.timer==null){this.timer=this.step.periodical(this.options.delay,this);if(this.options.autodisplay)this.element.setStyle('display','block');this.isRunning=true;}else this.current=0;}},stop:function(){if(this.timer!=null){this.isRunning=false;this.timer=$clear(this.timer);if(this.options.autodisplay)this.element.setStyle('display','none');}},step:function(){if(this.current>=this.options.count){if(this.options.loop)this.current=0;else this.stop();}
this.element.setStyle('background-position',this.options.horizontal?(this.current*-this.options.width)+'px 0px':'0px '+(this.current*-this.options.width)+'px');this.current++;}});Animation.Delay={'short':25,'normal':50,'long':100};
var scrollers=[];var ContentScroller=new Class({Implements:[Events,Options],options:{host:null,selectors:{wrapper:null,blocks:null},fx:{duration:'long',link:'cancel',transition:'back:out'},horizontal:true},current:0,count:0,elements:{host:null,wrapper:null,blocks:null,buttons:{prev:null,next:null}},size:null,initialize:function(options){this.setOptions(options);this.generate();scrollers.push(this);},generate:function(){var host=this.elements.host=$type(this.options.host)=='string'?$(this.options.host):this.options.host;if(host==null)return false;this.elements.wrapper=host.getElement(this.options.selectors.wrapper);if(this.elements.wrapper==null)return false;this.elements.blocks=this.elements.wrapper.getElements(this.options.selectors.blocks);if((this.elements.blocks==null)||(this.elements.blocks.length<2))
return false;this.count=this.elements.blocks.length;this.size=host.getSize();if(this.options.horizontal)
this.elements.wrapper.setStyle('width',(this.size.x*this.count));else
this.elements.wrapper.setStyle('height',(this.size.y*this.count));this.fx=new Fx.Tween(this.elements.wrapper.set(this.options.horizontal?'margin-left':'margin-top','0'),{duration:this.options.fx.duration,link:this.options.fx.link,transition:this.options.fx.transition});this.elements.buttons.prev=new Element('a',{'href':'#'}).addClass('scroller-button-prev').setStyles({'display':'none','position':'absolute','z-index':'202'}).addEvent('click',function(){this.previous();return false;}.bindWithEvent(this));this.elements.buttons.next=new Element('a',{'href':'#'}).addClass('scroller-button-next').setStyles({'display':'block','position':'absolute','z-index':'202'}).addEvent('click',function(){this.next();return false;}.bindWithEvent(this));this.elements.buttons.prev.inject(this.elements.host);this.elements.buttons.next.inject(this.elements.host);},next:function(){if(this.current<this.count-1)
this.setCurrent(this.current+1);},previous:function(){if(this.current>0)
this.setCurrent(this.current-1);},setCurrent:function(index){if((index>=0)&&(index<=this.count-1)){if(this.elements.buttons.prev!=null)this.elements.buttons.prev.setStyle('display',index<1?'none':'block');if(this.elements.buttons.next!=null)this.elements.buttons.next.setStyle('display',index>=this.count-1?'none':'block');if(this.options.horizontal)
this.fx.start('margin-left',(index*-this.size.x)+'px');else
this.fx.start('margin-top',(index*-this.size.y)+'px');this.current=index;this.fireEvent('changed',[this]);}}});
var imageGalleryPopup=null;var ImageGallery=new Class({Implements:[Options],options:{host:null,path:null,popup:null,fx:{duration:'long',link:'cancel',transition:'back:out'}},id:null,elements:{container:null,images:null,buttons:{container:null,enlarge:null,prev:null,next:null}},images:null,popup:null,fx:null,size:0,current:0,initialize:function(options){this.setOptions(options);this.generate();},generate:function(){var host=$type(this.options.host)=='string'?$(this.options.host):this.options.host;if(host==null)return false;this.id=host.uid;this.elements.images=host.getElements('img');if((this.elements.images==null)||(this.elements.images.length<1))return false;this.size=this.elements.images[0].getSize();var hostSize=host.getSize();this.elements.container=new Element('div').addClass('gallery-container').setStyle('width',(this.size.x*this.elements.images.length)+'px');this.elements.buttons.container=new Element('div').addClass('gallery-buttons').setStyles({'position':'absolute','left':'0','top':'0','width':hostSize.x+'px','height':hostSize.y+'px','z-index':'101'});this.elements.buttons.enlarge=new Element('a',{'href':'#'}).addClass('gallery-button-enlarge').setStyles({'display':'block','position':'absolute','z-index':'102'});this.elements.buttons.prev=new Element('a',{'href':'#'}).addClass('gallery-button-prev').setStyles({'display':'none','position':'absolute','z-index':'102'}).addEvent('click',function(){this.previous();return false;}.bindWithEvent(this));this.elements.buttons.next=new Element('a',{'href':'#'}).addClass('gallery-button-next').setStyles({'display':this.elements.images.length>1?'block':'none','position':'absolute','z-index':'102'}).addEvent('click',function(){this.next();return false;}.bindWithEvent(this));if(this.options.popup!=null){if(Browser.Engine.trident){for(var i=0;i<this.elements.images.length;i++)
this.elements.images[i].addEvent('click',function(){this.enlarge();return false;}.bindWithEvent(this));}else this.elements.buttons.container.addEvent('click',function(){this.enlarge();return false;}.bindWithEvent(this));this.elements.buttons.enlarge.addEvent('click',function(){this.enlarge();return false;}.bindWithEvent(this));}
this.fx=new Fx.Tween(this.elements.container.set('margin-left','0'),{duration:this.options.fx.duration,link:this.options.fx.link,transition:this.options.fx.transition});for(var i=0;i<this.elements.images.length;i++)
this.elements.images[i].inject(this.elements.container);if(this.options.popup!=null)this.elements.buttons.enlarge.inject(this.elements.buttons.container);this.elements.buttons.prev.inject(this.elements.buttons.container);this.elements.buttons.next.inject(this.elements.buttons.container);this.elements.container.inject(host);this.elements.buttons.container.inject(host);this.images=[];for(var i=0;i<this.elements.images.length;i++)
this.images.push({filename:this.elements.images[i].src.substring(this.elements.images[i].src.lastIndexOf('/')+1,this.elements.images[i].src.length),title:this.elements.images[i].alt});},enlarge:function(){if(imageGalleryPopup==null)
imageGalleryPopup=(new ImageGalleryPopup(this.options.popup));if(this.popup==null){this.popup=imageGalleryPopup;this.popup.addEvent('close',function(popup,uid){if(uid==this.id)this.setCurrent(popup.current);}.bindWithEvent(this))}
imageGalleryPopup.show(this.images,this.current,this.id);},previous:function(){if(this.current>0)
this.setCurrent(this.current-1);},next:function(){if(this.current<this.images.length-1)
this.setCurrent(this.current+1);},setCurrent:function(index){if((index>=0)&&(index<this.images.length)){if(this.elements.buttons.prev!=null)this.elements.buttons.prev.setStyle('display',index<1?'none':'block');if(this.elements.buttons.next!=null)this.elements.buttons.next.setStyle('display',index>=this.images.length-1?'none':'block');this.fx.start('margin-left',(index*-this.size.x)+'px');this.current=index;}}});
var ImageGalleryPopup=new Class({Implements:[Events,Options],options:{host:null,path:'',localization:{image:'Image',close:'Close',prev:'Previous',next:'Next'},minMargin:{x:32,y:32},minSize:{x:320,y:240},smoothResize:true,onClose:null,onShow:null},elements:{wrapper:null,overlay:null,window:null,image:null,imageNew:null,loader:null,info:{container:null,title:null,state:null},buttons:{container:null,close:null,prev:null,next:null}},fx:{window:null,imageNew:null,infoContainer:null},images:null,loadAnim:null,loadImage:null,loadTimer:null,sizes:{borderWidth:0,borderHeight:0,infoHeight:40,windowWidth:640,windowHeight:480},callerId:null,current:0,initialize:function(options){this.setOptions(options);this.generate();if((this.options.path!='')&&(this.options.path.charAt(this.options.path.length-1)!='/'))this.options.path+='/';},generate:function(){var host=$chk(this.options.host)?($type(this.options.host)=='string'?$(this.options.host):this.options.host):document.body;this.elements.wrapper=new Element('div').addClass('popup-wrapper').setStyle('display','none');this.elements.overlay=new Element('div').addClass('popup-overlay').setStyles({'position':'fixed','left':'0','top':'0','width':'100%','height':'100%','z-index':'310','opacity':'0.9'});this.elements.window=new Element('div').addClass('popup-window').setStyles({'position':'fixed','left':'50%','top':'50%','margin':'-240px 0 0 -320px','width':'640px','height':'480px','z-index':'311'});this.elements.image=new Element('img').addClass('popup-image').setStyles({'position':'absolute','left':'0','top':'0','width':'640px','height':'480px','z-index':'312'});this.elements.imageNew=new Element('img').addClass('popup-image-new').setStyles({'position':'absolute','left':'0','top':'0','width':'640px','height':'480px','z-index':'313'}).addEvent('click',function(){this.close();return false;}.bindWithEvent(this));this.elements.loader=new Element('div').addClass('popup-loader').setStyles({'display':'none','position':'absolute','left':'50%','top':'50%','z-index':'315'});this.elements.info.container=new Element('div').addClass('popup-info-container').setStyles({'display':'block','position':'absolute','left':'0','bottom':'0','width':'640px','overflow':'hidden','z-index':'314','opacity':'0.75'});this.elements.info.title=new Element('div').addClass('popup-info-title').setStyles({'overflow':'hidden'});this.elements.info.state=new Element('div').addClass('popup-info-state').setStyles({'overflow':'hidden'});this.elements.buttons.container=new Element('div').addClass('popup-buttons').addEvent('click',function(){this.close();return false;}.bindWithEvent(this));this.elements.buttons.close=new Element('a',{'href':'#'}).addClass('popup-button-close').setStyles({'display':'block','position':'absolute','z-index':'316'}).addEvent('click',function(){this.close();return false;}.bindWithEvent(this));this.elements.buttons.prev=new Element('a',{'href':'#'}).addClass('popup-button-prev').setStyles({'display':'block','position':'absolute','z-index':'316'}).addEvent('click',function(){this.previous();return false;}.bindWithEvent(this));this.elements.buttons.next=new Element('a',{'href':'#'}).addClass('popup-button-next').setStyles({'display':'block','position':'absolute','z-index':'316'}).addEvent('click',function(){this.next();return false;}.bindWithEvent(this));this.fx.window=new Fx.Morph(this.elements.window);this.fx.imageNew=new Fx.Tween(this.elements.imageNew);this.fx.infoContainer=new Fx.Tween(this.elements.info.container);this.elements.overlay.inject(this.elements.wrapper);this.elements.window.inject(this.elements.wrapper);this.elements.image.inject(this.elements.window);this.elements.imageNew.inject(this.elements.window);this.elements.loader.inject(this.elements.window);this.elements.info.container.inject(this.elements.window);this.elements.buttons.container.inject(this.elements.window);this.elements.info.title.inject(this.elements.info.container);this.elements.info.state.inject(this.elements.info.container);this.elements.buttons.close.inject(this.elements.buttons.container);this.elements.buttons.prev.inject(this.elements.buttons.container);this.elements.buttons.next.inject(this.elements.buttons.container);this.elements.wrapper.inject(host);this.sizes.borderWidth=this.elements.window.getStyle('border-left-width').toInt()+this.elements.window.getStyle('border-right-width').toInt();if(!$chk(this.sizes.borderWidth))this.sizes.borderWidth=0;this.sizes.borderHeight=this.elements.window.getStyle('border-top-width').toInt()+this.elements.window.getStyle('border-bottom-width').toInt();if(!$chk(this.sizes.borderWidth))this.sizes.borderHeight=0;this.sizes.infoHeight=this.elements.info.container.getStyle('height').toInt();this.loadAnim=new Animation(this.elements.loader,null,{autodisplay:true,autostart:false,horizontal:true,loop:true});if($chk(this.loadAnim))
this.elements.loader.setStyle('margin','-'+(this.loadAnim.options.width/2).toInt()+'px 0 0 -'+(this.loadAnim.options.height/2).toInt()+'px');},checkLoad:function(){if(this.loadImage!=null)
{if((this.loadImage.complete)&&(this.loadImage.width>0)){this.loadTimer=$clear(this.loadTimer);if((this.sizes.windowWidth!=this.loadImage.width)||(this.sizes.windowHeight!=this.loadImage.height)){this.setSize(this.loadImage.width,this.loadImage.height);this.blendImage.delay(this.fx.window.options.duration,this);}
else this.blendImage();}else if(!this.loadAnim.isRunning)this.loadAnim.start();}else this.loadTimer=$clear(this.loadTimer);},blendImage:function(){this.elements.imageNew.src=this.options.path+this.images[this.current].filename;this.elements.imageNew.setStyles({'display':'block','opacity':0}).tween('opacity','1');this.elements.info.title.set('text',this.images[this.current].title);this.elements.info.state.set('text',this.options.localization.image+' '+(this.current+1)+' / '+this.images.length);this.elements.info.container.setStyle('display','block');this.elements.info.container.tween('height',this.sizes.infoHeight);if(this.loadAnim.isRunning)this.loadAnim.stop();},close:function(){this.elements.wrapper.setStyle('display','none');this.fireEvent('close',[this,this.callerId]);return false;},show:function(images,current,uid){this.callerId=uid;this.images=images;this.elements.image.setStyle('display','none');this.elements.imageNew.setStyle('display','none');this.elements.info.container.setStyle('height','0');this.setCurrent($chk(current)?current:0);this.elements.wrapper.setStyle('display','block');this.fireEvent('show',[this,this.callerId]);},previous:function(){if(this.current>0)
this.setCurrent(this.current-1);return false;},next:function(){if(this.current<this.images.length-1)
this.setCurrent(this.current+1);return false;},setCurrent:function(index){if((index>=0)&&(index<this.images.length)){if(this.loadTimer!=null)this.loadTimer=$clear(this.loadTimer);this.loadImage=new Image();this.loadImage.src=this.options.path+this.images[index].filename;if($chk(this.elements.imageNew.src)){this.elements.image.src=this.elements.imageNew.src;this.elements.image.setStyle('display','block');this.elements.imageNew.setStyle('display','none');}
this.elements.buttons.prev.setStyle('display',index<1?'none':'block');this.elements.buttons.next.setStyle('display',index>=this.images.length-1?'none':'block');this.elements.info.container.tween('height',0);this.current=index;this.loadTimer=this.checkLoad.periodical(5,this);}},setSize:function(width,height){var maxSize=document.window.getSize();maxSize.x-=this.options.minMargin.x*2;maxSize.y-=this.options.minMargin.y*2;if((maxSize.x<width+this.sizes.borderWidth)||(maxSize.y<height+this.sizes.borderHeight)){if(maxSize.x<this.options.minSize.x)maxSize.x=this.options.minSize.x;if(maxSize.y<this.options.minSize.y)maxSize.y=this.options.minSize.y;var imgAR=width/height;var wndAR=maxSize.x/maxSize.y;width=wndAR>=imgAR?(imgAR*maxSize.y).toInt():maxSize.x;height=wndAR>=imgAR?maxSize.y:(maxSize.x/imgAR).toInt();}
if(this.options.smoothResize)this.elements.window.morph({'width':width,'height':height,'margin-left':((width+this.sizes.borderWidth)/-2),'margin-top':((height+this.sizes.borderHeight)/-2)});else this.elements.window.setStyles({'width':width,'height':height,'margin-left':((width+this.sizes.borderWidth)/-2),'margin-top':((height+this.sizes.borderHeight)/-2)});this.elements.image.setStyles({'display':'none','width':width,'height':height});this.elements.imageNew.setStyles({'display':'none','width':width,'height':height});this.elements.info.container.setStyles({'display':'none','width':width});this.sizes.windowWidth=width;this.sizes.windowHeight=height;}});
var CourseSchedule=new Class({Implements:[Options],options:{host:null,wrapper:null},current:0,elements:{host:null,info:null,courses:[]},scroller:null,initialize:function(options){this.setOptions(options);this.generate();},generate:function(){var host=this.elements.host=$type(this.options.host)=='string'?$(this.options.host):this.options.host;if(host==null)return false;this.elements.info=$type(this.options.wrapper)=='string'?$(this.options.wrapper):this.options.wrapper;if(this.elements.info==null)return false;var wrappers=host.getElements('div.course-wrapper');if(wrappers==null)return false;for(i=0;i<wrappers.length;i++){this.elements.courses.push({wrapper:wrappers[i],link:wrappers[i].getElement('a.course'),info:wrappers[i].getElement('table.schedule-info')});}
for(i=0;i<this.elements.courses.length;i++){var link=this.elements.courses[i].link;var info=this.elements.courses[i].info;if((link==null)||(info==null))continue;link.addEvent('mouseenter',function(event,index){this.hide();this.show(index);this.check();}.bindWithEvent(this,i));}},check:function(){if((this.scroller==null)&&(scrollers!=null)&&(scrollers.length>0)){this.scroller=scrollers[0];this.scroller.addEvent('changed',function(){this.hide();}.bindWithEvent(this))}},hide:function(){var wrapper=this.elements.info;var children=wrapper.getElements('table');for(i=0;i<children.length;i++)
children[i].destroy();this.elements.courses[this.current].link.removeClass('active');},show:function(index){if((index>=0)&&(index<=this.elements.courses.length-1)){this.elements.courses[index].link.addClass('active');this.elements.courses[index].info.clone().inject(this.elements.info);this.current=index;}}});