var bustout=bustout||{};
bustout.version="0.1";
bustout.global=this;
bustout.isArray=function(a){return a!=null&&typeof a==="object"&&"splice" in a&&"join" in a
};
bustout.isString=function(a){return typeof a==="string"
};
bustout.bind=function(d,a,f){var g=d.boundArgs_;
if(arguments.length>2){var b=Array.prototype.slice.call(arguments,2);
if(g){b.unshift.apply(b,g)
}g=b
}a=d.boundSelf_||a;
d=d.boundFn_||d;
var e;
var c=a||bustout.global;
if(g){e=function(){var h=Array.prototype.slice.call(arguments);
h.unshift.apply(h,g);
return d.apply(c,h)
}
}else{e=function(){return d.apply(c,arguments)
}
}e.boundArgs_=g;
e.boundSelf_=a;
e.boundFn_=d;
return e
};
bustout.extend=function(c,b){function a(){}a.prototype=b.prototype;
c.superClass_=b.prototype;
c.prototype=new a();
c.prototype.constructor=c
};
bustout.sequence_=0;
bustout.getNextSequence=function(){return bustout.sequence_++
};
var bustout=bustout||{};
bustout.Browser={};
bustout.Browser.IE=!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1);
bustout.Browser.Opera=navigator.userAgent.indexOf("Opera")>-1;
bustout.Browser.WebKit=navigator.userAgent.indexOf("AppleWebKit/")>-1;
bustout.Browser.Gecko=navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1;
bustout.Browser.MobileSafari=!!navigator.userAgent.match(/Apple.*Mobile.*Safari/);
bustout.dom=bustout.dom||{};
bustout.dom.NodeType={DOCUMENT:9};
bustout.dom.$=function(a){if(bustout.isString(a)){return document.getElementById(a)
}return a
};
bustout.dom.getElementsByClassName=function(c,h){if(document.getElementsByClassName){return h?h.getElementsByClassName(c):document.getElementsByClassName(c)
}else{if(!!document.evaluate){var g=".//*[contains(concat(' ', @class, ' '), ' "+c+" ')]";
return bustout.dom.getElementsByXPath_(g,h)
}else{var f=[];
var b=(bustout.dom.$(h)||document.body).getElementsByTagName("*");
var e=new RegExp("(^|\\s)"+c+"(\\s|$)");
for(var a=0,d=b.length;
a<d;
a++){if(e.test(b[a].className)){f.push(b[a])
}}return f
}}};
bustout.dom.getElementsByXPath_=function(f,e){var d=[];
var c=document.evaluate(f,bustout.dom.$(e)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
for(var a=0,b=c.snapshotLength;
a<b;
a++){d.push(c.snapshotItem(a))
}return d
};
bustout.dom.hasLayout=function(a){var b=bustout.dom.$(a);
return b.currentStyle&&b.currentStyle.hasLayout
};
bustout.dom.setHasLayout=function(a){if(bustout.Browser.IE){var b=bustout.dom.$(a);
if(!b.currentStyle.hasLayout){b.style.zoom=1
}}};
bustout.dom.setOpacity=function(b,a){var c=bustout.dom.$(b);
bustout.dom.setHasLayout(c);
if(bustout.Browser.IE){c.style.filter=(a===1)?"":"alpha(opacity="+a*100+")"
}c.style.opacity=a
};
bustout.dom.overlay=function(c,d){var b=bustout.dom.$(c);
var a=bustout.dom.$(d);
a.style.top=b.offsetTop+"px";
a.style.left=b.offsetLeft+"px";
a.style.width=b.offsetWidth+"px";
a.style.height=b.offsetHeight+"px"
};
bustout.dom.getOwnerDocument=function(a){return a.nodeType==bustout.dom.NodeType.DOCUMENT?a:a.ownerDocument
};
bustout.dom.getComputedStyle=function(a,c){var b=bustout.dom.$(a);
var e=bustout.dom.getOwnerDocument(b);
if(e.defaultView&&e.defaultView.getComputedStyle){var d=e.defaultView.getComputedStyle(b,"");
if(d){return d[c]
}}return null
};
bustout.dom.getStyle_=function(a,b){return bustout.dom.getComputedStyle(a,b)||(a.currentStyle?a.currentStyle[b]:null)||a.style[b]
};
bustout.dom.getCssPosition=function(a){var b=bustout.dom.$(a);
return bustout.dom.getStyle_(b,"position")
};
bustout.dom.getCssDisplay=function(a){var b=bustout.dom.$(a);
return bustout.dom.getStyle_(b,"display")
};
bustout.dom.getCssFloat=function(a){var b=bustout.dom.$(a);
return bustout.dom.getComputedStyle(b,"cssFloat")||(b.currentStyle?b.currentStyle.styleFloat:null)||b.style.cssFloat||b.style.styleFloat
};
bustout.events=bustout.events||{};
bustout.events.bindEventListener=function(c,a){a=c.boundSelf_||a;
c=c.boundFn_||c;
var b=a||bustout.global;
var d=function(e){return c.call(b,new bustout.events.BrowserEvent(e||window.event))
};
d.boundSelf_=a;
d.boundFn_=c;
return d
};
var bustout=bustout||{};
bustout.Disposable=function(){};
bustout.Disposable.prototype.disposed_=false;
bustout.Disposable.prototype.isDisposed=function(){return this.disposed_
};
bustout.Disposable.prototype.dispose=function(){if(!this.disposed_){this.disposeInternal();
this.disposed_=true
}};
bustout.Disposable.prototype.disposeInternal=function(){};
bustout.events=bustout.events||{};
bustout.events.Event=function(a,b){bustout.Disposable.call(this);
this.type=a;
this.target=b
};
bustout.extend(bustout.events.Event,bustout.Disposable);
bustout.events.Event.prototype.disposeInternal=function(){bustout.events.Event.superClass_.disposeInternal.call(this);
this.type=null;
this.target=null
};
bustout.events=bustout.events||{};
bustout.events.BrowserEvent=function(a){bustout.Disposable.call(this);
this.type=a.type;
this.target=a.target||a.srcElement;
this.event=a
};
bustout.extend(bustout.events.BrowserEvent,bustout.events.Event);
bustout.events.BrowserEvent.prototype.stopPropagation=function(){if(this.event.stopPropagation){this.event.stopPropgation()
}else{this.event.cancelBubble=true
}};
bustout.events.BrowserEvent.prototype.disposeInternal=function(){bustout.events.BrowserEvent.superClass_.disposeInteral.call(this);
this.event=null
};
bustout.events=bustout.events||{};
bustout.events.EventTarget=function(){bustout.Disposable.call(this);
this.listeners_={}
};
bustout.extend(bustout.events.EventTarget,bustout.Disposable);
bustout.events.EventTarget.prototype.addEventListener=function(b,d){if(bustout.isArray(b)){for(var a=0,c=b.length;
a<c;
a++){this.addEventListener_(b[a],d)
}}else{this.addEventListener_(b,d)
}};
bustout.events.EventTarget.prototype.addEventListener_=function(a,b){if(!this.listeners_[a]){this.listeners_[a]=[]
}this.listeners_[a].push(b)
};
bustout.events.EventTarget.prototype.dispatchEvent=function(c){var b=this.listeners_[c.type];
if(b){for(var a=0;
a<b.length;
a++){b[a](c)
}}};
bustout.events.EventTarget.prototype.disposeInternal=function(){bustout.events.EventTarget.superClass_.disposeInternal.call(this);
for(var a in this.listeners_){if(this.listeners_.hasOwnProperty(a)){this.listeners_[a]=null
}}this.listeners_=null
};
bustout.util=bustout.util||{};
bustout.util.HashListener=function(){bustout.events.EventTarget.call(this);
if(!bustout.util.HashListener.instance_){bustout.util.HashListener.instance_=this;
this.hash_=document.location.hash;
if(bustout.Browser.IE){var a=document.createElement("iframe");
a.id=bustout.util.HashListener.IFRAME_ID;
a.src='javascript:""';
a.style.display="none";
document.body.appendChild(a);
this.writeFrame_("")
}if("onpropertychange" in document&&"attachEvent" in document){this.iePropertyChangeFn_=bustout.events.bindEventListener(this.handlePropertyChange_,this);
document.attachEvent("onpropertychange",this.iePropertyChangeFn_)
}this.timer_=window.setInterval(bustout.bind(this.check_,this),bustout.util.HashListener.INTERVAL)
}return bustout.util.HashListener.instance_
};
bustout.extend(bustout.util.HashListener,bustout.events.EventTarget);
bustout.util.HashListener.EventType={CHANGE:"change"};
bustout.util.HashListener.IFRAME_ID="bustout-history";
bustout.util.HashListener.INTERVAL=100;
bustout.util.HashListener.instance_=null;
bustout.util.HashListener.prototype.getHash=function(){return this.hash_
};
bustout.util.HashListener.prototype.setHash_=function(a){this.hash_=a
};
bustout.util.HashListener.prototype.check_=function(){var a=document.location.hash;
if(a!==this.hash_){this.hash_=a;
this.dispatchEvent(new bustout.events.Event(bustout.util.HashListener.EventType.CHANGE,this))
}};
bustout.util.HashListener.prototype.writeFrame_=function(b){var a=bustout.dom.$(bustout.util.HashListener.IFRAME_ID);
var c=a.contentDocument||a.contentWindow.document;
c.open();
c.write("<script>parent.bustout.util.HashListener.instance_.setHash_("+parent.document.location.hash+"); window.onload = parent.bustout.util.HashListener.instance_.syncHash_;<\/script>");
c.close()
};
bustout.util.HashListener.prototype.syncHash_=function(){var a=this.hash_;
if(a!=document.location.hash){document.location.hash=a
}};
bustout.util.HashListener.prototype.handlePropertyChange_=function(a){if(a.event.propertyName==="location"){this.check_()
}};
bustout.util.HashListener.prototype.disposeInternal=function(){bustout.util.HashListener.superClass_.disposeInternal.call(this);
if("onpropertychange" in document&&"attachEvent" in document){document.detachEvent("onpropertychange",this.iePropertyChangeFn_)
}if(this.timer_){window.clearInterval(this.timer_);
this.timer_=null
}};
bustout.effects=bustout.effects||{};
bustout.effects.Effect=function(c,b,a){bustout.events.EventTarget.call(this);
this.from_=c;
this.to_=b;
if(!a){a={}
}this.duration_=a.duration||500;
this.fps_=a.fps||50;
this.transition_=a.transition||bustout.effects.Effect.Transition.LINEAR
};
bustout.extend(bustout.effects.Effect,bustout.events.EventTarget);
bustout.effects.Effect.EventType={START:"start_effect",RENDER:"render_effect",END:"end_effect"};
bustout.effects.Effect.Transition={LINEAR:function(a){return a
}};
bustout.effects.Effect.compute=function(c,b,a){return(b-c)*a+c
};
bustout.effects.Effect.prototype.time_=0;
bustout.effects.Effect.prototype.timer_=null;
bustout.effects.Effect.prototype.start=function(){this.time_=new Date().getTime()-this.time_;
this.timer_=setInterval(bustout.bind(this.step_,this),Math.round(1000/this.fps_));
this.dispatchEvent(new bustout.events.Event(bustout.effects.Effect.EventType.START,this))
};
bustout.effects.Effect.prototype.step_=function(){var a=new Date().getTime();
if(a<this.time_+this.duration_){var b=this.transition_((a-this.time_)/this.duration_);
this.render(bustout.effects.Effect.compute(this.from_,this.to_,b));
this.dispatchEvent(new bustout.events.Event(bustout.effects.Effect.EventType.RENDER,this))
}else{try{this.render(bustout.effects.Effect.compute(this.from_,this.to_,1));
this.dispatchEvent(new bustout.events.Event(bustout.effects.Effect.EventType.RENDER,this))
}finally{this.end_()
}}};
bustout.effects.Effect.prototype.render=function(a){};
bustout.effects.Effect.prototype.end_=function(){if(this.timer_){window.clearInterval(this.timer_);
this.timer_=null
}this.time_=0;
this.dispatchEvent(new bustout.events.Event(bustout.effects.Effect.EventType.END,this))
};
bustout.effects.Effect.prototype.disposeInternal=function(){bustout.effects.Effect.superClass_.disposeInternal.call(this);
if(this.timer_){window.clearInterval(this.timer_);
this.timer_=null
}this.transition_=null
};
bustout.effects=bustout.effects||{};
bustout.effects.OpacityEffect=function(b,d,c,a){bustout.effects.Effect.call(this,d,c,a);
this.element_=bustout.dom.$(b);
bustout.dom.setOpacity(this.element_,d)
};
bustout.extend(bustout.effects.OpacityEffect,bustout.effects.Effect);
bustout.effects.OpacityEffect.prototype.render=function(a){bustout.dom.setOpacity(this.element_,a)
};
bustout.effects.OpacityEffect.prototype.disposeInternal=function(){bustout.effects.OpacityEffect.superClass_.disposeInternal.call(this);
this.element_=null
};
bustout.gallery=bustout.gallery||{};
bustout.gallery.Image=function(b,a){bustout.events.EventTarget.call(this);
this.id_=b;
this.element_=bustout.dom.$(b);
this.element_.onload=bustout.events.bindEventListener(this.handleImageElementLoad_,this);
this.image_=new Image();
this.image_.onload=bustout.events.bindEventListener(this.handleImageLoad_,this);
if(a){this.image_.src=a
}};
bustout.extend(bustout.gallery.Image,bustout.events.EventTarget);
bustout.gallery.Image.EventType={LOAD:"load",UNLOAD:"unload",SHOW:"show",HIDE:"hide"};
bustout.gallery.Image.prototype.showEffect_=null;
bustout.gallery.Image.prototype.hideEffect_=null;
bustout.gallery.Image.prototype.getId=function(){return this.id_
};
bustout.gallery.Image.prototype.setSrc=function(a){if(this.image_.src){this.dispatchEvent(new bustout.events.Event(bustout.gallery.Image.EventType.UNLOAD,this));
this.image_.src=null;
this.element_.src=null
}this.image_.src=a
};
bustout.gallery.Image.prototype.handleImageLoad_=function(a){this.element_.src=this.image_.src
};
bustout.gallery.Image.prototype.handleImageElementLoad_=function(){this.element_.width=this.image_.width;
this.element_.height=this.image_.height;
this.dispatchEvent(new bustout.events.Event(bustout.gallery.Image.EventType.LOAD,this))
};
bustout.gallery.Image.prototype.getSrc=function(){return this.image_.src
};
bustout.gallery.Image.prototype.show=function(a){this.element_.style.display="";
if(a){this.showEffect_=a;
this.showEffect_.addEventListener(bustout.effects.Effect.EventType.END,bustout.bind(this.handleShowEffectEnd_,this));
this.showEffect_.start()
}else{bustout.dom.setOpacity(this.element_,1);
this.dispatchEvent(new bustout.events.Event(bustout.gallery.Image.EventType.SHOW,this))
}};
bustout.gallery.Image.prototype.handleShowEffectEnd_=function(){if(this.showEffect_){this.showEffect_.dispose();
this.showEffect_=null
}this.dispatchEvent(new bustout.events.Event(bustout.gallery.Image.EventType.SHOW,this))
};
bustout.gallery.Image.prototype.hide=function(a){if(a){this.hideEffect_=a;
this.hideEffect_.addEventListener(bustout.effects.Effect.EventType.END,bustout.bind(this.handleHideEffectEnd_,this));
this.hideEffect_.start()
}else{this.element_.style.display="none";
this.dispatchEvent(new bustout.events.Event(bustout.gallery.Image.EventType.HIDE,this))
}};
bustout.gallery.Image.prototype.handleHideEffectEnd_=function(){bustout.dom.setOpacity(this.element_,0);
this.element_.style.display="none";
if(this.hideEffect_){this.hideEffect_.dispose();
this.hideEffect_=null
}this.dispatchEvent(new bustout.events.Event(bustout.gallery.Image.EventType.HIDE,this))
};
bustout.gallery.Image.prototype.disposeInternal=function(){bustout.gallery.Image.superClass_.disposeInternal.call(this);
if(this.element_){this.element_=null
}if(this.image_){this.image_.onload=null;
this.image_=null
}if(this.showEffect_){this.showEffect_.dispose();
this.showEffect_=null
}if(this.hideEffect_){this.hideEffect_.dispose();
this.hideEffect_=null
}};
bustout.gallery=bustout.gallery||{};
bustout.gallery.Thumbnail=function(c,b,a){bustout.events.EventTarget.call(this);
this.id_=c;
this.element_=bustout.dom.$(this.id_);
this.className_=this.element_.className;
this.highlightClassName_=this.className_+" "+b;
this.selectedClassName_=this.className_+" "+a;
this.element_.onclick=bustout.events.bindEventListener(this.select_,this);
this.element_.onmouseover=bustout.events.bindEventListener(this.highlight_,this);
this.element_.onmouseout=bustout.events.bindEventListener(this.unhighlight_,this)
};
bustout.extend(bustout.gallery.Thumbnail,bustout.events.EventTarget);
bustout.gallery.Thumbnail.EventType={HIGHLIGHT:"highlight",UNHIGHLIGHT:"unhighlight",SELECT:"select",DESELECT:"deselect"};
bustout.gallery.Thumbnail.prototype.selected_=false;
bustout.gallery.Thumbnail.prototype.highlighted_=false;
bustout.gallery.Thumbnail.prototype.getId=function(){return this.id_
};
bustout.gallery.Thumbnail.prototype.setSelected=function(a){if((a&&!this.selected_)||(!a&&this.selected_)){this.element_.className=a?this.selectedClassName_:this.className_;
this.selected_=a;
this.dispatchEvent(new bustout.events.Event(a?bustout.gallery.Thumbnail.EventType.SELECT:bustout.gallery.Thumbnail.EventType.DESELECT,this))
}};
bustout.gallery.Thumbnail.prototype.select_=function(a){if(!this.selected_){this.setSelected(true)
}};
bustout.gallery.Thumbnail.prototype.highlight_=function(a){this.setHighlight_(true)
};
bustout.gallery.Thumbnail.prototype.unhighlight_=function(a){if(!this.selected_){this.setHighlight_(false)
}};
bustout.gallery.Thumbnail.prototype.setHighlight_=function(a){if((a&&!this.highlighted_)||(!a&&this.highlighted_)){this.element_.className=a?this.highlightClassName_:this.className_;
this.highlighted_=a;
this.dispatchEvent(new bustout.events.Event(a?bustout.gallery.Thumbnail.EventType.HIGHLIGHT:bustout.gallery.Thumbnail.EventType.UNHIGHLIGHT,this))
}};
bustout.gallery.Thumbnail.prototype.disposeInternal=function(){bustout.gallery.Thumbnail.superClass_.disposeInternal.call(this);
this.className_=null;
this.highlightedClassName_=null;
if(this.element_){this.element_.onclick=null;
this.element_.onmouseover=null;
this.element_.onmouseout=null;
this.element_=null
}};
bustout.gallery=bustout.gallery||{};
bustout.gallery.Gallery=function(k){bustout.events.EventTarget.call(this);
if(!k){k={}
}var f=k.imageId||"image";
var h=k.imagePath||"images/";
this.thumbnailClassName_=k.thumbnailClassName||"thumbnail";
this.thumbnailHighlightClassName_=k.thumbnailHighlightClassName||"thumbnail-highlight";
this.thumbnailSelectedClassName_=k.thumbnailSelectedClassName||"thumbnail-selected";
this.linkContainerEl_=bustout.dom.$(k.linkContainerId||"link-container");
this.nextLinkEl_=bustout.dom.$(k.nextLinkId||"link-next");
this.nextLinkEl_.onclick=bustout.events.bindEventListener(this.next_,this);
this.backLinkEl_=bustout.dom.$(k.backLinkId||"link-back");
this.backLinkEl_.onclick=bustout.events.bindEventListener(this.back_,this);
this.image_=new bustout.gallery.Image(f);
this.image_.addEventListener(bustout.gallery.Image.EventType.LOAD,bustout.bind(this.handleImageLoad_,this));
this.image_.addEventListener(bustout.gallery.Image.EventType.SHOW,bustout.bind(this.handleImageShow_,this));
this.ids_=[];
this.positions_={};
this.thumbnails_={};
this.images_={};
var b=bustout.dom.getElementsByClassName(this.thumbnailClassName_);
for(var g=0,e=b.length;
g<e;
g++){var d=b[g].id;
if(!d){d=b[g].id="thumbnail-"+bustout.getNextSequence()
}this.ids_.push(d);
this.positions_[d]=g+1;
var a=new bustout.gallery.Thumbnail(d,this.thumbnailHighlightClassName_,this.thumbnailSelectedClassName_);
a.addEventListener(bustout.gallery.Thumbnail.EventType.SELECT,bustout.bind(this.handleThumbnailSelected_,this));
this.thumbnails_[d]=a;
var j=b[g].src.split("/");
var c=j.length>1?j[j.length-1]:j;
this.images_[d]=h+c
}};
bustout.extend(bustout.gallery.Gallery,bustout.events.EventTarget);
bustout.gallery.Gallery.prototype.thumbnail_=null;
bustout.gallery.Gallery.prototype.position_=1;
bustout.gallery.Gallery.prototype.hashListener_=null;
bustout.gallery.Gallery.prototype.ignoreNextHashChange_=false;
bustout.gallery.Gallery.prototype.start=function(){this.hashListener_=new bustout.util.HashListener();
this.hashListener_.addEventListener(bustout.util.HashListener.EventType.CHANGE,bustout.bind(this.handleHashChange_,this));
var a=this.hashListener_.getHash();
this.hashItOut_(a)
};
bustout.gallery.Gallery.prototype.handleHashChange_=function(a){if(!this.ignoreNextHashChange_){this.hashItOut_(a.target.getHash())
}this.ignoreNextHashChange_=false
};
bustout.gallery.Gallery.prototype.hashItOut_=function(b){try{this.position_=Number(b?b.substring(1):1)
}catch(a){this.position_=1
}if(this.thumbnail_){this.thumbnail_.setSelected(false)
}var c=this.ids_[this.position_-1];
this.thumbnail_=this.thumbnails_[c];
this.thumbnail_.setSelected(true);
this.image_.setSrc(this.images_[c])
};
bustout.gallery.Gallery.prototype.handleImageLoad_=function(a){this.image_.show(new bustout.effects.OpacityEffect(this.image_.getId(),0,1))
};
bustout.gallery.Gallery.prototype.handleImageShow_=function(a){this.setLinkHrefs_();
this.showLinks_()
};
bustout.gallery.Gallery.prototype.handleThumbnailSelected_=function(a){this.hideLinks_();
if(this.thumbnail_&&this.thumbnail_!=a.target){this.thumbnail_.setSelected(false)
}this.thumbnail_=a.target;
this.image_.hide();
this.image_.setSrc(this.images_[this.thumbnail_.getId()]);
this.position_=this.positions_[this.thumbnail_.getId()];
this.ignoreNextHashChange_=true
};
bustout.gallery.Gallery.prototype.setLinkHrefs_=function(){var a=this.position_===this.ids_.length?1:this.position_+1;
var b=this.position_===1?this.ids_.length:this.position_-1;
this.nextLinkEl_.href="#"+a;
this.backLinkEl_.href="#"+b
};
bustout.gallery.Gallery.prototype.hideLinks_=function(){this.nextLinkEl_.style.display="none";
this.backLinkEl_.style.display="none"
};
bustout.gallery.Gallery.prototype.showLinks_=function(){bustout.dom.overlay(bustout.dom.$(this.image_.getId()),this.linkContainerEl_);
this.nextLinkEl_.style.display="";
this.backLinkEl_.style.display=""
};
bustout.gallery.Gallery.prototype.next_=function(){var a=this.position_+1;
if(a>this.ids_.length){a=1
}this.thumbnails_[this.ids_[a-1]].setSelected(true);
this.ignoreNextHashChange_=true
};
bustout.gallery.Gallery.prototype.back_=function(){var a=this.position_-1;
if(a<1){a=this.ids_.length
}this.thumbnails_[this.ids_[a-1]].setSelected(true);
this.ignoreNextHashChange_=true
};
bustout.gallery.Gallery.prototype.disposeInternal=function(){if(this.image_){this.image_.dispose();
this.image_=null
}for(id in this.images_){this.images_[id]=null;
delete this.images_[id]
}for(id in this.thumbnails_){this.thumbnails_[id].dispose();
this.thumbnails_[id]=null;
delete this.thumbnails_[id]
}if(this.linkContainerEl_){this.linkContainerEl_=null
}if(this.nextLinkEl_){this.nextLinkEl_.onclick=null;
this.nextLinkEl_=null
}if(this.backLinkEl_){this.backLinkEl_.onclick=null;
this.backLinkEl_=null
}if(this.hashListener_){this.hashListener_.dispose();
this.hashListener_=null
}};
bustout.gallery=bustout.gallery||{};
bustout.gallery.Carousel=function(b,m,o){bustout.events.EventTarget.call(this);
this.id_=b;
var e=bustout.dom.$(this.id_);
var j=document.createElement("img");
var g=document.createElement("img");
var i=j.id=this.id_+bustout.getNextSequence();
var c=g.id=this.id_+bustout.getNextSequence();
j.className=g.className=e.className;
j.style.cssText=g.style.cssText=e.style.cssText;
var k=bustout.dom.getCssDisplay(e);
var a=bustout.dom.getCssPosition(e);
var h=bustout.dom.getCssFloat(e);
var l=e.style.display;
try{var n=false;
if(a!="absolute"&&k=="inline"||(a=="static"||a=="relative")&&!h){n=true;
e.style.display="none"
}if(a=="fixed"){j.style.position=g.style.position=a
}else{j.style.position=g.style.position="absolute"
}j.style.top=g.style.top=e.offsetTop+"px";
if(e.direction&&e.dir==="rtl"){j.style.right=g.style.right=e.offsetRight+"px"
}else{j.style.left=g.style.left=e.offsetLeft+"px"
}}finally{if(n){e.style.display=l
}}e.parentNode.appendChild(j);
e.parentNode.appendChild(g);
this.foo_=new bustout.gallery.Image(i);
this.bar_=new bustout.gallery.Image(c);
this.foo_.addEventListener(bustout.gallery.Image.EventType.LOAD,bustout.bind(this.handleImageLoad_,this));
this.bar_.addEventListener(bustout.gallery.Image.EventType.LOAD,bustout.bind(this.handleImageLoad_,this));
this.foo_.addEventListener(bustout.gallery.Image.EventType.SHOW,bustout.bind(this.handleImageShow_,this));
this.bar_.addEventListener(bustout.gallery.Image.EventType.SHOW,bustout.bind(this.handleImageShow_,this));
this.foo_.hide();
this.bar_.hide();
this.images_=m;
if(!o){o={}
}this.rate_=o.rate||2000;
this.duration_=o.duration||500;
this.cursor_=0;
this.currentImage_=this.foo_;
this.currentImage_.setSrc(this.images_[0])
};
bustout.extend(bustout.gallery.Carousel,bustout.events.EventTarget);
bustout.gallery.Carousel.EventType={BEFORE_SWAP:"before_swap",AFTER_SWAP:"after_swap"};
bustout.gallery.Carousel.prototype.initialized_=false;
bustout.gallery.Carousel.prototype.running_=false;
bustout.gallery.Carousel.prototype.timer_=null;
bustout.gallery.Carousel.prototype.previousImage_=null;
bustout.gallery.Carousel.prototype.start=function(){if(!this.initialized_){setTimeout(bustout.bind(this.start,this),50)
}else{this.running_=true;
this.timer_=setTimeout(bustout.bind(this.swap_,this),this.rate_)
}};
bustout.gallery.Carousel.prototype.stop=function(){clearTimeout(this.timer_);
this.timer_=null;
this.running_=false
};
bustout.gallery.Carousel.prototype.getCurrentImage=function(){return this.currentImage_
};
bustout.gallery.Carousel.prototype.swap_=function(){this.dispatchEvent(new bustout.events.Event(bustout.gallery.Carousel.EventType.BEFORE_SWAP,this));
if(this.running_){if(this.cursor_==(this.images_.length-1)){this.cursor_=0
}else{this.cursor_++
}this.previousImage_=this.currentImage_;
this.currentImage_=this.currentImage_==this.foo_?this.bar_:this.foo_;
this.currentImage_.setSrc(this.images_[this.cursor_])
}};
bustout.gallery.Carousel.prototype.handleImageLoad_=function(a){if(this.previousImage_){this.previousImage_.hide(new bustout.effects.OpacityEffect(this.previousImage_.getId(),1,0,{duration:this.duration_}));
this.previousImage_=null
}this.currentImage_.show(new bustout.effects.OpacityEffect(this.currentImage_.getId(),0,1,{duration:this.duration_}))
};
bustout.gallery.Carousel.prototype.handleImageShow_=function(a){this.dispatchEvent(new bustout.events.Event(bustout.gallery.Carousel.EventType.AFTER_SWAP,this));
if(!this.initialized_){this.initialized_=true
}if(this.initialized_&&this.running_){this.timer_=setTimeout(bustout.bind(this.swap_,this),this.rate_)
}};
bustout.gallery.Carousel.prototype.disposeInternal=function(){bustout.events.Event.superClass_.disposeInternal.call(this);
this.foo_.dispose();
this.foo_=null;
this.bar_.dispose();
this.bar_=null;
this.currentImage_=null;
this.images_=null;
if(this.timer_){clearTimeout(this.timer_);
this.timer_=null
}};