function disableSelection(element){element.onselectstart=returnFalse;element.unselectable="on";element.style.MozUserSelect="none";element.style.cursor="default";}
function setOpacity(element,opacity){if(Browser.instance().isIEBased()){element.style.filter="alpha(opacity="+Math.round(opacity*100)+")";}else{element.style.opacity=opacity;}}
function stopEvent(e){if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble=true;}}
function disableContextMenu(e){e.oncontextmenu=function(){return false;}}
function inherit(subclass,superclass){var instance=function(){};instance.prototype=superclass.prototype;subclass.prototype=new instance();}
function callback(instance,method){return function(){method.apply(instance,arguments);};}
function assert(condition){if(!condition)throw new Error("Assertion failed");}
function arrayRemove(array,elem){for(var i=0;i<array.length;i++){if(array[i]==elem){array.splice(i,1);return true;}}
return false;}
function returnFalse(){return false;}
function Photo(path,url){this.path=path;this.url=url;}
function SlideShow(container,photos,shadow,width,height,opt_padding){this.photos_=photos;this.shadow_=shadow;this.width_=width;this.height_=height;this.padding_=opt_padding||15;this.spacer_="images/clear.png";this.container_=container;var innerContainer=document.createElement("div");innerContainer.style.position="relative";innerContainer.style.overflow="hidden";innerContainer.style.height=(this.height_+this.padding_)+"px";container.appendChild(innerContainer);var mover=document.createElement("div");mover.style.position="absolute";mover.style.left="0px";mover.style.top="0px";innerContainer.appendChild(mover);this.mover_=mover;}
SlideShow.prototype.load=function(){var totalWidth=this.container_.offsetWidth;var numVisible=Math.ceil((totalWidth+this.padding_)/(this.width_+this.padding_));var numImages=numVisible+2;var images=[];for(var i=0;i<numImages;i++){var image=this.createImage_(i-1);images.push(image);this.configureImage_(image,i-1);}
this.images_=images;this.index_=0;}
SlideShow.prototype.right=function(){this.animate_(-1);}
SlideShow.prototype.left=function(){this.animate_(1);}
SlideShow.prototype.animate_=function(multiplier){var delta=multiplier*Math.round(this.container_.offsetWidth*0.75);this.start_=this.mover_.offsetLeft;this.distance_=delta;if(this.transition_)this.transition_.cancel();this.transition_=new Transition(SineCurve,750,callback(this,this.animateStep_));this.transition_.run();}
SlideShow.prototype.animateStep_=function(percentage){this.mover_.style.left=(this.start_+this.distance_*percentage)+"px";this.rotate_();}
SlideShow.prototype.rotate_=function(){var correctIndex=Math.round(this.mover_.offsetLeft/(this.width_+this.padding_));while(correctIndex<this.index_){this.rotateRight_();}
while(correctIndex>this.index_){this.rotateLeft_();}}
SlideShow.prototype.rotateRight_=function(){var left=this.images_.splice(0,1)[0];this.configureImage_(left,this.images_.length-this.index_);this.images_.push(left);this.index_--;}
SlideShow.prototype.rotateLeft_=function(){var right=this.images_.pop();this.configureImage_(right,-2-this.index_);this.images_.unshift(right);this.index_++;}
SlideShow.prototype.createImage_=function(position){var foreground=document.createElement("img");foreground.style.width=this.width_+"px";foreground.style.height=this.height_+"px";foreground.style.zIndex=2;foreground.style.position="absolute";foreground.style.border="0px";foreground.src=this.spacer_;var shadow=document.createElement("img");shadow.src=this.shadow_;shadow.style.zIndex=1;shadow.style.position="absolute";disableSelection(shadow);disableContextMenu(shadow);var container=document.createElement("div");container.style.position="absolute";container.style.top="0px";var link=document.createElement("a");link.target="_blank";this.mover_.appendChild(container);container.appendChild(shadow);container.appendChild(link);link.appendChild(foreground);return{container:container,foreground:foreground,shadow:shadow,link:link};}
SlideShow.prototype.configureImage_=function(image,index){var left=(index*(this.width_+this.padding_))+"px";var index=index%this.photos_.length;if(index<0)index+=this.photos_.length;image.foreground.src=this.spacer_;image.foreground.src=this.photos_[index].path;image.link.href=this.photos_[index].url;image.foreground.style.left=left;image.shadow.style.left=left;}
function Transition(curve,milliseconds,callback,opt_timing){this.curve_=curve;this.milliseconds_=milliseconds;this.callback_=callback;this.start_=new Date().getTime();this.timing_=opt_timing||25;var self=this;this.runCallback_=function(){self.timeout_=null;self.run();};}
Transition.prototype.run=function(){if(!this.hasNext())return;this.callback_(this.next());this.timeout_=setTimeout(this.runCallback_,this.timing_);}
Transition.prototype.hasNext=function(){if(this.done_)return this.oneLeft_;var now=new Date().getTime();if((now-this.start_)>this.milliseconds_){this.done_=true;this.oneLeft_=true;}
return true;}
Transition.prototype.cancel=function(){if(this.timeout_){clearTimeout(this.timeout_);}}
Transition.prototype.next=function(){this.oneLeft_=false;var now=new Date().getTime();var percentage=Math.min(1,(now-this.start_)/this.milliseconds_);return this.curve_(percentage);}
function SineCurve(percentage){return(1-Math.cos(percentage*Math.PI))/2;}
function LinearCurve(percentage){return percentage;}