var com=com||{};com.propertypal=com.propertypal||{};com.propertypal.ui=com.propertypal.ui||{};
(function(f){f.extend(com.propertypal.ui,{slideshow:function(C){function z(){var a="";d.enableVideoTour&&d.enable360Tour?a="a.horiz-scroll-item":d.enableVideoTour||d.enable360Tour?d.enableVideoTour&&!d.enable360Tour?a="a.horiz-scroll-item:not(a.horiz-scroll-tour)":!d.enableVideoTour&&d.enable360Tour&&(a="a.horiz-scroll-item:not(a.horiz-scroll-video)"):a="a.horiz-scroll-item:not(a.horiz-scroll-video):not(a.horiz-scroll-tour)";return a}function u(){var a=f(this),e=parseInt(a.attr("data-owidth"))*d.maxUpscale,
b=parseInt(a.attr("data-oheight"))*d.maxUpscale;300>b&&(e/=b,b=300,e*=b);.75>=b/e?v.push({w:e,h:b}):A.push({w:e,h:b});b=f("\x3cdiv/\x3e").addClass("horiz-scroll-item").width(p.width()).height(p.height()).attr("data-slide-url",a.attr("href")).attr("data-slide-rel",a.attr("rel")).attr("data-slide-alt",a.attr("title")).attr("data-poster-url",a.attr("data-poster-url")).attr("data-owidth",e).attr("data-oheight",b).appendTo(p);n.rel&&-1!=a.attr("rel").indexOf("video-placeholder")&&b.addClass("horiz-scroll-video");
n.rel&&-1!=a.attr("rel").indexOf("tour-placeholder")&&b.addClass("horiz-scroll-tour");a.hasClass("horiz-scroll-current")&&b.addClass("horiz-scroll-current");l.push(b);D++;E.html(l.length)}function F(){var a=f(this).parent();0==f("a",a).length&&a.append(f("\x3ca /\x3e").attr("class",d.tourOverlayClass))}function G(){var a=f(this).parent();0==f("a",a).length&&a.append(f("\x3ca /\x3e").attr("class",d.videoOverlayClass))}function w(a,e){var b=f("\x3cimg/\x3e");a.addClass(d.slideLoadingClass);b.attr("src",
a.attr("data-slide-url")).attr("data-owidth",a.attr("data-owidth")).attr("data-oheight",a.attr("data-oheight")).attr("draggable","false").attr("unselectable","on").removeAttr("width").removeAttr("height").addClass(d.imageLoadingClass).appendTo(a).on("dragstart",function(a){a.preventDefault()}).bind("load",function(){x.apply(b[0]);e&&e.apply(b[0])});0<b.height()&&(x.apply(b[0]),e&&e.apply(b[0]))}function k(a,e){if(a&&0<a.length&&!a.attr("data-slide-loaded")){a.attr("data-slide-loaded",!0);var b=a.attr("data-slide-rel");
-1!=b.indexOf("video-placeholder")&&d.enableVideoTour?w(a,G):-1!=b.indexOf("tour-placeholder")&&d.enable360Tour?w(a,F):w(a,e)}else e&&e()}function x(){var a=f(this),e=a.parent();e.removeClass(d.slideLoadingClass);a.removeClass(d.imageLoadingClass);a.hasClass(d.slidePlaceholderImgClass)||e.find("img."+d.slidePlaceholderImgClass).remove();var b=e.data("owidth"),c=e.data("oheight");if(e.hasClass(d.panoramicPhotoClass))if(h.hasClass(d.panoramicClipClass)){var m=e.height()/c,l=e.width();e.height();e=b*
m;a.css({width:e,height:c*m,"margin-left":-((e-l)/2)})}else a.css({width:"",height:"","margin-left":""})}function B(){var a=.75,e=.75;f.each(l,function(){var b=this.data("owidth"),c=this.data("oheight"),f=c/b;b/=c;a>f&&.56<f&&(a=f);e>b&&(e=b);.5625>f?(this.data("clipwidth",16/9*c),this.addClass(d.panoramicPhotoClass)):this.removeClass(d.panoramicPhotoClass)});var b="function"===typeof d.maxWidthPercentage?d.maxWidthPercentage():d.maxWidthPercentage,c="function"===typeof d.maxHeightPercentage?d.maxHeightPercentage():
d.maxHeightPercentage,m=d.constrainHeight;"function"===typeof m&&(m=m());b*=h.width();var g=b*d.landscapeAspectRatio;g>m*c&&(g=m*c,b=g/d.landscapeAspectRatio);c=Math.round(b);m=Math.round(c*a);g>b&&(m=Math.round(g),c=Math.round(m*e));for(b=0;b<l.length;b++){var k=c;g=m;k=parseInt(l[b].attr("data-owidth"));var n=parseInt(l[b].attr("data-oheight"));l[b].data("clipwidth")&&(k=l[b].data("clipwidth"));k=Math.round(k/n*g);l[b].width(k).height(g).css("line-height",g+"px");x.apply(l[b].find("img"))}f(".horiz-scroll-current",
p);q.css("max-width","");q.css("max-width")||q.css("max-width",c)}var d=f.extend(!0,{selector:".ss",landscapeAspectRatio:.75,maxWidthPercentage:.95,maxHeightPercentage:.6,maxUpscale:1.5,defaultContentSelector:".ss-default",slidesWrapperClass:"ss-slides",thumbsWrapperClass:"ss-thumbs",videoWrapperClass:"ss-video",slidePlaceholderImgClass:"ss-placeholder",videoOverlayClass:"ss-media-overlay ss-media-overlay-video",tourOverlayClass:"ss-media-overlay ss-media-overlay-tour",imageLoadingClass:"ss-image-loading",
slideLoadingClass:"ss-slide-loading",panoramicPhotoClass:"ss-panoramic",panoramicClipClass:"ss-panoramic-clip",allowKeyBoardNav:!1,enable360Tour:!1,enableVideoTour:!1,constrainHeight:function(){return window.innerHeight?window.innerHeight:f(window).height()}},C),r=f(window),h=f(d.selector),p=f("."+d.slidesWrapperClass,h),q=f("."+d.thumbsWrapperClass,h),n=f("."+d.thumbsWrapperClass+" "+z(),h),l=[],H=f(".ss-index",h),E=f(".ss-total",h),t=f(".ss-title",h),g=com.propertypal.utils.eventDriven(),D=0,v=
[],A=[],c=null,y=null;h.css("-webkit-user-select","none").css("-webkit-touch-callout","none").css("-moz-user-select","none").css("-ms-user-select","none").css("-o-user-select","none").css("user-select","none").attr("unselectable","on");p.find(d.defaultContentSelector).remove();n.each(u);(function(){var a=[];f.each(0==v.length?A:v,function(c){a[this.w]=a[this.w]?a[this.w]+1:1;if(!a.maxOcc||a.maxOcc<a[this.w])a.maxOcc=a[this.w]})})();2==l.length&&(u.apply(n.first()),u.apply(n.last()));allSlides=f(z(),
h);B();(function(){c=com.propertypal.ui.horizScroll({selector:p,blockNavigation:!1,mouseOverNavigation:!0,dynamicClipper:!0});var a=h.width(),e=h.height();c.bind("beforeresize",function(){if(h.width()!=a||h.height()!=e)a=h.width(),e=h.height(),B()});c.bind("resize",function(){g.trigger("resize")});1>=n.length&&q.hide();c.bind("beforechange",function(b){H.html(b.toIndex+1);b.toItem.attr("data-slide-alt")?(t.html(b.toItem.attr("data-slide-alt")),t.show()):(t.html(""),t.hide())});c.bind("changecomplete",
function(b){k(c.getCurrent());k(c.getPrevious());k(c.getNext(),function(){k(c.getSlide(c.getCurrentIndex()+2))})});c.getFirstVisible()&&k(c.getCurrent(),function(){k(c.getNext(),function(){k(c.getSlide(c.getCurrentIndex()+2))});k(c.getPrevious())});q.is(":visible")&&(y=com.propertypal.ui.horizScroll({selector:q,draggable:!1,blockNavigation:!1,seamless:!1}),c.bind("change",function(b){y.panTo(b.toIndex)}));n.each(function(b){var a=b++;f(this).click(function(b){b.preventDefault();c.panTo(a)})});r.bind("keydown",
function(b){if(!f(b.target).is(":input")){var a=h.offset();d.allowKeyBoardNav&&a.top>=r.scrollTop()&&a.top+h.height()<=r.scrollTop()+r.height()&&(37==b.which?(c.prev(),b.preventDefault()):39==b.which&&(c.next(),b.preventDefault()))}})})();g.options=d;g.thumbsScroll=y;g.slidesScroll=c;g.getCurrentIndex=function(){return c.getCurrentIndex()};g.getWrapper=function(){return h};g.checkResize=function(){c.checkResize()};g.play=function(){c.play()};g.pause=function(){c.pause()};g.togglePlay=function(){return c.togglePlay()};
return g}})})(jQuery);