/*
Milkbox v2.2.1 - required: mootools.js v1.2.1 core + more: Assets	
	by Luca Reghellin (http://www.reghellin.com) February 2009, MIT-style license.
	Inspiration Lokesh Dhakar (http://www.lokeshdhakar.com/projects/lightbox2/)
	AND OF COURSE, SPECIAL THANKS TO THE MOOTOOLS DEVELOPERS
*/
var Milkbox=new Class({Implements:[Options,Events],options:{overlayOpacity:0.7,topPosition:50,initialWidth:250,initialHeight:250,canvasBorderWidth:'0px',canvasBorderColor:'#000000',canvasPadding:'0px',resizeDuration:700,resizeTransition:'sine:in:out',autoPlay:false,autoPlayDelay:7,removeTitle:false,onXmlGalleries:$empty,onClosed:$empty,onFileReady:$empty},initialize:function(options) {this.setOptions(options);this.autoPlayBkup={autoPlayDelay:this.options.autoPlayDelay,autoPlay:this.options.autoPlay};this.fullOptionsBkup={};this.galleries=[];this.families=[];this.xmlFiles=[];this.loadedImages=[];this.currentFile=null;this.currentIndex=null;this.currentGallery=null;this.currentRequest=null;this.currentResponse=null;this.mode=null;this.closed=true;this.busy=true;this.paused=true;this.fileReady=false;this.eventsok=false;this.first=true;this.intObj=null;this.formtags=null;this.prepareGalleries();if (this.galleries.length==0) {return;};this.initMilkbox();this.saveOptions();},initMilkbox:function() {this.prepareHTML();this.prepareEffects();this.prepareEvents();this.formtags=$$('select','textarea');this.activated=true;},openMilkbox:function(gallery,index) {this.closed=false;if (this.formtags.length!=0) {this.formtags.setStyle('display','none')};this.overlay.setStyles({'top':-$(window).getScroll().y,'height':$(window).getScrollSize().y+$(window).getScroll().y});this.center.setStyle('top',$(window).getScroll().y+this.options.topPosition);this.currentGallery=gallery;this.currentIndex=index;this.overlay.tween('opacity',this.options.overlayOpacity);if (gallery.length==1) {this.mode='singleFile';this.loadFile(gallery[index],index);}else {this.mode='fileGallery';var playpauseWidth=0;$$(this.prev,this.next,this.count).setStyle('display','block');if (this.options.autoPlay) {this.playpause.setStyle('display','block');var playpauseWidth=this.playpause.getSize().x;}
var border=this.center.getStyle('border-right-width').toInt();var navWidth=this.prev.getSize().x+this.next.getSize().x+this.close.getSize().x+playpauseWidth+border;this.navigation.setStyle('width',navWidth);this.description.setStyle('margin-right',navWidth);var next=(index!=gallery.length-1)?gallery[index+1]:gallery[0];var prev=(index!=0)?gallery[index-1]:gallery[gallery.length-1];var preloads=(prev==next)?[prev]:[prev,next];this.loadFile(gallery[index],preloads);}},loadFile:function(fileObj,preloads) {this.fileReady=false;var swf=this.checkFileType(fileObj,'swf');if (!swf) {if (!this.loadedImages.contains(fileObj.retrieve('href'))) {this.center.addClass('mbLoading');}
this.loadImage(fileObj.retrieve('href'));}else {this.loadSwf(fileObj);}
if (preloads) {this.preloadFiles(preloads);}},preloadFiles:function(preloads) {preloads.each(function(fileObj,index) {var swf=this.checkFileType(fileObj.retrieve('href'),"swf");if (!swf) {this.preloadImage(fileObj.retrieve('href'));}},this);},loadImage:function(file) {var imageAsset=new Asset.image(file,{onload:function(img) {if (!this.loadedImages.contains(file)) {this.loadedImages.push(file);};this.currentFile=img;this.loadAux(this.currentFile);}.bindWithEvent(this)});},preloadImage:function(file) {if (!this.loadedImages.contains(file)) {var imageAsset=new Asset.image(file,{onload:function(img) {this.loadedImages.push(file);}.bindWithEvent(this)});}},loadSwf:function(swf) {var swfObj=new Swiff(swf.retrieve('href'),{width:swf.retrieve('width').toInt(),height:swf.retrieve('height').toInt(),params:{wMode:'opaque',swLiveConnect:'false'}});this.currentFile=swfObj;this.loadAux(swf);},loadAux:function(file) {this.fileReady=true;this.fireEvent('fileReady');$$(this.description,this.navigation).setStyle('visibility','hidden');this.navigation.setStyle('height','');$$(this.next,this.prev,this.close).setStyle('backgroundPosition','0 0');this.showFile(file);},showFile:function(file) {if (this.closed) {return;};var fileSize=new Hash();var targetSize={};var b=null;var p=null;if (this.options.canvasBorderWidth.toInt()!=0&&this.canvas.getStyle('borderWidth').toInt()==0) {b=this.options.canvasBorderWidth+' solid '+this.options.canvasBorderColor;this.canvas.setStyle('border',b);}
if (this.options.canvasPadding.toInt()!=0&&this.canvas.getStyle('padding').toInt()==0) {p=this.options.canvasPadding;this.canvas.setStyle('padding',p);}
var canvasSize=this.canvas.getSize();var canvasAddSize=this.canvas.getStyle('borderWidth').toInt()*2+this.canvas.getStyle('padding').toInt()*2;this.canvas.setStyles({'opacity':0,'width':'','height':''});if (!file.retrieve('width')) {fileSize=fileSize.extend(file.getProperties('width','height')).map(function(item,index) {return item.toInt();});}else {fileSize.extend({'height':file.retrieve('height').toInt(),'width':file.retrieve('width').toInt()});}
var centerSize=new Hash(this.center.getStyles('width','height')).map(function(item,index) {return item.toInt();});if (fileSize.width!=centerSize.width) {targetSize.width=fileSize.width+canvasAddSize;targetSize.marginLeft=-(targetSize.width/2).round();}
var gap=(canvasSize.y-canvasAddSize>0)?centerSize.height-canvasSize.y:0;targetSize.height=fileSize.height+canvasAddSize+gap;this.canvas.setStyles({'width':fileSize.width,'height':fileSize.height});this.center.removeClass('mbLoading');var d=0;if (this.first) {d=500;this.first=false;}
(function() {this.center.morph(targetSize);}).delay(d,this)},showGallery:function(opt) {if (!opt||!opt.gallery) {return;}
var fileIndex=($chk(opt.index))?opt.index:0;var g=this.getGallery(opt.gallery);var auto=false;var d;if (opt.autoplay||(g['options']&&g['options'].autoplay)) {auto=true;}
if (g!=-1&&!this.opened) {if (auto) {d=(opt&&opt.delay)?opt.delay:(g['options']&&g['options'].delay)?g['options'].delay:this.autoPlayDelay;this.startAutoPlay({gallery:g,index:fileIndex,delay:d});}else {this.openMilkbox(g,fileIndex);}}},addGalleries:function(xmlfile) {this.currentRequest=new Request({method:'get',autoCancel:true,url:xmlfile,onRequest:function() {}.bindWithEvent(this),onSuccess:function(text,xml) {var t=text.replace(/(<a.+)\/>/gi,"$1></a>");this.setGalleries(new Element('div',{html:t}),xmlfile);}.bindWithEvent(this),onFailure:function(transport) {alert('Milkbox :: addGalleries: XML file path error or local Ajax test: please test addGalleries() on-line');}});this.currentRequest.send();},setGalleries:function(container,xmlfile) {if (!this.xmlFiles.contains(xmlfile)) {this.xmlFiles.push(xmlfile);}
var c=container;var galleries=c.getElements('.gallery');var links=[];var aplist=[];galleries.each(function(gallery,i) {var obj={gallery:gallery.getProperty('name'),autoplay:Boolean(gallery.getProperty('autoplay')),delay:Number(gallery.getProperty('delay'))}
var l=gallery.getChildren('a');var lx=l.map(function(link) {return link.setProperty('rel','milkbox['+obj.gallery+']');});links.push(lx);if (obj.autoplay) {aplist.push(obj);}});this.prepareGalleries(links.flatten());this.setAutoPlay(aplist);if (!this.activated) {this.initMilkbox();}
this.fireEvent('xmlGalleries');},checkFileType:function(file,type) {var href=null;if ($type(file)!='string') {href=file.retrieve('href');}
else {href=file;}
var regexp=new RegExp("\.("+type+")$","i");return href.split('?')[0].test(regexp);},getGallery:function(gallery) {var f=null;if (gallery.test(/^milkbox/i)) {f=this.families;}else {f=this.families.map(function(item) {var trimmed=item.trim();var name=trimmed.slice(0,trimmed.length).substr(8);var cleanName=name.replace(/(.+)]$/,"$1");return cleanName;});}
var i=f.indexOf(gallery);var g=(i!=-1)?this.galleries[i]:i;return g;},setFileProps:function(fileObj,propString) {var s=propString.split(',');s.each(function(p,i) {var clean=p.trim().split(':');fileObj.store(clean[0].trim(),clean[1].trim())},this);},changeOptions:function(obj) {if (!obj) {return;}
this.setOptions(obj);this.center.get('morph').setOptions({transition:this.options.resizeTransition,duration:this.options.resizeDuration});},saveOptions:function(obj) {if ($chk(obj)) {this.fullOptionsBkup=obj;}else {this.fullOptionsBkup=this.options;}},restoreOptions:function() {this.setOptions(this.fullOptionsBkup);b=this.options.canvasBorderWidth+' solid '+this.options.canvasBorderColor;this.canvas.setStyles({'border':b,'padding':this.options.canvasPadding});this.center.get('morph').setOptions({transition:this.options.resizeTransition,duration:this.options.resizeDuration});},reloadGalleries:function() {this.galleries=[];this.families=[];this.formtags=$$('select','textarea');this.prepareGalleries();this.removeGalleriesEvents();this.setGalleriesEvents();if (this.xmlFiles.length==0) {return;}
this.xmlFiles.each(function(xmlfile,index) {this.addGalleries(xmlfile);}.bind(this));},setAutoPlay:function(list) {var l=($type(list)=='object')?[list]:list;l.each(function(item) {var g=this.getGallery(item.gallery);if (g==-1) {return;}
var a=(item.autoplay==true)?item.autoplay:false;var d=($chk(item.delay)&&a)?item.delay:this.options.autoPlayDelay;g['options']={autoplay:a,delay:d}},this);},startAutoPlay:function(opt) {var g=-1;var i,d;if (opt&&opt.gallery) {if ($type(opt.gallery)=='array') {g=opt.gallery}
else if ($type(opt.gallery)=='string') {g=this.getGallery(opt.gallery);}}
if (g==-1) {g=this.galleries[0];}
d=(opt&&opt.delay&&($type(opt.delay)=='number'))?opt.delay*1000:(g['options']&&g['options'].delay)?g['options'].delay*1000:this.options.autoPlayDelay*1000;i=(opt&&opt.index&&($type(opt.index)=='number'))?opt.index:0;if (d<this.options.resizeDuration*2) {d=this.options.resizeDuration*2};this.options.autoPlayDelay=d/1000;if (!this.options.autoPlay) {this.setOptions({autoPlay:true,autoPlayDelay:this.options.autoPlayDelay});}
if (this.closed) {this.openMilkbox(g,i);if (this.mode!='fileGallery') {return;}
this.addEvent('fileReady',function() {this.intObj=this.next_prev_aux.periodical(d,this,[null,'next']);this.removeEvents('fileReady');}.bindWithEvent(this));}else {if (!this.closed) {this.next_prev_aux(null,'next');}
this.intObj=this.next_prev_aux.periodical(d,this,[null,'next']);}
this.paused=false;},stopAutoPlay:function() {if (this.intObj) {$clear(this.intObj);this.intObj=null;}
this.playpause.setStyle('backgroundPosition','0 -44px');this.paused=true;},removeGalleriesEvents:function() {this.galleries.each(function(gallery) {$$(gallery).removeEvents('click');},this);},setGalleriesEvents:function() {this.galleries.each(function(gallery) {$$(gallery).addEvent('click',function(e) {var button=($(e.target).match('a'))?$(e.target):$(e.target).getParent('a');e.preventDefault();var g=this.getGallery(button.rel);if (g.options&&g.options.autoplay) {this.setOptions({autoPlay:g.options.autoplay,autoPlayDelay:g.options.delay});}
if (this.options.autoPlay) {this.startAutoPlay({gallery:gallery,index:gallery.indexOf(button)});}else {this.openMilkbox(gallery,gallery.indexOf(button));}}.bindWithEvent(this));},this);},prepareEvents:function(xml) {this.setGalleriesEvents();this.next.addEvent('click',this.next_prev_aux.bindWithEvent(this,'next'));this.prev.addEvent('click',this.next_prev_aux.bindWithEvent(this,'prev'));$$(this.next,this.prev,this.close).addEvents({'mouseover':function() {this.setStyle('backgroundPosition','0 -22px');},'mouseout':function() {this.setStyle('backgroundPosition','0 0');}});$(window.document).addEvent('keydown',function(e) {if (this.mode!='fileGallery'||this.busy==true) {return;}
if (e.key=='right'||e.key=='space') {this.next_prev_aux(e,'next');}
else if (e.key=='left') {this.next_prev_aux(e,'prev');}
else if (e.key=='esc') {this.closeMilkbox();}}.bindWithEvent(this));this.playpause.addEvents({'mouseover':function(e) {if (this.paused==false) {this.playpause.setStyle('backgroundPosition','0 -22px');}
else {this.playpause.setStyle('backgroundPosition','0 -66px');}}.bindWithEvent(this),'mouseout':function() {if (this.paused==false) {this.playpause.setStyle('backgroundPosition','0 0');}
else {this.playpause.setStyle('backgroundPosition','0 -44px');}}.bindWithEvent(this),'click':function() {if (this.paused==false) {this.stopAutoPlay();this.paused=true;this.playpause.setStyle('backgroundPosition','0 -66px');}else {var d=(this.currentGallery.options&&this.currentGallery.options.delay)?this.currentGallery.options.delay:this.options.autoPlayDelay;this.startAutoPlay({gallery:this.currentGallery,index:this.currentIndex+1,delay:d});this.paused=false;this.playpause.setStyle('backgroundPosition','0 0');}}.bindWithEvent(this)});this.overlay.get('tween').addEvent('onComplete',function() {if (this.overlay.getStyle('opacity')==this.options.overlayOpacity) {this.center.tween('opacity',1);}else if (this.overlay.getStyle('opacity')==0) {this.overlay.setStyles({'height':0,'top':''});};}.bindWithEvent(this));this.center.get('morph').addEvent('onComplete',function() {if ($type(this.currentFile)=="element") {this.canvas.grab(this.currentFile);}else {(function() {this.canvas.grab(this.currentFile);}).delay(500,this);}
this.canvas.tween('opacity',1);var d=(!(this.mode=='showThisImage'))?this.currentGallery[this.currentIndex].retrieve('title'):this.specialDescription;if ($chk(d)) {this.description.innerHTML=d;};if (this.mode=='fileGallery') {this.count.appendText((this.currentIndex+1)+' of '+this.currentGallery.length);}
var currentCenterHeight=this.center.getStyle('height').toInt();this.navigation.setStyle('height',this.bottom.getStyle('height').toInt());var bottomSize=this.bottom.getSize().y;var targetOffset=(currentCenterHeight>this.canvas.getSize().y)?(this.bottom.getSize().y+this.canvas.getSize().y)-currentCenterHeight:bottomSize;this.bottom.setStyle('display','none');this.center.retrieve('setFinalHeight').start(currentCenterHeight,currentCenterHeight+targetOffset);}.bindWithEvent(this));this.center.retrieve('setFinalHeight').addEvent('onComplete',function() {this.bottom.setStyles({'visibility':'visible','display':'block'});$$(this.description,this.navigation).setStyle('visibility','visible');var scrollSize=$(window).getScrollSize().y;var scrollTop=$(window).getScroll().y;this.overlay.setStyles({'height':scrollSize+scrollTop,'top':-scrollTop});this.busy=false;}.bindWithEvent(this));window.addEvent('resize',function() {if (this.overlay.getStyle('opacity')==0) {return;};var scrollSize=$(window).getScrollSize().y;var scrollTop=$(window).getScroll().y;this.overlay.setStyles({'height':scrollSize+scrollTop,'top':-scrollTop});}.bindWithEvent(this));$$(this.overlay,this.close).addEvent('click',function() {this.closeMilkbox();}.bindWithEvent(this));this.eventsok=true;},next_prev_aux:function(e,direction) {if (e) {e.preventDefault();this.stopAutoPlay();}else {if (this.busy||!this.fileReady) {return;}}
this.busy=true;var backupIndex=this.currentIndex;if (direction=="next") {var i=(this.currentIndex!=this.currentGallery.length-1)?this.currentIndex+=1:this.currentIndex=0;var _i=(this.currentIndex!=this.currentGallery.length-1)?this.currentIndex+1:0;}else {var i=(this.currentIndex!=0)?this.currentIndex-=1:this.currentIndex=this.currentGallery.length-1;var _i=(this.currentIndex!=0)?this.currentIndex-1:this.currentGallery.length-1;};this.canvas.empty();this.description.empty();this.count.empty();this.loadFile(this.currentGallery[i],[this.currentGallery[_i]]);},prepareEffects:function() {this.overlay.set('tween',{duration:'short',link:'cancel'});this.center.set('tween',{duration:'short',link:'chain'});this.center.set('morph',{duration:this.options.resizeDuration,link:'chain',transition:this.options.resizeTransition});this.center.store('setFinalHeight',new Fx.Tween(this.center,{property:'height',duration:'short'}));this.canvas.set('tween',{link:'chain'});},prepareGalleries:function(responseElements) {var milkbox_a=[];var gIndex;var a_tags=(responseElements)?responseElements:$$('a');a_tags.each(function(a) {if (a.rel&&a.rel.test(/^milkbox/i)&&a.href.split('?')[0].test(/\.(gif|jpg|jpeg|png|swf)$/i)) {if (a.rel.length>7&&!this.families.contains(a.rel)) {this.families.push(a.rel);};milkbox_a.push(a);}},this);milkbox_a.each(function(a) {$(a).store('href',a.href);$(a).store('rel',a.rel);$(a).store('title',a.title);if (this.checkFileType(a.href,"swf")) {this.setFileProps($(a),a.rev);}
if (this.options.removeTitle) {$(a).removeProperty('title');}
if (a.rel.length>7) {this.families.each(function(f,i) {if (a.rel==f) {var gMounted=false;var index;this.galleries.each(function(g,k) {if (g[0].rel==f) {gMounted=true;index=k;return;}});if (gMounted==true) {this.galleries[index].push($(a));}
else {this.galleries.push([$(a)]);}};},this);}else {this.galleries.push([$(a)]);};},this);},prepareHTML:function() {this.overlay=new Element('div',{'id':'mbOverlay','styles':{'opacity':0,'visibility':'visible','height':0,'overflow':'hidden'}}).inject($(document.body));this.center=new Element('div',{'id':'mbCenter','styles':{'width':this.options.initialWidth,'height':this.options.initialHeight,'marginLeft':-(this.options.initialWidth/2),'opacity':0}}).inject($(document.body));this.canvas=new Element('div',{'id':'mbCanvas'}).inject(this.center);this.bottom=new Element('div',{'id':'mbBottom'}).inject(this.center).setStyle('visibility','hidden');this.navigation=new Element('div',{'id':'mbNavigation'}).setStyle('visibility','hidden');this.description=new Element('div',{'id':'mbDescription'}).setStyle('visibility','hidden');this.bottom.adopt(this.navigation,this.description,new Element('div',{'class':'clear'}));this.close=new Element('a',{'id':'mbCloseLink'});this.next=new Element('a',{'id':'mbNextLink'});this.prev=new Element('a',{'id':'mbPrevLink'});this.playpause=new Element('a',{'id':'mbPlayPause'});this.count=new Element('span',{'id':'mbCount'});$$(this.next,this.prev,this.count,this.playpause).setStyle('display','none');this.navigation.adopt(this.close,this.next,this.prev,this.playpause,new Element('div',{'class':'clear'}),this.count);},closeMilkbox:function() {this.cancelAllEffects();this.stopAutoPlay();this.setOptions(this.autoPlayBkup);this.currentFile=null;this.currentIndex=null;this.currentGallery=null;this.currentRequest=null;this.currentResponse=null;$$(this.prev,this.next,this.playpause,this.count).setStyle('display','none');this.playpause.setStyle('backgroundPosition','0 0');var border=this.center.getStyle('border-right-width').toInt();var navWidth=this.close.getSize().x+border;this.navigation.setStyles({'width':navWidth,'height':'','visibility':'hidden'});this.description.setStyle('margin-right',navWidth);this.description.empty();this.bottom.setStyles({'visibility':'hidden','display':''});this.canvas.setStyles({'opacity':0,'width':'','height':''});this.canvas.empty();this.count.empty();this.center.setStyles({'opacity':0,'width':this.options.initialWidth,'height':this.options.initialHeight,'marginLeft':-(this.options.initialWidth/2)});this.overlay.tween('opacity',0);if (this.formtags.length!=0) {this.formtags.setStyle('display','')};this.mode=null;this.closed=true;this.first=true;this.fileReady=false;this.fireEvent('closed');},cancelAllEffects:function() {this.overlay.get('tween').cancel();this.center.get('morph').cancel();this.center.get('tween').cancel();this.center.retrieve('setFinalHeight').cancel();this.canvas.get('tween').cancel();}});window.addEvent('domready',function() {milkbox=new Milkbox();});
/*
Script: Slideshow.js
	Slideshow - A javascript class for Mootools to stream and animate the presentation of images on your website.
License:
	MIT-style license.
Copyright:
	Copyright (c) 2008 [Aeron Glemann](http://www.electricprism.com/aeron/).
Dependencies:
	Mootools 1.2 Core: Fx.Morph, Fx.Tween, Selectors, Element.Dimensions.
	Mootools 1.2 More: Assets.
*/
Slideshow=new Class({Implements:[Chain,Events,Options],options:{captions:false,center:true,classes:[],controller:false,delay:2000,duration:750,fast:false,height:false,href:'',hu:'',linked:false,loader:{'animate':['/css/slideshow/loader-#.png',12]},loop:true,match:/\?slide=(\d+)$/,overlap:true,paused:false,properties:['href','rel','rev','title'],random:false,replace:[/(\.[^\.]+)$/,'t$1'],resize:'width',slide:0,thumbnails:false,titles:true,transition:function(p) {return-(Math.cos(Math.PI*p)-1)/2;},width:false},initialize:function(el,data,options) {this.setOptions(options);this.slideshow=$(el);if (!this.slideshow)
return;this.slideshow.set('styles',{'display':'block','position':'relative','z-index':0});var match=window.location.href.match(this.options.match);this.slide=(this.options.match&&match)?match[1].toInt():this.options.slide;this.counter=this.delay=this.transition=0;this.direction='left';this.paused=false;if (!this.options.overlap)
this.options.duration*=2;var anchor=this.slideshow.getElement('a')||new Element('a');if (!this.options.href)
this.options.href=anchor.get('href')||'';if (this.options.hu.length&&!this.options.hu.test(/\/$/))
this.options.hu+='/';if (this.options.fast===true)
this.options.fast=2;var keys=['slideshow','first','prev','play','pause','next','last','images','captions','controller','thumbnails','hidden','visible','inactive','active','loader'];var values=keys.map(function(key,i) {return this.options.classes[i]||key;},this);this.classes=values.associate(keys);this.classes.get=function() {var str='.'+this.slideshow;for(var i=0,l=arguments.length;i<l;i++)
str+=('-'+this[arguments[i]]);return str;}.bind(this.classes);if (!data) {this.options.hu='';data={};var thumbnails=this.slideshow.getElements(this.classes.get('thumbnails')+' img');this.slideshow.getElements(this.classes.get('images')+' img').each(function(img,i) {var src=img.get('src');var caption=$pick(img.get('alt'),img.get('title'),'');var parent=img.getParent();var properties=(parent.get('tag')=='a')?parent.getProperties:{};var href=img.getParent().get('href')||'';var thumbnail=(thumbnails[i])?thumbnails[i].get('src'):'';data[src]={'caption':caption,'href':href,'thumbnail':thumbnail};});}
var loaded=this.load(data);if (!loaded)
return;this.events=$H({'keydown':[],'keyup':[],'mousemove':[]});var keyup=function(e) {switch(e.key) {case'left':this.prev(e.shift);break;case'right':this.next(e.shift);break;case'p':this.pause();break;}}.bind(this);this.events.keyup.push(keyup);document.addEvent('keyup',keyup);var el=this.slideshow.getElement(this.classes.get('images'));var images=(el)?el.empty():new Element('div',{'class':this.classes.get('images').substr(1)}).inject(this.slideshow);var div=images.getSize();this.height=this.options.height||div.y;this.width=this.options.width||div.x;images.set({'styles':{'display':'block','height':this.height,'overflow':'hidden','position':'relative','width':this.width}});this.slideshow.store('images',images);this.a=this.image=this.slideshow.getElement('img')||new Element('img');if (Browser.Engine.trident&&Browser.Engine.version>4)
this.a.style.msInterpolationMode='bicubic';this.a.set('styles',{'display':'none','position':'absolute','zIndex':1});this.b=this.a.clone();[this.a,this.b].each(function(img) {anchor.clone().cloneEvents(anchor).grab(img).inject(images);});if (this.options.captions)
this._captions();if (this.options.controller)
this._controller();if (this.options.loader)
this._loader();if (this.options.thumbnails)
this._thumbnails();this._preload();},go:function(n,direction) {if ((this.slide-1+this.data.images.length)%this.data.images.length==n||$time()<this.transition)
return;$clear(this.timer);this.delay=0;this.direction=(direction)?direction:((n<this.slide)?'right':'left');this.slide=n;if (this.preloader)
this.preloader=this.preloader.destroy();this._preload(this.options.fast==2||(this.options.fast==1&&this.paused));},first:function() {this.prev(true);},prev:function(first) {var n=0;if (!first) {if (this.options.random) {if (this.showed.i<2)
return;this.showed.i-=2;n=this.showed.array[this.showed.i];}
else
n=(this.slide-2+this.data.images.length)%this.data.images.length;}
this.go(n,'right');},pause:function(p) {if ($chk(p))
this.paused=(p)?false:true;if (this.paused) {this.paused=false;this.delay=this.transition=0;this.timer=this._preload.delay(100,this);[this.a,this.b].each(function(img) {['morph','tween'].each(function(p) {if (this.retrieve(p))this.get(p).resume();},img);});if (this.options.controller)
this.slideshow.getElement('.'+this.classes.pause).removeClass(this.classes.play);}
else {this.paused=true;this.delay=Number.MAX_VALUE;this.transition=0;$clear(this.timer);[this.a,this.b].each(function(img) {['morph','tween'].each(function(p) {if (this.retrieve(p))this.get(p).pause();},img);});if (this.options.controller)
this.slideshow.getElement('.'+this.classes.pause).addClass(this.classes.play);}},next:function(last) {var n=(last)?this.data.images.length-1:this.slide;this.go(n,'left');},last:function() {this.next(true);},load:function(data) {this.firstrun=true;this.showed={'array':[],'i':0};if ($type(data)=='array') {this.options.captions=false;data=new Array(data.length).associate(data.map(function(image,i) {return image+'?'+i}));}
this.data={'images':[],'captions':[],'hrefs':[],'thumbnails':[]};for(var image in data) {var obj=data[image]||{};var caption=(obj.caption)?obj.caption.trim():'';var href=(obj.href)?obj.href.trim():((this.options.linked)?this.options.hu+image:this.options.href);var thumbnail=(obj.thumbnail)?obj.thumbnail.trim():image.replace(this.options.replace[0],this.options.replace[1]);this.data.images.push(image);this.data.captions.push(caption);this.data.hrefs.push(href);this.data.thumbnails.push(thumbnail);}
if (this.options.random)
this.slide=$random(0,this.data.images.length-1);if (this.options.thumbnails&&this.slideshow.retrieve('thumbnails'))
this._thumbnails();if (this.slideshow.retrieve('images')) {[this.a,this.b].each(function(img) {['morph','tween'].each(function(p) {if (this.retrieve(p))this.get(p).cancel();},img);});this.slide=this.transition=0;this.go(0);}
return this.data.images.length;},destroy:function(p) {this.events.each(function(array,e) {array.each(function(fn) {document.removeEvent(e,fn);});});this.pause(1);if (this.options.loader)
$clear(this.slideshow.retrieve('loader').retrieve('timer'));if (this.options.thumbnails)
$clear(this.slideshow.retrieve('thumbnails').retrieve('timer'));this.slideshow.uid=Native.UID++;if (p)
this.slideshow[p]();},_preload:function(fast) {if (!this.preloader)
this.preloader=new Asset.image(this.options.hu+this.data.images[this.slide],{'onload':function() {this.store('loaded',true);}});if (this.preloader.retrieve('loaded')&&$time()>this.delay&&$time()>this.transition) {if (this.stopped) {if (this.options.captions)
this.slideshow.retrieve('captions').get('morph').cancel().start(this.classes.get('captions','hidden'));this.pause(1);if (this.end)
this.fireEvent('end');this.stopped=this.end=false;return;}
this.image=(this.counter%2)?this.b:this.a;this.image.set('styles',{'display':'block','height':'auto','visibility':'hidden','width':'auto','zIndex':this.counter});['src','height','width'].each(function(prop) {this.image.set(prop,this.preloader.get(prop));},this);this._resize(this.image);this._center(this.image);var anchor=this.image.getParent();if (this.data.hrefs[this.slide])
anchor.set('href',this.data.hrefs[this.slide]);else
anchor.erase('href');var text=(this.data.captions[this.slide])?this.data.captions[this.slide].replace(/<.+?>/gm,'').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,"'"):'';this.image.set('alt',text);if (this.options.titles)
anchor.set('title',text);if (this.options.loader)
this.slideshow.retrieve('loader').fireEvent('hide');if (this.options.captions)
this.slideshow.retrieve('captions').fireEvent('update',fast);if (this.options.thumbnails)
this.slideshow.retrieve('thumbnails').fireEvent('update',fast);this._show(fast);this._loaded();}
else {if ($time()>this.delay&&this.options.loader)
this.slideshow.retrieve('loader').fireEvent('show');this.timer=(this.paused&&this.preloader.retrieve('loaded'))?null:this._preload.delay(100,this,fast);}},_show:function(fast) {if (!this.image.retrieve('morph')) {var options=(this.options.overlap)?{'duration':this.options.duration,'link':'cancel'}:{'duration':this.options.duration/2,'link':'chain'};$$(this.a,this.b).set('morph',$merge(options,{'onStart':this._start.bind(this),'onComplete':this._complete.bind(this),'transition':this.options.transition}));}
var hidden=this.classes.get('images',((this.direction=='left')?'next':'prev'));var visible=this.classes.get('images','visible');var img=(this.counter%2)?this.a:this.b;if (fast) {img.get('morph').cancel().set(hidden);this.image.get('morph').cancel().set(visible);}
else {if (this.options.overlap) {img.get('morph').set(visible);this.image.get('morph').set(hidden).start(visible);}
else {var fn=function(hidden,visible) {this.image.get('morph').set(hidden).start(visible);}.pass([hidden,visible],this);hidden=this.classes.get('images',((this.direction=='left')?'prev':'next'));img.get('morph').set(visible).start(hidden).chain(fn);}}},_loaded:function() {this.counter++;this.delay=(this.paused)?Number.MAX_VALUE:$time()+this.options.duration+this.options.delay;this.direction='left';this.transition=(this.options.fast==2||(this.options.fast==1&&this.paused))?0:$time()+this.options.duration;if (this.slide+1==this.data.images.length&&!this.options.loop&&!this.options.random)
this.stopped=this.end=true;if (this.options.random) {this.showed.i++;if (this.showed.i>=this.showed.array.length) {var n=this.slide;if (this.showed.array.getLast()!=n)this.showed.array.push(n);while(this.slide==n)
this.slide=$random(0,this.data.images.length-1);}
else
this.slide=this.showed.array[this.showed.i];}
else
this.slide=(this.slide+1)%this.data.images.length;if (this.image.getStyle('visibility')!='visible')
(function() {this.image.setStyle('visibility','visible');}).delay(1,this);if (this.preloader)
this.preloader=this.preloader.destroy();this._preload();},_center:function(img) {if (this.options.center) {var size=img.getSize();img.set('styles',{'left':(size.x-this.width)/-2,'top':(size.y-this.height)/-2});}},_resize:function(img) {if (this.options.resize) {var h=this.preloader.get('height'),w=this.preloader.get('width');var dh=this.height/h,dw=this.width/w,d;if (this.options.resize=='length')
d=(dh>dw)?dw:dh;else
d=(dh>dw)?dh:dw;img.set('styles',{height:Math.ceil(h*d),width:Math.ceil(w*d)});}},_start:function() {this.fireEvent('start');},_complete:function() {if (this.firstrun&&this.options.paused) {this.firstrun=false;this.pause(1);}
this.fireEvent('complete');},_captions:function() {if (this.options.captions===true)
this.options.captions={};var el=this.slideshow.getElement(this.classes.get('captions'));var captions=(el)?el.empty():new Element('div',{'class':this.classes.get('captions').substr(1)}).inject(this.slideshow);captions.set({'events':{'update':function(fast) {var captions=this.slideshow.retrieve('captions');var empty=(this.data.captions[this.slide]==='');if (fast) {var p=(empty)?'hidden':'visible';captions.set('html',this.data.captions[this.slide]).get('morph').cancel().set(this.classes.get('captions',p));}
else {var fn=(empty)?$empty:function(n) {this.slideshow.retrieve('captions').set('html',this.data.captions[n]).morph(this.classes.get('captions','visible'))}.pass(this.slide,this);captions.get('morph').cancel().start(this.classes.get('captions','hidden')).chain(fn);}}.bind(this)},'morph':$merge(this.options.captions,{'link':'chain'})});this.slideshow.store('captions',captions);},_controller:function() {if (this.options.controller===true)
this.options.controller={};var el=this.slideshow.getElement(this.classes.get('controller'));var controller=(el)?el.empty():new Element('div',{'class':this.classes.get('controller').substr(1)}).inject(this.slideshow);var ul=new Element('ul').inject(controller);$H({'first':'Shift + Leftwards Arrow','prev':'Leftwards Arrow','pause':'P','next':'Rightwards Arrow','last':'Shift + Rightwards Arrow'}).each(function(accesskey,action) {var li=new Element('li',{'class':(action=='pause'&&this.options.paused)?this.classes.play+' '+this.classes[action]:this.classes[action]}).inject(ul);var a=this.slideshow.retrieve(action,new Element('a',{'title':((action=='pause')?this.classes.play.capitalize()+' / ':'')+this.classes[action].capitalize()+' ['+accesskey+']'}).inject(li));a.set('events',{'click':function(action) {this[action]();}.pass(action,this),'mouseenter':function(active) {this.addClass(active);}.pass(this.classes.active,a),'mouseleave':function(active) {this.removeClass(active);}.pass(this.classes.active,a)});},this);controller.set({'events':{'hide':function(hidden) {if (!this.retrieve('hidden'))
this.store('hidden',true).morph(hidden);}.pass(this.classes.get('controller','hidden'),controller),'show':function(visible) {if (this.retrieve('hidden'))
this.store('hidden',false).morph(visible);}.pass(this.classes.get('controller','visible'),controller)},'morph':$merge(this.options.controller,{'link':'cancel'})}).store('hidden',false);var keydown=function(e) {if (['left','right','p'].contains(e.key)) {var controller=this.slideshow.retrieve('controller');if (controller.retrieve('hidden'))
controller.get('morph').set(this.classes.get('controller','visible'));switch(e.key) {case'left':this.slideshow.retrieve((e.shift)?'first':'prev').fireEvent('mouseenter');break;case'right':this.slideshow.retrieve((e.shift)?'last':'next').fireEvent('mouseenter');break;default:this.slideshow.retrieve('pause').fireEvent('mouseenter');break;}}}.bind(this);this.events.keydown.push(keydown);var keyup=function(e) {if (['left','right','p'].contains(e.key)) {var controller=this.slideshow.retrieve('controller');if (controller.retrieve('hidden'))
controller.store('hidden',false).fireEvent('hide');switch(e.key) {case'left':this.slideshow.retrieve((e.shift)?'first':'prev').fireEvent('mouseleave');break;case'right':this.slideshow.retrieve((e.shift)?'last':'next').fireEvent('mouseleave');break;default:this.slideshow.retrieve('pause').fireEvent('mouseleave');break;}}}.bind(this);this.events.keyup.push(keyup);var mousemove=function(e) {var images=this.slideshow.retrieve('images').getCoordinates();if (e.page.x>images.left&&e.page.x<images.right&&e.page.y>images.top&&e.page.y<images.bottom)
this.slideshow.retrieve('controller').fireEvent('show');else
this.slideshow.retrieve('controller').fireEvent('hide');}.bind(this);this.events.mousemove.push(mousemove);document.addEvents({'keydown':keydown,'keyup':keyup,'mousemove':mousemove});this.slideshow.retrieve('controller',controller).fireEvent('hide');},_loader:function() {if (this.options.loader===true)
this.options.loader={};var loader=new Element('div',{'class':this.classes.get('loader').substr(1),'morph':$merge(this.options.loader,{'link':'cancel'})}).store('hidden',false).store('i',1).inject(this.slideshow.retrieve('images'));if (this.options.loader.animate) {for(var i=0;i<this.options.loader.animate[1];i++)
img=new Asset.image(this.options.loader.animate[0].replace(/#/,i));if (Browser.Engine.trident4&&this.options.loader.animate[0].contains('png'))
loader.setStyle('backgroundImage','none');}
loader.set('events',{'animate':function() {var loader=this.slideshow.retrieve('loader');var i=(loader.retrieve('i').toInt()+1)%this.options.loader.animate[1];loader.store('i',i);var img=this.options.loader.animate[0].replace(/#/,i);if (Browser.Engine.trident4&&this.options.loader.animate[0].contains('png'))
loader.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+img+'", sizingMethod="scale")';else
loader.setStyle('backgroundImage','url('+img+')');}.bind(this),'hide':function() {var loader=this.slideshow.retrieve('loader');if (!loader.retrieve('hidden')) {loader.store('hidden',true).morph(this.classes.get('loader','hidden'));if (this.options.loader.animate)
$clear(loader.retrieve('timer'));}}.bind(this),'show':function() {var loader=this.slideshow.retrieve('loader');if (loader.retrieve('hidden')) {loader.store('hidden',false).morph(this.classes.get('loader','visible'));if (this.options.loader.animate)
loader.store('timer',function() {this.fireEvent('animate');}.periodical(50,loader));}}.bind(this)});this.slideshow.retrieve('loader',loader).fireEvent('hide');},_thumbnails:function() {if (this.options.thumbnails===true)
this.options.thumbnails={};var el=this.slideshow.getElement(this.classes.get('thumbnails'));var thumbnails=(el)?el.empty():new Element('div',{'class':this.classes.get('thumbnails').substr(1)}).inject(this.slideshow);thumbnails.setStyle('overflow','hidden');var ul=new Element('ul',{'tween':{'link':'cancel'}}).inject(thumbnails);this.data.thumbnails.each(function(thumbnail,i) {var li=new Element('li').inject(ul);var a=new Element('a',{'events':{'click':function(i) {this.go(i);return false;}.pass(i,this),'loaded':function() {this.data.thumbnails.pop();if (!this.data.thumbnails.length) {var div=thumbnails.getCoordinates();var props=thumbnails.retrieve('props');var limit=0,pos=props[1],size=props[2];thumbnails.getElements('li').each(function(li) {var li=li.getCoordinates();if (li[pos]>limit)limit=li[pos];},this);thumbnails.store('limit',div[size]+div[props[0]]-limit);}}.bind(this)},'href':this.options.hu+this.data.images[i],'morph':$merge(this.options.thumbnails,{'link':'cancel'})}).inject(li);if (this.data.captions[i]&&this.options.titles)
a.set('title',this.data.captions[i].replace(/<.+?>/gm,'').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,"'"));var img=new Asset.image(this.options.hu+thumbnail,{'onload':function() {this.fireEvent('loaded');}.bind(a)}).inject(a);},this);thumbnails.set('events',{'scroll':function(n,fast) {var div=this.getCoordinates();var ul=this.getElement('ul').getPosition();var props=this.retrieve('props');var axis=props[3],delta,pos=props[0],size=props[2],value;var tween=this.getElement('ul').get('tween',{'property':pos});if ($chk(n)) {var li=this.getElements('li')[n].getCoordinates();delta=div[pos]+(div[size]/2)-(li[size]/2)-li[pos]
value=(ul[axis]-div[pos]+delta).limit(this.retrieve('limit'),0);if (fast)
tween.set(value);else
tween.start(value);}
else {var area=div[props[2]]/3,page=this.retrieve('page'),velocity=-0.2;if (page[axis]<(div[pos]+area))
delta=(page[axis]-div[pos]-area)*velocity;else if (page[axis]>(div[pos]+div[size]-area))
delta=(page[axis]-div[pos]-div[size]+area)*velocity;if (delta) {value=(ul[axis]-div[pos]+delta).limit(this.retrieve('limit'),0);tween.set(value);}}}.bind(thumbnails),'update':function(fast) {var thumbnails=this.slideshow.retrieve('thumbnails');thumbnails.getElements('a').each(function(a,i) {if (i==this.slide) {if (!a.retrieve('active',false)) {a.store('active',true);var active=this.classes.get('thumbnails','active');if (fast)a.get('morph').set(active);else a.morph(active);}}
else {if (a.retrieve('active',true)) {a.store('active',false);var inactive=this.classes.get('thumbnails','inactive');if (fast)a.get('morph').set(inactive);else a.morph(inactive);}}},this);if (!thumbnails.retrieve('mouseover'))
thumbnails.fireEvent('scroll',[this.slide,fast]);}.bind(this)})
var div=thumbnails.getCoordinates();thumbnails.store('props',(div.height>div.width)?['top','bottom','height','y']:['left','right','width','x']);var mousemove=function(e) {var div=this.getCoordinates();if (e.page.x>div.left&&e.page.x<div.right&&e.page.y>div.top&&e.page.y<div.bottom) {this.store('page',e.page);if (!this.retrieve('mouseover')) {this.store('mouseover',true);this.store('timer',function() {this.fireEvent('scroll');}.periodical(50,this));}}
else {if (this.retrieve('mouseover')) {this.store('mouseover',false);$clear(this.retrieve('timer'));}}}.bind(thumbnails);this.events.mousemove.push(mousemove);document.addEvent('mousemove',mousemove);this.slideshow.store('thumbnails',thumbnails);}});

window.addEvent('domready',function() {
	$$('a[href^="http"]&&a:not([rel$=al])').each(function(a) {
		if (!a.get('href').contains(window.location.host)) {
			a.addClass('external');
			a.set('target', '_blank');
		}
	});
	$$('a[rel=external]').each(function(a) {
		a.set('target', '_blank');
	});
});
