/* 	This file is reduced and modified part of JonDesign's SmoothGallery v2.1beta1. All code copyright 2007 Jonathan Schemoul 	*/
var gallery={Implements:[Events,Options],options:{showArrows:true,showInfopane:true,fadeDuration:500,timed:false,delay:9000,preloader:true,preloaderImage:true,preloaderErrorImage:true,manualData:[],populateFrom:false,populateData:true,destroyAfterPopulate:true,elementSelector:"div.imageElement",titleSelector:"h3",subtitleSelector:"p",linkSelector:"a.open",imageSelector:"img.full",defaultTransition:"crossfade",slideInfoZoneOpacity:0.75,slideInfoZoneSlide:true,InfoZoneDifferentBg:true,baseClass:"jdGallery",withArrowsClass:"withArrows",navGalleryID:"navGallery"},initialize:function(C,B){this.setOptions(B);this.fireEvent("onInit");this.currentIter=0;this.lastIter=0;this.maxIter=0;this.galleryElement=C;this.galleryData=this.options.manualData;this.galleryInit=1;this.galleryElements=Array();this.galleryElement.addClass(this.options.baseClass);this.populateFrom=C;if(this.options.populateFrom){this.populateFrom=this.options.populateFrom}if(this.options.populateData){this.populateData()}C.style.display="block";this.constructElements();if((this.galleryData.length>1)&&(this.options.showArrows)){var D=new Element("a").addClass("left").addEvent("click",this.prevItem.bind(this)).injectInside($(this.options.navGalleryID));var A=new Element("a").addClass("right").addEvent("click",this.nextItem.bind(this)).injectInside($(this.options.navGalleryID));this.galleryElement.addClass(this.options.withArrowsClass)}this.loadingElement=new Element("div").addClass("loadingElement").injectInside(C);if(this.options.showInfopane){this.initInfoSlideshow()}this.doSlideShow(1)},populateData:function(){currentArrayPlace=this.galleryData.length;options=this.options;var A=$A(this.galleryData);A.extend(this.populateGallery(this.populateFrom,currentArrayPlace));this.galleryData=A;this.fireEvent("onPopulated")},populateGallery:function(A,C){var B=[];options=this.options;currentArrayPlace=C;A.getElements(options.elementSelector).each(function(D){elementDict=$H({image:D.getElement(options.imageSelector).getProperty("src"),number:currentArrayPlace,transition:this.options.defaultTransition});if(options.showInfopane){elementDict.extend({title:D.getElement(options.titleSelector).innerHTML,description:D.getElement(options.subtitleSelector).innerHTML})}B.extend([elementDict]);currentArrayPlace++;if(this.options.destroyAfterPopulate){D.dispose()}});return B},constructElements:function(){el=this.galleryElement;this.maxIter=this.galleryData.length;var A;for(i=0;i<this.galleryData.length;i++){var A=new Fx.Morph(new Element("div").addClass("slideElement").setStyles({position:"absolute",left:"0px",right:"0px",margin:"0px",padding:"0px",backgroundPosition:"center center",opacity:"0"}).injectInside(el),{duration:this.options.fadeDuration});if(this.options.preloader){A.source=this.galleryData[i].image;A.loaded=false;A.load=function(B,C){if(!B.loaded){this.galleryData[C].imgloader=new Asset.image(B.source,{onload:function(D,E){D.element.setStyle("backgroundImage","url('"+D.source+"')");D.loaded=true;D.width=this.galleryData[E].imgloader.width;D.height=this.galleryData[E].imgloader.height}.pass([B,C],this)})}}.pass([A,i],this)}else{A.element.setStyle("backgroundImage","url('"+this.galleryData[i].image+"')")}this.galleryElements[parseInt(i)]=A}},destroySlideShow:function(A){var B=A.className;var C=new Element("div").addClass("myClassName");A.parentNode.replaceChild(C,A)},startSlideShow:function(){this.fireEvent("onStart");this.loadingElement.style.display="none";this.lastIter=this.maxIter-1;this.currentIter=0;this.galleryInit=0;this.galleryElements[parseInt(this.currentIter)].set({opacity:1});if(this.options.showInfopane){this.showInfoSlideShow.delay(1000,this)}this.prepareTimer()},nextItem:function(){this.fireEvent("onNextCalled");this.nextIter=this.currentIter+1;if(this.nextIter>=this.maxIter){this.nextIter=0}this.galleryInit=0;this.goTo(this.nextIter)},prevItem:function(){this.fireEvent("onPreviousCalled");this.nextIter=this.currentIter-1;if(this.nextIter<=-1){this.nextIter=this.maxIter-1}this.galleryInit=0;this.goTo(this.nextIter)},goTo:function(A){this.clearTimer();if(this.options.preloader){this.galleryElements[A].load();if(A==0){this.galleryElements[this.maxIter-1].load()}else{this.galleryElements[A-1].load()}if(A==(this.maxIter-1)){this.galleryElements[0].load()}else{this.galleryElements[A+1].load()}}if(this.options.showInfopane){this.slideInfoZone.clearChain();this.hideInfoSlideShow().chain(this.changeItem.pass(A,this))}else{this.currentChangeDelay=this.changeItem.delay(500,this,A)}this.prepareTimer()},changeItem:function(A){this.fireEvent("onStartChanging");this.galleryInit=0;if(this.currentIter!=A){for(i=0;i<this.maxIter;i++){if((i!=this.currentIter)){this.galleryElements[i].set({opacity:0})}}gallery.Transitions[this.galleryData[A].transition].pass([this.galleryElements[this.currentIter],this.galleryElements[A],this.currentIter,A],this)();this.currentIter=A}this.doSlideShow.bind(this)();this.fireEvent("onChanged")},clearTimer:function(){if(this.options.timed){$clear(this.timer)}},prepareTimer:function(){if(this.options.timed){this.timer=this.nextItem.delay(this.options.delay,this)}},doSlideShow:function(A){if(this.galleryInit==1){imgPreloader=new Image();imgPreloader.onload=function(){this.startSlideShow.delay(10,this)}.bind(this);imgPreloader.src=this.galleryData[0].image;if(this.options.preloader){this.galleryElements[0].load()}}else{if(this.options.showInfopane){this.showInfoSlideShow.delay((500+this.options.fadeDuration),this)}}},initInfoSlideshow:function(){this.slideInfoZone=new Fx.Morph(new Element("div").addClass("slideInfoZone").injectAfter($("topGallery"))).set({opacity:0});if(this.options.InfoZoneDifferentBg){var C=new Fx.Morph(new Element("div").addClass("myTrans").injectInside(this.slideInfoZone.element)).set({opacity:0.35})}var B=new Element("h2").injectInside(this.slideInfoZone.element);var A=new Element("p").injectInside(this.slideInfoZone.element);this.slideInfoZone.normalHeight=this.slideInfoZone.element.offsetHeight;this.slideInfoZone.element.setStyle("opacity",0)},changeInfoSlideShow:function(){this.hideInfoSlideShow.delay(500,this);this.showInfoSlideShow.delay(500,this)},showInfoSlideShow:function(){this.fireEvent("onShowInfopane");this.slideInfoZone.cancel();element=this.slideInfoZone.element;if(this.options.InfoZoneDifferentBg){element.getElement("div.myTrans")}element.getElement("h2").set("html",this.galleryData[this.currentIter].title);element.getElement("p").set("html",this.galleryData[this.currentIter].description);if(((this.currentIter+1)<10)&&(this.maxIter<10)){$("countGallery").set("html",'<span class="number">0'+(this.currentIter+1)+"/0"+this.maxIter+"</span> ")}else{if(((this.currentIter+1)<10)&&(this.maxIter>10)){$("countGallery").set("html",'<span class="number">0'+(this.currentIter+1)+"/"+this.maxIter+"</span> ")}else{$("countGallery").set("html",'<span class="number">'+(this.currentIter+1)+"/"+this.maxIter+"</span> ")}}if(this.options.slideInfoZoneSlide){this.slideInfoZone.start({opacity:[1,this.options.slideInfoZoneOpacity],height:[0,this.slideInfoZone.normalHeight]})}else{this.slideInfoZone.start({opacity:[0,this.options.slideInfoZoneOpacity]})}return this.slideInfoZone},hideInfoSlideShow:function(){this.fireEvent("onHideInfopane");this.slideInfoZone.cancel();if(this.options.slideInfoZoneSlide){this.slideInfoZone.start({opacity:1,height:0})}else{this.slideInfoZone.start({opacity:0})}return this.slideInfoZone},flushGallery:function(){this.galleryElements.each(function(A){A.element.dispose();A=A.element=null});this.galleryElements=[]},changeData:function(A){this.galleryData=A;this.clearTimer();this.flushGallery();this.constructElements();if(this.options.showInfopane){this.hideInfoSlideShow()}this.galleryInit=1;this.lastIter=0;this.currentIter=0;this.doSlideShow(1)}};gallery=new Class(gallery);gallery.Transitions=new Hash({fade:function(C,D,A,B){C.options.transition=D.options.transition=Fx.Transitions.linear;C.options.duration=D.options.duration=this.options.fadeDuration;if(B>A){D.start({opacity:1})}else{D.set({opacity:1});C.start({opacity:0})}},crossfade:function(C,D,A,B){C.options.transition=D.options.transition=Fx.Transitions.linear;C.options.duration=D.options.duration=this.options.fadeDuration;D.start({opacity:1});C.start({opacity:0})},fadebg:function(C,D,A,B){C.options.transition=D.options.transition=Fx.Transitions.linear;C.options.duration=D.options.duration=this.options.fadeDuration/2;C.start({opacity:0}).chain(D.start.pass([{opacity:1}],D))}});
/* 	Follows: Preloader (class). Copyright 2007 Tomocchino. */
var Preloader=new Class({Implements:[Events,Options],options:{root:"",period:100},initialize:function(A){this.setOptions(A)},load:function(A){this.index=0;this.images=[];this.sources=this.temps=A;this.total=this.sources.length;this.fireEvent("onStart",[this.index,this.total]);this.timer=this.progress.periodical(this.options.period,this);this.sources.each(function(C,B){this.images[B]=new Asset.image(this.options.root+C,{onload:function(){this.index++;if(this.images[B]){this.fireEvent("onLoad",[this.images[B],B,C])}}.bind(this),onerror:function(){this.index++;this.fireEvent("onError",[this.images.splice(B,1),B,C])}.bind(this),onabort:function(){this.index++;this.fireEvent("onError",[this.images.splice(B,1),B,C])}.bind(this)})},this)},progress:function(){this.fireEvent("onProgress",[Math.min(this.index,this.total),this.total]);if(this.index>=this.total){this.complete()}},complete:function(){$clear(this.timer);this.fireEvent("onComplete",[this.images])},cancel:function(){$clear(this.timer)}});
/* 	Follows: formatString (function). Original name: Yahoo.Tools.printf. Copyright Yahoo.	*/
function formatString(){var B=arguments.length;var A=arguments[0];for(var C=1;C<B;C++){var E="\\{"+(C-1)+"\\}";var D=new RegExp(E,"g");A=A.replace(D,arguments[C])}return A};
/* 	Copyright: Guillermo Rauch <http://devthought.com/> Distributed under MIT - Keep this message!	 */
var MorphList=new Class({Implements:[Events,Options],options:{morph:{link:"cancel",duration:400}},initialize:function(C,A){var B=this;this.setOptions(A);this.menu=$(C);this.menuitems=this.menu.getChildren();this.menuitems.addEvents({mouseenter:function(){B.morphTo(this)},mouseleave:function(){B.morphTo(B.current)},click:function(D){B.click(D,this)}});this.bg=new Element("li",{"class":"background"}).adopt(new Element("div",{"class":"left"}));this.bg.inject(this.menu).set("morph",this.options.morph);this.setCurrent(this.menu.getElement(".current"))},click:function(B,A){if(A==this.current){this.setCurrent(this.menuitems[0],true)}else{this.setCurrent(A,true)}this.fireEvent("onClick",[B,A])},setCurrent:function(B,A){if(B&&!this.current){this.bg.set("styles",{left:B.offsetLeft,width:B.offsetWidth,height:B.offsetHeight,top:B.offsetTop});(A)?this.bg.fade("hide").fade("in"):this.bg.fade("show")}if(this.current){this.current.removeClass("current")}if(B){this.current=B.addClass("current")}},morphTo:function(A){if(!this.current){return }this.bg.morph({left:A.offsetLeft,top:A.offsetTop,width:A.offsetWidth,height:A.offsetHeight});this.fireEvent("onMorph",A)}});

