
function markMissing(name){var input=$E('input[name='+name+']');if(input){input.addClass('invalid');input.getParent().addClass('invalid');}}
window.addEvent('load',function(){if($('left_image')&&$('right_image')){startHomeSlideshow();setupCollectionList();}
$ES('.collection-links a').forEach(function(link){link.setAttribute('target','_blank')});});function setupCollectionList(){new CollectionList('collections-button');}
var CollectionList={initialize:function(element){this.element=$(element);this.container=$E('#left_image .gallery');this.element.setStyle('position','absolute');this.element.getElement('ul').setStyle('display','none');this.element.setStyle('height','30px');this.element.setStyle('width',this.container.style.width);this.position();this.element.setStyle('display','');new Fx.Style(this.element,'opacity').start(0,0.8);this.element.getElement('h3').addEvent('click',this.expand.bind(this));this.expanded=false;},position:function(){this.element.setPosition({relativeTo:this.container,position:'bottomLeft',edge:'bottomLeft'});},expand:function(){if(!this.expanded){this.expanded=true;left_gallery.stop();right_gallery.stop();var list=function(){this.element.getElement('ul').setOpacity(0).setStyle('display','');new Fx.Style(this.element.getElement('ul'),'opacity').start(0,1);}
var grow=function(){this.element.getElement('h3').addClass('close');new Fx.Style(this.element,'height',{onComplete:list.bind(this)}).start(this.element.getComputedSize()['height'],this.container.getComputedSize()['height']);}
new Fx.Styles(this.element,{onComplete:grow.bind(this)}).start({top:[this.element.offsetTop,this.element.offsetTop-(this.container.getComputedSize()['height']-this.element.getComputedSize()['height'])],opacity:[0.8,0.9]});}else{var startGalleries=function(){left_gallery.start(1000);right_gallery.start(2000);}
this.expanded=false;this.element.getElement('ul').setStyle('display','none');this.element.getElement('h3').removeClass('close');new Fx.Styles(this.element,{onComplete:startGalleries}).start({height:[this.element.getComputedSize()['height'],30],top:[this.element.offsetTop,this.element.offsetTop+(this.container.getComputedSize()['height']-30)],opacity:[0.9,0.8]});}}}
CollectionList=new Class(CollectionList);var left_gallery;var right_gallery;function startHomeSlideshow(){left_gallery=new gallery('left_image',{duration:3000,fadeDuration:3000});right_gallery=new gallery('right_image',{duration:3000,fadeDuration:3000});left_gallery.start(1000);right_gallery.start(1000);}
var gallery={initialize:function(element,options){this.setOptions({duration:1000,fadeDuration:3000},options);this.element=$(element);this.images=this.element.getElements('img');this.image=0;this.running=false;this.images.forEach(function(image){image.setStyle('display','none');});this.container=this.element.getElement('.gallery')||new Element('div').addClass('gallery').injectInside(this.element);this.size=this.container.getCoordinates();if(this.size['width']==0||this.size['height']==0){this.images[0].setStyle('display','');this.size=this.images[0].getCoordinates();this.images[0].setStyle('display','none');}
this.container.setStyles({width:this.size['width']+'px',height:this.size['height']+'px'});this.inner_container=(this.container.getElement('.gallery_inner')||new Element('div').addClass('gallery_inner')).setStyles({width:this.size['width']+'px',height:this.size['height']+'px'});this.inner_container.injectInside(this.container);},start:function(delay){this.running=true;setTimeout(this.next.bind(this),delay||0);},stop:function(){this.running=false;},next:function(){if(!this.running)return;this.image++;if(!this.images[this.image])this.image=0;this.inner_container.setOpacity(0);this.inner_container.setStyles({backgroundImage:'url('+this.images[this.image].src+')'});new Fx.Style(this.inner_container,'opacity',{duration:this.options.fadeDuration,onComplete:function(){this.container.setStyles({backgroundImage:'url('+this.images[this.image].src+')'});this.inner_container.setOpacity(0);setTimeout(this.next.bind(this),this.options.duration);}.bind(this)}).start(0,1);}};gallery=new Class(gallery);gallery.implement(new Events);gallery.implement(new Options);