function AJSlideshow(d,a){var c=0,e="slideshow__";var b=(a&&("dommanipVersion" in a))?a:new DOMManipII();if(!(b&&b.isSupported&&b.dommanipVersion>=2)){this.error=-1;return false}this.dm=b;if(d&&typeof d=="object"){this.maxStep=d.maxStep||200;this.animFreq=d.animFreq||25;this.animWeight=d.animWeight||2;this.leanWidth=d.leanWidth||60;this.urlbase=d.urlbase||"";this.centerXImg=!!d.centerXImg;this.centerYImg=!!d.centerYImg;this.ajaxLoad=!!d.ajaxLoad;this.htmlCaptions=!!d.htmlCaptions;this.zOpenDur=(isNaN(d.zOpenDur))?0:Math.abs(d.zOpenDur);this.singleCapt=!!d.singleCapt;this.extCounter=d.extCounter||false;this.zeroMsgHtml=!!d.zeroMsgHtml;if(typeof d.prefix=="string"){e=d.prefix}if(typeof d.zeroMessage=="string"){this.zeroMsgArray=[d.zeroMessage]}else{if(typeof d.zeroMessage=="object"&&d.zeroMessage.length){this.zeroMsgArray=d.zeroMessage}else{this.zeroMsgArray=false}}if(!isNaN(d.slideInterval)&&d.slideInterval>0){this.slideInterval=Math.floor(d.slideInterval)}else{this.slideInterval=8000}}else{c++}if(b.legacyIE&&this.animFreq<50){this.animFreq=50}this.doFullDraw=false;this.isTransition=false;this.currentIndex=0;this.centerIndex=0;this.maxIndex=null;this.zoomActive=false;this.zoomStartAnim=false;this.origLayerSctop=false;this.totalCount=null;this.totalOffset=null;this.sPrefix=e;this.container=b.ele(e+"container");if(!this.container){c++}this.animTimer=null;this.slideTimer=null;this.images=[];this.bob=[];this.dataLoaded=0;this.dataTotal=0;this.readyFunc=[];this.wasSetup=false;this.capt=null;this.prevLink=null;this.nextLink=null;this.playLink=null;this.zoomLink=null;this.closeLink=null;this.cancelLink=null;this.zoomLayer=null;this.zoomImgDiv=null;this.zoomImage=null;this.filterDiv=null;this.nextRange=null;this.prevRange=null;this.error=c}AJSlideshow.prototype.unloadme=function(){var d,b,a;var c=["prevLink","nextLink","playLink","zoomLink","closeLink","cancelLink"];a=c.length;if(this.slideTimer){window.clearInterval(this.slideTimer);this.slideTimer=null}this.stopAnim();for(d=0;d<a;d++){b=c[d];if(this[b]){this[b].onclick=null}}if(this.images&&this.images.length){a=this.images.length;for(d=0;d<a;d++){if(this.images[d]){this.images[d].onload=null;this.images[d].onerror=null}}}};AJSlideshow.prototype.prepare=function(){var f=this;var e,g=this.sPrefix,d,c,a,b,h;this.wasSetup=true;this.preloader=this.simpleDiv(g+"load","ajslideshow__load");this.container.appendChild(this.preloader);this.preloadCount=this.simpleDiv(g+"counter","ajslideshow__counter");this.preloader.appendChild(this.preloadCount);this.zeroMessenger=this.simpleDiv(g+"zeromessage","ajslideshow__hide");this.container.appendChild(this.zeroMessenger);b=this.simpleDiv(g+"zeromessage_inner","ajslideshow__zero_inner");if(this.zeroMsgArray&&this.zeroMsgArray.length){a=this.zeroMsgArray.length;for(d=0;d<a;d++){h=g+"zeromessage_"+(1+d).toString();c=this.simpleDiv(h,"ajslideshow_zero_message");if(this.zeroMsgHtml){c.innerHTML=this.zeroMsgArray[d]}else{this.dm.appendLText(c,this.zeroMsgArray[d])}b.appendChild(c)}}this.zeroMessenger.appendChild(b);this.picbox=this.simpleDiv(g+"pics","ajslideshow__pics");this.container.appendChild(this.picbox);this.cWidth=this.picbox.offsetWidth;this.cHeight=this.picbox.offsetHeight;this.capt=this.simpleDiv(g+"capt","ajslideshow__capt");this.container.appendChild(this.capt);e=this.preloader.offsetHeight-this.preloadCount.offsetHeight;this.preloadCount.style.marginTop=Math.floor(e/2)+"px";this.prevLink=this.simpleDiv(g+"prev_link","ajslideshow__hide");this.container.appendChild(this.prevLink);this.prevLink.onclick=function(){f.prevPic()};this.nextLink=this.simpleDiv(g+"next_link","ajslideshow__hide");this.container.appendChild(this.nextLink);this.nextLink.onclick=function(){f.nextPic()};this.playLink=this.simpleDiv(g+"play_link","ajslideshow__play_off");this.container.appendChild(this.playLink);this.playLink.onclick=function(){f.slideshow(!f.slideTimer)};this.zoomLink=this.simpleDiv(g+"zoom_link","ajslideshow__hide");this.container.appendChild(this.zoomLink);this.zoomLink.onclick=function(){f.doZoomOpen()}};AJSlideshow.prototype.showLoading=function(c,d,b){var a;
if(c){if(isNaN(b)||isNaN(d)||d==0){if(this.wasSetup){this.dm.emptyElement(this.preloadCount);this.preloader.className="ajslideshow__load"}else{this.prepare()}if(this.preloadCount&&b>0){a="0 / "+Math.floor(b);this.dm.appendText(this.preloadCount,a)}}else{if(this.preloadCount){a=Math.floor(d)+" / "+Math.floor(b);this.dm.emptyElement(this.preloadCount);this.dm.appendText(this.preloadCount,a)}}}else{this.preloader.className="ajslideshow__hide"}};AJSlideshow.prototype.empty=function(){this.stopAnim();this.dm.emptyElement(this.picbox);if(this.capt){this.dm.emptyElement(this.capt)}this.bob=[]};AJSlideshow.prototype.inject=function(e){var a,c,d,b=this;if(e&&typeof e=="object"&&e.pics){this.zeroMessenger.className="ajslideshow__hide";if(typeof e.urlbase=="string"){this.urlbase=e.urlbase}this.totalCount=e.totalCount;this.totalOffset=e.totalOffset;c=e.pics;d=c.length;this.empty();this.images=[];this.dataLoaded=0;this.dataTotal=d;this.maxIndex=d-1;this.showLoading(true,0,this.dataTotal);for(a=0;a<d;a++){this.images[a]=new Image();this.images[a].onerror=(function(f){return function(){b.picLoaded(f,this,false)}})(a);this.images[a].onload=(function(f){return function(){b.picLoaded(f,this,true)}})(a);this.images[a].src=this.urlbase+c[a].pic;if(!c[a].zoom){c[a].zoom=c[a].pic}}this.data=c;this.nextRange=e.nextRange;this.prevRange=e.prevRange;this.setCurrentIndex((this.reverseLoad)?this.maxIndex:0,this.isTransition);this.isTransition=false}else{this.zeroMessenger.className="ajslideshow__zero";this.showLoading(false)}};AJSlideshow.prototype.picLoaded=function(j,e,k){var d,c,h,g,a,b,f=false;if(e){e.onload=null;e.onerror=null;if(k){a=document.createElement("div");a.className="ajslideshow__bob";b=document.createElement("a");b.href="#";b.appendChild(e);a.appendChild(b);a.style.width=e.width+"px";a.style.height=e.height+"px";this.picbox.appendChild(a);h=(this.centerXImg)?e.width:a.offsetWidth;g=(this.centerYImg)?e.height:a.offsetHeight;f={dom:a,width:h,height:g}}}this.bob[j]=f;this.dataLoaded++;this.ready()};AJSlideshow.prototype.ready=function(g){var c,b,a,d,h,e=this;if(this.dataLoaded<this.dataTotal){this.showLoading(true,this.dataLoaded,this.dataTotal);if(g){this.readyFunc.push(g)}}else{a=this.readyFunc.length;for(c=0;c<a;c++){d=this.readyFunc[c];if(typeof d=="function"){d()}}this.readyFunc=[];if(g&&typeof g=="function"){g()}h=[];a=this.bob.length;b=0;for(c=0;c<a;c++){if(this.bob[c]){this.bob[c].dom.firstChild.onclick=(function(f){return function(){if(e.centerIndex==f){e.doZoomOpen()}else{e.setCurrentIndex(f,false)}return false}})(b++);this.bob[c].dataIndex=c;h.push(this.bob[c])}}this.bob=h;this.maxIndex=this.bob.length-1;this.updateTargets();this.updateCounter();this.startAnim()}};AJSlideshow.prototype.getXhr=function(){var b=false;try{if(window.ActiveXObject){b=new ActiveXObject("Microsoft.XMLHTTP")}}catch(a){}if(!b&&window.XMLHttpRequest){b=new XMLHttpRequest()}return b};AJSlideshow.prototype.load=function(a){var c,b=this;if(window.jQuery&&window.jQuery.ajax){this.showLoading(true,0,0);window.jQuery.ajax({type:"GET",url:a,dataType:"json",success:function(d,e){b.inject(d)},error:function(){b.inject(false)}})}else{this.showLoading(true,0,0);c=this.getXhr();if(c){c.open("get",a,true);c.onreadystatechange=function(){var d,e=false;if(c.readyState==4){if(c.status==200){d=c.responseText;if(window.JSON&&typeof window.JSON.parse=="function"){e=window.JSON.parse(d)}else{if(typeof window.jsonParse=="function"){e=window.jsonParse(d)}}if(e){b.inject(e)}else{b.inject(false)}}else{b.inject(false)}c=null}};c.send(null)}}};AJSlideshow.prototype.updateCounter=function(){var b=1+this.currentIndex,a=this.totalCount;if(typeof this.extCounter=="string"){this.extCounter=this.dm.ele(this.extCounter)}if(this.extCounter&&a>0){b+=this.totalOffset;this.dm.emptyElement(this.extCounter);this.dm.appendText(this.extCounter,b+"/"+a)}};AJSlideshow.prototype.setCurrentIndex=function(a,d){var c=this.prevLink,b=this.nextLink;if(!d){this.slideshow(false)}this.doZoomActive(false);if(!isNaN(a)&&a>=0&&a<=this.maxIndex&&this.data[a]){this.currentIndex=Math.floor(a);this.updateTargets();
if(c){if(a==0&&!this.prevRange){c.className="ajslideshow__hide"}else{c.className="ajslideshow__left_show"}}if(b){if(a==this.maxIndex&&!this.nextRange){b.className="ajslideshow__hide";this.slideshow(false)}else{b.className="ajslideshow__right_show"}}if(this.capt){if(this.htmlCaptions){this.capt.innerHTML=this.data[a].capt||""}else{this.dm.emptyElement(this.capt);if(this.data[a].capt){this.dm.appendLText(this.capt,this.data[a].capt)}}}this.updateCounter();return true}return false};AJSlideshow.prototype.updateCurrentIndex=function(b,a){this.setCurrentIndex(this.currentIndex+b,a)};AJSlideshow.prototype.nextPic=function(b){if(this.dataLoaded<this.dataTotal){return false}var a=this.setCurrentIndex(this.currentIndex+1,b);if(!a&&this.nextRange){if(this.ajaxLoad){this.reverseLoad=false;this.isTransition=b;this.load(this.nextRange)}else{window.location.href=this.nextRange}}};AJSlideshow.prototype.prevPic=function(b){if(this.dataLoaded<this.dataTotal){return false}var a=this.setCurrentIndex(this.currentIndex-1,b);if(!a&&this.prevRange){if(this.ajaxLoad){this.reverseLoad=true;this.isTransition=b;this.load(this.prevRange)}else{window.location.href=this.prevRange}}};AJSlideshow.prototype.isVisibleBob=function(a){return(this.currentIndex-2<=a&&a<=this.currentIndex+2)};AJSlideshow.prototype.getTargetPos=function(b,d){var a,e,c=this.bob[b];if(c){if(isNaN(d)||d==0){a=Math.floor((this.cWidth-c.width)/2)}else{if(d<-1){a=this.leanWidth-2*c.width}else{if(d<0){a=this.leanWidth-c.width}else{if(d>1){a=this.cWidth-this.leanWidth+c.width}else{a=this.cWidth-this.leanWidth}}}}e=Math.floor((this.cHeight-c.height)/2);return{x:a,y:e}}return false};AJSlideshow.prototype.updateTargets=function(){var b,a=this.bob.length,c,d;for(b=0;b<a;b++){c=this.bob[b];if(c){d=this.getTargetPos(b,b-this.currentIndex);if(d&&typeof d=="object"){this.bob[b].targetx=d.x;this.bob[b].targety=d.y}}}this.doFullDraw=true};AJSlideshow.prototype.moveThings=function(l){var e,c,h,d,a,k,m,j,b;var g=this.animWeight;var f=g-1;if(this.doFullDraw||l){c=0;h=this.bob.length;this.doFullDraw=false}else{c=this.currentIndex-2;h=this.currentIndex+3}for(e=c;e<h;e++){d=this.bob[e];if(d&&d.dom){if(this.isVisibleBob(e)){a=d.dom;k=parseInt(a.style.left,10);if(isNaN(k)){j=0.1}else{j=d.targetx-k}if(j<-1||j>1){m=Math.floor(0.5+(d.targetx+f*k)/g);b=Math.abs(k-m);if(b>this.maxStep){m=k+(this.maxStep*((j>0)?1:-1))}else{if(b<1){m=k+((j>0)?1:-1)}}a.style.left=m+"px"}else{if(j){a.style.left=d.targetx+"px"}}if(e==this.currentIndex&&(j>=-f&&j<=f)){this.centerIndex=e;this.doZoomActive(a,this.images[this.bob[e].dataIndex])}a.style.top=d.targety+"px";a.style.display="block"}else{d.dom.style.display="none"}}}};AJSlideshow.prototype.startAnim=function(){var a=this;this.moveThings();this.showLoading(false);this.animTimer=window.setInterval(function(){if(a.zoomLayer){a.moveLayer(a.zoomLayer)}else{a.moveThings()}},this.animFreq)};AJSlideshow.prototype.stopAnim=function(){if(this.animTimer){window.clearInterval(this.animTimer);this.animTimer=null}};AJSlideshow.prototype.slideshow=function(b){var d=this;var a=this.slideInterval,c=this.playLink;if(b&&!this.slideTimer){this.slideTimer=window.setInterval(function(){d.nextPic(true)},a);if(c){c.className="ajslideshow__play_on"}}else{if(!b&&this.slideTimer){window.clearInterval(this.slideTimer);this.slideTimer=null;if(c){c.className="ajslideshow__play_off"}}}};AJSlideshow.prototype.doZoomActive=function(c,a){var b=this.zoomLink;if(b){if(c&&c.style&&c.firstChild){b.className="ajslideshow__zoom_on";b.style.top=c.style.top;b.style.left=c.style.left;b.style.display="block";b.style.width=(c.firstChild.offsetWidth||a.width)+"px";b.style.height=(c.firstChild.offsetHeight||a.height)+"px"}else{b.style.width="0px";b.style.height="0px";b.className="ajslideshow__hide"}}};AJSlideshow.prototype.doZoomOpen=function(){var a,f,j,h,d,b,e=this.sPrefix;var g=this;var i=document.getElementsByTagName("body").item(0);var c=this.bob[this.centerIndex];if(c){h=c.dataIndex;if(!this.data[h]){return false}this.disableMain(true);this.zoomStartAnim=false;f=this.simpleDiv(e+"zoomlayer","ajslideshow__layer");
a=this.simpleDiv(e+"zoomrow_pic","ajslideshow__zoomrow_pic");f.appendChild(a);this.zoomImgDiv=a;this.cancelLink=document.createElement("a");this.cancelLink.href="#";this.cancelLink.className="loading";this.cancelLink.onclick=function(){g.doZoomClose();return false};a.appendChild(this.cancelLink);j=this.simpleDiv(e+"zoomrow_capt","ajslideshow__zoomrow_capt");j.style.display="none";f.appendChild(j);a=this.simpleDiv(e+"zoomcapt","ajslideshow__zoomcapt");j.appendChild(a);if(this.singleCapt){b=this.data[h].capt}else{b=this.data[h].zoomcapt}if(b){if(this.htmlCaptions){a.innerHTML=b||""}else{if(b){this.dm.appendLText(a,b)}}}a=this.simpleDiv(e+"zoomclose","ajslideshow__zoomclose");j.appendChild(a);this.closeLink=a;this.closeLink.onclick=function(){g.doZoomClose()};d=new Image();d.onload=function(){window.setTimeout(function(){g.doZoomPic(true)},150)};d.onerror=function(){g.doZoomPic(false)};d.src=this.urlbase+this.data[h].zoom;this.zoomImage=d;i.appendChild(f);this.zoomLayer=f}};AJSlideshow.prototype.doZoomClose=function(){var a=this.zoomLayer;if(this.zoomImage){this.zoomImage.onload=null;this.zoomImage.onerror=null;this.zoomImage=null}this.cancelLink=null;this.closeLink=null;this.zoomImgDiv=null;this.origLayerSctop=false;if(a){a.parentNode.removeChild(a);this.zoomLayer=null}this.disableMain(false)};AJSlideshow.prototype.doZoomPic=function(a){var b;if(a){a=this.zoomImage;b=this.cancelLink;if(b){b.parentNode.removeChild(b)}this.cancelLink=null;b=this.zoomImgDiv;if(b.offsetWidth<a.width||b.offsetHeight<a.height){if(this.zOpenDur>0){this.zblockW=b.offsetWidth;this.zblockH=b.offsetHeight;this.zoomStartAnim=new Date().getTime()}else{this.doZoomEndPic()}}}else{this.doZoomClose()}};AJSlideshow.prototype.doZoomEndPic=function(){var b,a=this.zoomImage;this.zoomStartAnim=false;this.zoomImgDiv.style.height=a.height+"px";this.zoomImgDiv.style.width=a.width+"px";this.zoomImgDiv.appendChild(a);b=this.dm.ele(this.sPrefix+"zoomrow_capt");if(b){b.style.display="block";b.style.width=a.width+"px"}};AJSlideshow.prototype.moveLayer=function(d){var f=this.getSizes(),g=false,c=false,a,h,b,e;if(this.zoomStartAnim){b=new Date().getTime()-this.zoomStartAnim;if(b>this.zOpenDur){this.doZoomEndPic()}else{e=b/this.zOpenDur;e=Math.sin(e*Math.PI/2);a=this.zblockW+e*(this.zoomImage.width-this.zblockW);h=this.zblockH+e*(this.zoomImage.height-this.zblockH);this.zoomImgDiv.style.width=a+"px";this.zoomImgDiv.style.height=h+"px"}}if(d){if(f.width<=d.offsetWidth){a=0;g=true}else{a=Math.floor((f.width-d.offsetWidth)/2);if(a<0){a=0}}if(f.height<=d.offsetHeight){h=0;g=c=true}else{h=Math.floor((f.height-d.offsetHeight)/2);if(h<0){h=0}}if(g||this.dm.legacyIE){if(c){if(this.origLayerSctop===false){this.origLayerSctop=(isNaN(f.sctop))?0:Math.floor(f.sctop)}h+=this.origLayerSctop}else{h+=(isNaN(f.sctop))?0:Math.floor(f.sctop)}d.style.position="absolute"}else{d.style.position="fixed"}d.style.top=h+"px";d.style.left=a+"px"}};AJSlideshow.prototype.simpleDiv=function(c,a){var b=document.createElement("div");if(a){b.className=a}if(c){b.id=c}return b};AJSlideshow.prototype.getSizes=function(){var a={width:0,height:0,sctop:0,scleft:0};var b=document.body;var c=document.documentElement;if(typeof(window.innerHeight)=="number"){a.height=window.innerHeight;a.width=window.innerWidth}else{if(c&&(c.clientWidth||c.clientHeight)){a.height=c.clientHeight;a.width=c.clientWidth}else{if(b&&(b.clientWidth||b.clientHeight)){a.height=b.clientHeight;a.width=b.clientWidth}}}if(b&&(b.scrollLeft||b.scrollTop)){a.sctop=b.scrollTop;a.scleft=b.scrollLeft}else{if(c&&(c.scrollLeft||c.scrollTop)){a.sctop=c.scrollTop;a.scleft=c.scrollLeft}else{if(typeof(window.pageYOffset)=="number"){a.sctop=window.pageYOffset;a.scleft=window.pageXOffset}}}if(a.sctop<0){a.sctop=0}if(a.scleft<0){a.scleft=0}return a};AJSlideshow.prototype.disableMain=function(c){var d=document.getElementsByTagName("body").item(0);var g=this.sPrefix+"filter";var b,a,f=this.getSizes();var e=this.dm.ele(g);if(c&&(!e)){a=d.offsetHeight+2;if(!isNaN(f.height)&&f.height>a){a=f.height}b=document.createElement("div");b.className="ajslideshow__filter";b.id=g;
b.style.height=a+"px";d.appendChild(b);this.filterDiv=b}else{if(!c&&e){this.filterDiv=null;e.parentNode.removeChild(e)}}};
