﻿var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}};Object.extend=function(a,b){for(property in b)a[property]=b[property];return a};Function.prototype.bind=function(b){var a=this;return function(){return a.apply(b,arguments)}};Function.prototype.bindAsEventListener=function(b){var a=this;return function(c){a.call(b,c||window.event)}};function $(){if(arguments.length==1)return b(arguments[0]);var a=[];$c(arguments).each(function(c){a.push(b(c))});return a;function b(a){if(typeof a=="string")a=document.getElementById(a);return a}}if(!window.Element)var Element={};Object.extend(Element,{remove:function(a){a=$(a);a.parentNode.removeChild(a)},hasClassName:function(a,c){a=$(a);if(!a)return;var b=false;a.className.split(" ").each(function(a){if(a==c)b=true});return b},addClassName:function(a,b){a=$(a);Element.removeClassName(a,b);a.className+=" "+b},removeClassName:function(a,c){a=$(a);if(!a)return;var b="";a.className.split(" ").each(function(a,d){if(a!=c){if(d>0)b+=" ";b+=a}});a.className=b},cleanWhitespace:function(a){a=$(a);$c(a.childNodes).each(function(a){a.nodeType==3&&!/\S/.test(a.nodeValue)&&Element.remove(a)})},find:function(a,b){a=$(a)[b];while(a.nodeType!=1)a=a[b];return a}});var Position={cumulativeOffset:function(a){var c=0,b=0;do{c+=a.offsetTop||0;b+=a.offsetLeft||0;a=a.offsetParent}while(a);return [b,c]}};document.getElementsByClassName=function(b){var c=document.getElementsByTagName("*")||document.all,a=[];$c(c).each(function(c){Element.hasClassName(c,b)&&a.push(c)});return a};Array.prototype.iterate=function(b){for(var a=0;a<this.length;a++)b(this[a],a)};if(!Array.prototype.each)Array.prototype.each=Array.prototype.iterate;function $c(c){for(var b=[],a=0;a<c.length;a++)b.push(c[a]);return b}var fx={};fx.Base=function(){};fx.Base.prototype={setOptions:function(a){this.options={duration:500,onComplete:"",transition:fx.sinoidal};Object.extend(this.options,a||{})},step:function(){var a=this,b=(new Date).getTime();if(b>=a.options.duration+a.startTime){a.now=a.to;clearInterval(a.timer);a.timer=null;a.options.onComplete&&setTimeout(a.options.onComplete.bind(a),10)}else{var c=(b-a.startTime)/a.options.duration;a.now=a.options.transition(c)*(a.to-a.from)+a.from}a.increase()},custom:function(b,c){var a=this;if(a.timer!=null)return;a.from=b;a.to=c;a.startTime=(new Date).getTime();a.timer=setInterval(a.step.bind(a),13)},hide:function(){this.now=0;this.increase()},clearTimer:function(){clearInterval(this.timer);this.timer=null}};fx.Layout=Class.create();fx.Layout.prototype=Object.extend(new fx.Base,{initialize:function(c,b){var a=this;a.el=$(c);a.el.style.overflow="hidden";a.iniWidth=a.el.offsetWidth;a.iniHeight=a.el.offsetHeight;a.setOptions(b)}});fx.Height=Class.create();Object.extend(Object.extend(fx.Height.prototype,fx.Layout.prototype),{increase:function(){this.el.style.height=this.now+"px"},toggle:function(){var a=this;if(a.el.offsetHeight>0)a.custom(a.el.offsetHeight,0);else a.custom(0,a.el.scrollHeight)}});fx.Width=Class.create();Object.extend(Object.extend(fx.Width.prototype,fx.Layout.prototype),{increase:function(){this.el.style.width=this.now+"px"},toggle:function(){var a=this;if(a.el.offsetWidth>0)a.custom(a.el.offsetWidth,0);else a.custom(0,a.iniWidth)}});fx.Opacity=Class.create();fx.Opacity.prototype=Object.extend(new fx.Base,{initialize:function(c,b){var a=this;a.el=$(c);a.now=1;a.increase();a.setOptions(b)},increase:function(){var a=this;if(a.now==1&&/Firefox/.test(navigator.userAgent))a.now=.9999;a.setOpacity(a.now)},setOpacity:function(b){var a=this;if(b==0&&a.el.style.visibility!="hidden")a.el.style.visibility="hidden";else if(a.el.style.visibility!="visible")a.el.style.visibility="visible";if(window.ActiveXObject)a.el.style.filter="alpha(opacity="+b*100+")";a.el.style.opacity=b},toggle:function(){if(this.now>0)this.custom(1,0);else this.custom(0,1)}});fx.sinoidal=function(a){return -Math.cos(a*Math.PI)/2+.5};fx.linear=function(a){return a};fx.cubic=function(a){return Math.pow(a,3)};fx.circ=function(a){return Math.sqrt(a)};var fileLoadingImage="/images/litebox/loading.gif",fileBottomNavCloseImage="/images/litebox/closelabel.gif",resizeSpeed=3,borderSize=10,imageArray=[],activeImage;if(resizeSpeed>10)resizeSpeed=10;if(resizeSpeed<1)resizeSpeed=1;resizeDuration=(11-resizeSpeed)*100;Object.extend(Element,{hide:function(){for(var a=0;a<arguments.length;a++){var b=$(arguments[a]);b.style.display="none"}},show:function(){for(var a=0;a<arguments.length;a++){var b=$(arguments[a]);b.style.display=""}},getWidth:function(a){a=$(a);return a.offsetWidth},setWidth:function(a,b){a=$(a);a.style.width=b+"px"},getHeight:function(a){a=$(a);return a.offsetHeight},setHeight:function(a,b){a=$(a);a.style.height=b+"px"},setTop:function(a,b){a=$(a);a.style.top=b+"px"},setSrc:function(a,b){a=$(a);a.src=b},setInnerHTML:function(a,b){a=$(a);a.innerHTML=b}});Array.prototype.removeDuplicates=function(){var a=this;for(i=1;i<a.length;i++)a[i][0]==a[i-1][0]&&a.splice(i,1)};Array.prototype.empty=function(){for(i=0;i<=this.length;i++)this.shift()};var Lightbox=Class.create();Lightbox.prototype={initialize:function(){var A="imageDataContainer",z="hoverNav",a="id",b="div",c=false,y="lightbox",g="href";if(!document.getElementsByTagName)return;for(var C=document.getElementsByTagName("a"),u=0;u<C.length;u++){var t=C[u],E=String(t.getAttribute("rel"));if(t.getAttribute(g)&&E.toLowerCase().match(y))t.onclick=function(){myLightbox.start(this);return c}}var D=document.getElementsByTagName("body").item(0),m=document.createElement(b);m.setAttribute(a,"overlay");m.onclick=function(){myLightbox.end();return c};D.appendChild(m);var h=document.createElement(b);h.setAttribute(a,y);h.style.display="none";D.appendChild(h);var n=document.createElement(b);n.setAttribute(a,"outerImageContainer");h.appendChild(n);var e=document.createElement(b);e.setAttribute(a,"imageContainer");n.appendChild(e);var o=document.createElement("img");o.setAttribute(a,"lightboxImage");e.appendChild(o);var l=document.createElement(b);l.setAttribute(a,z);e.appendChild(l);var r=document.createElement("a");r.setAttribute(a,"prevLink");r.setAttribute(g,"#");l.appendChild(r);var q=document.createElement("a");q.setAttribute(a,"nextLink");q.setAttribute(g,"#");l.appendChild(q);var s=document.createElement(b);s.setAttribute(a,"loading");e.appendChild(s);var f=document.createElement("a");f.setAttribute(a,"loadingLink");f.setAttribute(g,"#");f.onclick=function(){myLightbox.end();return c};s.appendChild(f);var x=document.createElement("img");x.setAttribute("src",fileLoadingImage);f.appendChild(x);var i=document.createElement(b);i.setAttribute(a,A);i.className="clearfix";h.appendChild(i);var k=document.createElement(b);k.setAttribute(a,"imageData");i.appendChild(k);var j=document.createElement(b);j.setAttribute(a,"imageDetails");k.appendChild(j);var B=document.createElement("span");B.setAttribute(a,"caption");j.appendChild(B);var w=document.createElement("span");w.setAttribute(a,"numberDisplay");j.appendChild(w);var p=document.createElement(b);p.setAttribute(a,"bottomNav");k.appendChild(p);var d=document.createElement("a");d.setAttribute(a,"bottomNavClose");d.setAttribute(g,"#");d.onclick=function(){myLightbox.end();return c};p.appendChild(d);var v=document.createElement("img");v.setAttribute("src",fileBottomNavCloseImage);d.appendChild(v);overlayEffect=new fx.Opacity(m,{duration:300});overlayEffect.hide();imageEffect=new fx.Opacity(o,{duration:350,onComplete:function(){imageDetailsEffect.custom(0,1)}});imageEffect.hide();imageDetailsEffect=new fx.Opacity(A,{duration:400,onComplete:function(){navEffect.custom(0,1)}});imageDetailsEffect.hide();navEffect=new fx.Opacity(z,{duration:100});navEffect.hide()},start:function(a){var b="href",d="lightbox";hideSelectBoxes();var f=getPageSize();Element.setHeight("overlay",f[1]);overlayEffect.custom(0,.8);imageArray=[];imageNum=0;if(!document.getElementsByTagName)return;var g=document.getElementsByTagName("a");if(a.getAttribute("rel")==d)imageArray.push([a.getAttribute(b),a.getAttribute("title")]);else{for(var e=0;e<g.length;e++){var c=g[e];c.getAttribute(b)&&c.getAttribute("rel")==a.getAttribute("rel")&&imageArray.push([c.getAttribute(b),c.getAttribute("title")])}imageArray.removeDuplicates();while(imageArray[imageNum][0]!=a.getAttribute(b))imageNum++}var f=getPageSize(),h=getPageScroll(),i=h[1]+f[3]/15;Element.setTop(d,i);Element.show(d);this.changeImage(imageNum)},changeImage:function(a){activeImage=a;Element.show("loading");imageDetailsEffect.hide();imageEffect.hide();navEffect.hide();Element.hide("prevLink");Element.hide("nextLink");Element.hide("numberDisplay");imgPreloader=new Image;imgPreloader.onload=function(){Element.setSrc("lightboxImage",imageArray[activeImage][0]);myLightbox.resizeImageContainer(imgPreloader.width,imgPreloader.height)};imgPreloader.src=imageArray[activeImage][0]},resizeImageContainer:function(d,c){var a="outerImageContainer",b=this;b.wCur=Element.getWidth(a);b.hCur=Element.getHeight(a);wDiff=b.wCur-borderSize*2-d;hDiff=b.hCur-borderSize*2-c;reHeight=new fx.Height(a,{duration:resizeDuration});reHeight.custom(Element.getHeight(a),c+borderSize*2);reWidth=new fx.Width(a,{duration:resizeDuration,onComplete:function(){imageEffect.custom(0,1)}});reWidth.custom(Element.getWidth(a),d+borderSize*2);if(hDiff==0&&wDiff==0)if(navigator.appVersion.indexOf("MSIE")!=-1)pause(250);else pause(100);Element.setHeight("prevLink",c);Element.setHeight("nextLink",c);Element.setWidth("imageDataContainer",d+borderSize*2);Element.setWidth("hoverNav",d+borderSize*2);b.showImage()},showImage:function(){Element.hide("loading");myLightbox.updateDetails();this.preloadNeighborImages()},updateDetails:function(){var a="numberDisplay";Element.show("caption");Element.setInnerHTML("caption",imageArray[activeImage][1]);if(imageArray.length>1){Element.show(a);Element.setInnerHTML(a,"Image "+eval(activeImage+1)+" of "+imageArray.length)}myLightbox.updateNav()},updateNav:function(){var b="nextLink",a="prevLink";if(activeImage!=0){Element.show(a);document.getElementById(a).onclick=function(){myLightbox.changeImage(activeImage-1);return false}}if(activeImage!=imageArray.length-1){Element.show(b);document.getElementById(b).onclick=function(){myLightbox.changeImage(activeImage+1);return false}}this.enableKeyboardNav()},enableKeyboardNav:function(){document.onkeydown=this.keyboardAction},disableKeyboardNav:function(){document.onkeydown=""},keyboardAction:function(a){if(a==null)keycode=event.keyCode;else keycode=a.which;key=String.fromCharCode(keycode).toLowerCase();if(key=="x"||key=="o"||key=="c")myLightbox.end();else if(key=="p"){if(activeImage!=0){myLightbox.disableKeyboardNav();myLightbox.changeImage(activeImage-1)}}else if(key=="n")if(activeImage!=imageArray.length-1){myLightbox.disableKeyboardNav();myLightbox.changeImage(activeImage+1)}},preloadNeighborImages:function(){if(imageArray.length-1>activeImage){preloadNextImage=new Image;preloadNextImage.src=imageArray[activeImage+1][0]}if(activeImage>0){preloadPrevImage=new Image;preloadPrevImage.src=imageArray[activeImage-1][0]}},end:function(){this.disableKeyboardNav();Element.hide("lightbox");imageEffect.toggle();overlayEffect.custom(.8,0);showSelectBoxes()}};function getPageScroll(){var a;if(self.pageYOffset)a=self.pageYOffset;else if(document.documentElement&&document.documentElement.scrollTop)a=document.documentElement.scrollTop;else if(document.body)a=document.body.scrollTop;arrayPageScroll=["",a];return arrayPageScroll}function getPageSize(){var c,d;if(window.innerHeight&&window.scrollMaxY){c=document.body.scrollWidth;d=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;d=document.body.scrollHeight}else{c=document.body.offsetWidth;d=document.body.offsetHeight}var b,a;if(self.innerHeight){b=self.innerWidth;a=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientWidth;a=document.documentElement.clientHeight}else if(document.body){b=document.body.clientWidth;a=document.body.clientHeight}if(d<a)pageHeight=a;else pageHeight=d;if(c<b)pageWidth=b;else pageWidth=c;arrayPageSize=[pageWidth,pageHeight,b,a];return arrayPageSize}function getKey(a){if(a==null)keycode=event.keyCode;else keycode=a.which;key=String.fromCharCode(keycode).toLowerCase();if(key=="x");}function listenKey(){document.onkeypress=getKey}function showSelectBoxes(){selects=document.getElementsByTagName("select");for(i=0;i!=selects.length;i++)selects[i].style.visibility="visible"}function hideSelectBoxes(){selects=document.getElementsByTagName("select");for(i=0;i!=selects.length;i++)selects[i].style.visibility="hidden"}function pause(b){var a=new Date,c=a.getTime()+b;while(true){a=new Date;if(a.getTime()>c)return}}function initLightbox(){myLightbox=new Lightbox};
