var PageElements;(function(n){var i=function(){this.arrImagesForLoad=[];this.arrImagesLoaded=[];this.arrSequence=[];this.autoplay=!1;this.isAnimation=!1;this.animationInterval=null;this.animationSpeed=-1;this.animationHeight=0;this.animationWidth=0;this.$imagesContainer=null;this.$imageLoading=null;this.$clickedOnPreview=!1;this.xmlFile="";this.images3dIndex=0;this.images3dPrefix=null;this.init=function(t,i){var r,u,f;return this.$imagesContainer=t,n("img",this.$imagesContainer).remove(),this.arrImagesForLoad.length=0,this.arrImagesLoaded.length=0,this.arrSequence.length=0,this.$imageLoading=n("<img />").attr("class","preview").attr("src",i.animationLoadingImg),this.$imagesContainer.append(this.$imageLoading),this.$imageLoading.mouseup(function(n){n.stopPropagation()}),this.stopAnimation(),this.autoplay=i.autoplay,this.animationSpeed=i.animationSpeed,this.animationHeight=i.animationHeight,this.animationWidth=i.animationWidth,this.xmlFile=i.xmlFile,this.images3dIndex=i.images3dIndex,this.images3dPrefix=i.images3dPrefix,
r=n.Deferred(),"XDomainRequest"in window&&window.XDomainRequest!==null?(u=new XDomainRequest,u.open("get",this.xmlFile),f=this,u.onload=function(){f.loadImageXml(n.parseXML(u.responseText)).done(function(){r.resolve()}).fail(function(){r.reject()})},u.onerror=function(){r.reject()},u.send()):this.basicXhr=n.ajax({type:"GET",url:i.xmlFile,dataType:"xml",context:this,success:function(n){this.loadImageXml(n).done(function(){r.resolve()}).fail(function(){r.reject()})},error:function(){r.reject()}}),this.initialization=r.promise()};this.loadImageXml=function(t){var i=this,r;return n(t).find("fsi_parameter").each(function(){var u=n(this),b=u.find("FPX").find("Base").attr("value"),y=u.find("images3d").length,e,p,c,a,f,s,h,r,v,t;y===1?e=u:(p=!!i.images3dPrefix,p?(c=u.find('images3d[prefix="'+i.images3dPrefix+'"]'),e=c.length?c.closest("Image"):u.find("Image").first()):(y<i.images3dIndex+1&&(i.images3dIndex=0),e=n(u.find("Image")[i.images3dIndex])));var l=e.find("Options").find("SceneSets").attr("value"),o=e.find("images3d"),
k=o.attr("prefix")?o.attr("prefix"):"",w=o.attr("suffix");if(l!="")for(a=l.split(","),t=0;t<a.length;t++)if(f=a[t].split("-"),f.length==1)i.arrSequence.push(Math.max(parseInt(Math.round(f[0]/2),10),1)-1);else if(f.length==2)if(s=Math.max(parseInt(Math.round(f[0]/2),10),1),h=Math.max(parseInt(Math.round(f[1]/2),10),1),s<h)for(r=s;r<=h;r++)i.arrSequence.push(r-1);else for(r=s;r>=h;r--)i.arrSequence.push(r-1);else continue;if(v="even",i.arrSequence.length==1&&(v="eq("+i.arrSequence[0]+")"),o.find("image:"+v).each(function(){var t=n(this).attr("src");i.arrImagesForLoad.push(i.createImage(b+k+t+w+"&width="+i.animationWidth+"&height="+i.animationHeight+"&profile=jpeg"+(w==".png"?"&effects=matte(fff)":"")+"&quality=95"))}),l=="")for(t=0;t<i.arrImagesForLoad.length;t++)i.arrSequence.push(t)}),r=n.Deferred(),this.prepareImages().done(function(){r.resolve()}).fail(function(){r.reject()}),r.promise()};this.createImage=function(t){return n("<img />").hide().css("margin","auto").attr("class","preview").data("src",t)};this.
prepareImages=function(){for(var r,t,u=[],f=this.arrImagesForLoad.length,i=0;i<f;i++)r=this.arrImagesForLoad.shift(),t=n.Deferred(),u.push(t),r.one("load",{context:this,deferral:t,imageNumber:i},function(t){t.data.context.arrImagesLoaded[t.data.imageNumber]=n(this);t.data.deferral.resolve(t.data.context)}).one("error",{deferral:t},function(n){n.data.deferral.reject()}).attr("src",r.data("src"));return n.when.apply(n,u).then(function(n){n.arrImagesLoaded.length&&n.setUpPosterImage(n.arrImagesLoaded[0]);n.$imagesContainer.append.apply(n.$imagesContainer,n.arrImagesLoaded);n.allImagesReady()})};this.setUpPosterImage=function(n){this.currentShowingIndex=0;this.$imageLoading.hide();n.mouseup(function(){this.clickedOnPreview=!0}).show()};this.allImagesReady=function(){var n=this;this.$imageLoading.hide();this.autoplay&&!this.clickedOnPreview&&(this.animationInterval=setInterval(function(){n.showNext()},this.animationSpeed));this.clickedOnPreview&&(this.clickedOnPreview=!1);this.arrImagesLoaded[0]&&this.arrImagesLoaded[
0].unbind("click")};this.startAnimation=function(){var n=this;this.isAnimation||(this.isAnimation=!0,this.animationInterval=setInterval(function(){n.showNext()},this.animationSpeed))};this.stopAnimation=function(){this.isAnimation=!1;clearInterval(this.animationInterval)};this.destroy=function(){this.initialization.state()==="pending"?this.basicXhr&&this.basicXhr.readyState!==4&&this.basicXhr.abort():this.stopAnimation()};this.showNext=function(){if(this.$imagesContainer.parents("body").length==0){this.stopAnimation();return}var n=this.currentShowingIndex+1;if(n>=this.arrSequence.length&&(n=0),this.arrSequence[n]==this.arrSequence[this.currentShowingIndex]){this.currentShowingIndex=n;return}this.arrImagesLoaded[this.arrSequence[this.currentShowingIndex]].hide();this.arrImagesLoaded[this.arrSequence[n]].show();this.currentShowingIndex=n}},t={init:function(t){var s={xmlFile:"default.xml",autoplay:!1,animationSpeed:100,animationWidth:400,animationHeight:400,callbacks:{onNoTarget:function(){},onPartlySuccess:function(
){},onSuccess:function(){},onEachSuccess:function(){},onFailure:function(){},onEachFailure:function(){},onInit:function(){},onEachInit:function(){}}},r=n.extend(!0,{},s,t),f=[],u=this.length,e=0,o=0;return this.each(function(){var t=n(this),u=n.Deferred(),s;f.push(u);t.data("showcase")||(s=new i,t.data("showcase",s));t.data("showcase").init(t,r).done(function(){r.callbacks.onEachSuccess.call(t);e++}).fail(function(){r.callbacks.onEachFailure.call(t);o++}).always(function(){r.callbacks.onEachInit.call(t);u.resolve()})}),u?n.when.apply(n,f).done(function(){u===e?r.callbacks.onSuccess.call(this):u===o?r.callbacks.onFailure.call(this):r.callbacks.onPartlySuccess.call(this);r.callbacks.onInit.call(this)}):(r.callbacks.onNoTarget.call(this),r.callbacks.onInit.call(this)),this},startAnimation:function(){return this.each(function(){n(this).data("showcase").startAnimation()})},stopAnimation:function(){return this.each(function(){n(this).data("showcase").stopAnimation()})},destroy:function(){return this.each(function()
{var t=n(this);t.data("showcase").destroy();t.data("showcase",undefined)})}};n.fn.showcase=function(n){if(t[n])return t[n].apply(this,Array.prototype.slice.call(arguments,1));if(typeof n!="object"&&n)console.log("there was an error");else return t.init.apply(this,arguments)}})(jQuery),function(n){var t=function(){function n(n,t){var i=this;this.origin=n;this.showcaseContainer=n.contextQuery;this.freezer=t;this.innerContainer=this.showcaseContainer.children("div");this.isInitialized=this.initializeShowcase().then(function(){i.isAnimating=!0;i.freezer.introduce(i.showcaseContainer,i.pause.bind(i),i.resume.bind(i),function(){return i.isAnimating})})}return n.prototype.pause=function(n){var t=this,i;return n===void 0&&(n=!1),i=function(){if(!t.innerContainer.data("showcase"))return $.Deferred().reject().promise();(n||t.isAnimating)&&(t.innerContainer.showcase("stopAnimation"),t.isAnimating=!1)},this.isInitialized.then(function(){return i()},function(){return i()})},n.prototype.resume=function(n){var t=this;return(
n===void 0&&(n=!1),this.freezer.isFrozen)?$.Deferred().reject().promise():this.isInitialized.then(function(){if(!t.innerContainer.data("showcase"))return $.Deferred().reject().promise();(n||!t.isAnimating)&&(t.innerContainer.showcase("startAnimation"),t.isAnimating=!0)})},n.prototype.destroy=function(){return this.freezer.destroy(),this.isInitialized.state()==="pending"?$.when(this.cleanUpPendingTeaser()):this.cleanUpInitializedTeaser()},n.prototype.initializeShowcase=function(){var n=$.Deferred(),t=this.showcaseContainer.data("index");return this.innerContainer.showcase({xmlFile:this.showcaseContainer.data("fsitarget"),images3dIndex:t?t:0,images3dPrefix:this.showcaseContainer.data("prefix"),autoplay:!0,animationSpeed:400,animationWidth:this.showcaseContainer.width()||this.getWidthByAspectRatio(),animationHeight:this.showcaseContainer.height()||this.getHeightByAspectRatio(),animationLoadingImg:this.showcaseContainer.data("loader"),callbacks:{onFailure:function(){n.reject()},onInit:function(){n.resolve()}}}),n.
promise()},n.prototype.getWidthByAspectRatio=function(){var n=this.getAspectRatio(this.showcaseContainer.data("aspect-ratio-horizontal"),this.showcaseContainer.data("aspect-ratio-vertical"));return n?Math.round(this.showcaseContainer.height()*n):0},n.prototype.getHeightByAspectRatio=function(){var n=this.getAspectRatio(this.showcaseContainer.data("aspect-ratio-vertical"),this.showcaseContainer.data("aspect-ratio-horizontal"));return n?Math.round(this.showcaseContainer.width()*n):0},n.prototype.getAspectRatio=function(n,t){return parseInt(n)/parseInt(t)},n.prototype.cleanUpPendingTeaser=function(){this.innerContainer.data("showcase")&&this.innerContainer.showcase("destroy")},n.prototype.cleanUpInitializedTeaser=function(){var n=this;return this.isInitialized.then(function(){return eventAggregator.unSubscribeMultiple(n.subscriptions),n.pause()},function(){return n.pause()}).then(undefined,function(){return $.Deferred().resolve().promise()}).then(function(){n.innerContainer.data("showcase",undefined)})},n}();n.ShowcaseController=
t;DependencySystem.define(t).as(DS.Controller).andInject([DS.Origin,Common.Freezer])}(PageElements||(PageElements={})),function(n){var t=function(){function t(){}return t.componentName="showcase-component",t.query=".showcase, .dlp-showcase",t.controller=n.ShowcaseController,t}();n.ShowcaseComponent=t;DependencySystem.define(t).as(DS.Component)}(PageElements||(PageElements={}))