var PhotoCreations={},colors=['#00db86','#d21e49','#00b4dc'],activeColor=0;window.addEvent('domready',function()
{var pushbox=$('pushbox');if(pushbox){new PhotoCreations.Pushbox({wrapper:pushbox,elements:pushbox.getElements('ol li'),buttons:pushbox.getElements('ul li a'),aside:pushbox.getElement('.lbl')});}
$$('form').each(function(form,i){new PhotoCreations.Form({form:form});});PhotoCreations.BorderChange.periodical(10000,this);new PhotoCreations.Lightbox;$$('div.slider').each(function(el,i){new PhotoCreations.Slider({wrapper:el,elements:el.getElements('div > ol > li'),buttons:el.getElements('nav > ul > li')});});});PhotoCreations.BorderChange=function(){var footer=$(document.body).getElement('footer').set('tween',{duration:6000});++activeColor;if(colors.length-activeColor<1){activeColor=0;}
footer.tween('border-color',colors[activeColor]);}
PhotoCreations.Lightbox=new Class({options:{mask:null,wrapper:null,content:null,title:null,close:null,prev:null,next:null,current:'',image:null,links:null,open:false},Implements:Options,initialize:function(options){this.setOptions(options);this.create();this.findLinks();},create:function(){this.options.mask=new Mask;this.options.mask.addEvent('click',this.close.bind(this));this.options.wrapper=new Element('div',{'id':'lb-wrapper'}).inject($(document.body));this.options.content=new Element('div',{'id':'lb-content'}).inject(this.options.wrapper);var bottom=new Element('div',{'class':'lb-bottom'}).inject(this.options.wrapper);this.options.title=new Element('div',{'class':'lb-btm-title'}).inject(bottom);this.options.close=new Element('a',{'class':'close','href':'#','html':'close','events':{click:function(e){e.stop();this.close();}.bind(this)}}).inject(bottom).fade('hide');this.options.prev=new Element('a',{'class':'btn-prev','title':'Vorige','href':'#','html':'Vorige','events':{click:function(e){e.stop();this.prev();}.bind(this)}}).inject(bottom);this.options.next=new Element('a',{'class':'btn-next','title':'Volgende','href':'#','html':'Volgende','events':{click:function(e){e.stop();this.next();}.bind(this)}}).inject(bottom);this.close();window.addEvents({keydown:function(e){if(open){switch(e.key){case'esc':this.close();break;case'left':this.prev();break;case'right':this.next();break;}}}.bind(this)});},findLinks:function(){this.options.links=$$('a.lightbox');this.addEvents();},addEvents:function(){var self=this;this.options.links.addEvent('click',function(e){e.stop();if(this!=self.options.current){self.options.current=this;self.get();}});},prev:function(){var curIndex=this.getCurrentIndex();if(this.options.links.indexOf(this.options.current)>0){--curIndex;this.options.current=this.options.links[curIndex];this.get();}},next:function(){var curIndex=this.getCurrentIndex();if(this.options.links.indexOf(this.options.current)!=-1&&this.options.links[curIndex+1]){++curIndex;this.options.current=this.options.links[curIndex];this.get();}},get:function(){this.setLoading();if(this.options.content.getElement('img')){this.options.content.getElement('img').dispose();}
this.options.image=Asset.image(this.options.current.get('href'),{onLoad:function(){if(typeof this.options.current.get('title')=='string'){this.options.image.set('title',this.options.current.get('title'));}else{this.options.image.set('title','');}
this.show();}.bind(this)});},setLoading:function(){this.options.wrapper.addClass('loading');if(!this.options.open){this.open();}},show:function(){this.checkButtons();var width=this.options.image.get('width').toInt();var height=this.options.image.get('height').toInt();this.options.image.inject(this.options.content).fade('hide');var morph=new Fx.Morph(this.options.wrapper,{duration:400,transition:Fx.Transitions.Sine.easeOut,onComplete:function(){this.options.close.fade('show');this.options.wrapper.removeClass('loading');this.options.image.fade(1);if(typeof this.options.image.get('title')=='string'){this.options.title.set('html',this.options.image.get('title'));}else{this.options.title.set('html','');}}.bind(this)}).start({'width':width,'height':height+40,'marginLeft':-(width/2),'marginTop':-((height+40)/2)});},open:function(){this.options.wrapper.setStyle('display','block');this.options.mask.show();this.options.open=true;},close:function(){this.options.content.empty();this.options.wrapper.setStyles({'display':'none','width':20,'height':20,'margin':'-25px 0 0 -25px'});this.options.mask.hide();this.options.close.fade('hide');this.options.open=false;this.options.current=null;},getCurrentIndex:function(){return this.options.links.indexOf(this.options.current);},checkButtons:function(){var total=this.options.links.length;var current=this.options.links.indexOf(this.options.current);if(current<1){this.options.prev.addClass('hide');}
else{this.options.prev.removeClass('hide');}
if(current>=total-1){this.options.next.addClass('hide');}
else{this.options.next.removeClass('hide');}}});PhotoCreations.Form=new Class({options:{form:null},Implements:Options,initialize:function(options){this.setOptions(options);this.setForm();},setForm:function(){if(!this.options.form.get('isAjax')){this.options.form.set('send',{method:this.options.form.method,url:this.options.form.action,onComplete:function(response){this.setResponse(response);}.bind(this)});this.options.form.addEvent('submit',function(e){e.stop();this.options.form.send();}.bind(this));this.options.form.set('isAjax',true);}},setResponse:function(response){response=JSON.decode(response);if(response.errors.length>0){this.options.form.getElements('input, textarea').removeClass('error');this.options.form.getElement('p.message').addClass('errorMessage').set('html',response.message);response.errors.each(function(error){if(document.id('inp-'+error)){document.id('inp-'+error).addClass('error');}});}
else{this.options.form.getElement('p.message').removeClass('errorMessage').addClass('successMessage').set('html',response.message);this.options.form.getElement('fieldset').dispose();}}});PhotoCreations.Slider=new Class({options:{wrapper:null,elements:null,buttons:null,active:0,total:0,dir:1,timer:null,fx:null},Implements:Options,initialize:function(options){this.setOptions(options);this.options.total=this.options.elements.length;this.options.fx=new Fx.Scroll(this.options.wrapper.getElement('> div'),{link:'cancel',duration:300});this.initLinks();this.periodical();},initLinks:function(){this.options.buttons.each(function(a,i){a.addEvent('click',function(e){e.stop();if(a.hasClass('next')){this.next(1);}
else if(a.hasClass('prev')){this.prev(1);}
this.periodical();}.bind(this));}.bind(this));this.slide();},periodical:function(){this.options.timer=clearInterval(this.options.timer);this.options.timer=this.get.periodical(8500,this);},get:function(){if(this.options.dir==1){this.next();}else{this.prev();}},prev:function(dirChange){--this.options.active;if(this.options.active<0){this.options.active=0;if(typeof dirChange=='undefined'){this.options.dir=1;this.next();}
return false;}
this.slide();},next:function(dirChange){++this.options.active;if((this.options.total-this.options.active)<1){this.options.active=this.options.total-1;if(typeof dirChange=='undefined'){this.options.dir=0;this.prev();}
return false;}
this.slide();},slide:function(){this.options.fx.toElement(this.options.elements[this.options.active]);this.activeNav();},activeNav:function(){this.options.buttons.each(function(a,i){if(a.hasClass('prev')){if(this.options.active<1){a.addClass('inactive');}else{a.removeClass('inactive');}}
else if(a.hasClass('next')){if(this.options.active>=(this.options.total-1)){a.addClass('inactive');}else{a.removeClass('inactive');}}}.bind(this));}});PhotoCreations.Pushbox=new Class({options:{wrapper:null,elements:null,buttons:null,aside:null,active:0,total:0,timer:null,fx:null},Implements:Options,initialize:function(options){this.setOptions(options);this.options.total=this.options.buttons.length;this.options.fx=new Fx.Scroll(this.options.wrapper.getElement('> div'),{duration:550});this.initLinks();this.periodical();},initLinks:function(){this.options.buttons.each(function(a,i){a.addEvent('click',function(e){e.stop();a.set('tween',{duration:350});this.activate(i);this.periodical();}.bind(this));}.bind(this));this.slide();},periodical:function(){this.options.timer=clearInterval(this.options.timer);},activate:function(key){this.options.active=key;this.slide();},next:function(){++this.options.active;if((this.options.total-this.options.active)<1){this.options.active=0;}
this.slide();},slide:function(){this.options.fx.toElement(this.options.elements[this.options.active]);this.activeNav();},activeNav:function(){this.options.buttons.each(function(a,i){if(a.hasClass('active')){a.tween('color','#ffffff').removeClass('active');}
else if(i==this.options.active){a.tween('color','#d21e49').addClass('active');}}.bind(this));},setText:function(){this.options.aside.set('html',(this.options.active+1)+' <em>van</em> '+this.options.total);}});
