function s2j_onPlayerInitOver(){isGalleryVideoPlaying=!0}function s2j_onPlayOver(){isGalleryVideoPlaying=!1}(function(n){for(var i=["Width","Height"],t;t=i.pop();)(function(t,i){n.fn[t]=t in new Image?function(){return this[0][t]}:function(){var r=this[0],n,t;return r.tagName.toLowerCase()==="img"&&(n=new Image,n.src=r.src,t=n[i]),t}})("natural"+t,t.toLowerCase())})(jQuery),Vista.ImageResize={},Vista.ImageResize.BoundHorizontally=function(n,t){var r=n.width(),i=n.height();window.setTimeout(function(){var n=t.height()!==0?t.height():i,u=t.width()!==0?t.width():r,s=i,h,c,f,e,o;n<i&&(n=i,u=r),h=s/n*u,t.height(s),t.width(h),n=t.height(),u=t.width(),u>r&&(c=r,f=r/u*n,t.width(c),t.height(f),t.addClass("horizontal-bound")),i>n&&(e=i-n,o=Math.ceil(e/2),t.css("top",o),t.addClass("horizontal-bound"))},50)},Vista.GetImagesAsync=function(n,t){function u(n,t){var i=$(t);return $.Deferred(function(r){t.onload=function(){r.resolve(t)},t.onerror=function(){r.reject(),(!t.fileSize||t.fileSize<0)&&i.remove()},t.src=n,i.addClass("gallery-image other-image")}).promise()}var f=t.height()||300,i=$.Deferred(),r=[];return n.filter(function(n){var e=new Image,f,o;r.push(u(n.ImagePath,e)),e=$(e),e.removeAttr("height"),e.removeAttr("width"),n.Link&&n.Link.indexOf("polyv.net")>=0?(f=$("<embed>"),f.attr("src",n.Link+"&autoplay=true&ban_ui=on"),f.attr("id","ployvPlayer"),f.width("100%"),f.height("100%"),f.addClass("gallery-image gallery-video other-image"),f.attr("allowfullscreen","true"),f.attr("allowscriptaccess","always"),t.append(f)):n.Link?(o=$('<a target="_blank" />'),o.attr("href",n.Link),e.appendTo(o),t.append(o)):t.append(e)}),$.each(r,function(){this.done(function(n){var r=$(n);Vista.ImageResize.BoundHorizontally(t,r),i.resolve()})}),i.promise()};var isGalleryVideoPlaying=!1;Vista.ImageGallery=function(n,t){function e(n){var e,t;return n=n%i.length,e=$(i[r]),e.removeClass(l),e.addClass(a),t=$(i[n]),t.addClass(l),t.removeClass(a),$(u[r]).removeClass(f),$(u[n]).addClass(f),$(o[r]).removeClass(f),$(o[n]).addClass(f),r=n,t}function h(){c=setTimeout(function(){h(),y()},t)}function y(){isGalleryVideoPlaying&&i[r].className.indexOf("gallery-video")>=0||e(r+1)}function v(){clearTimeout(c);var t=$(this),n=u.index(t);e(n),h()}t=t||7e3;var i=[],r=0,l="current-image",a="other-image",f="selected",u=[],s,o=[],c;(function(){var t,r;if(i=n.find(".gallery-image").toArray(),i.length!==0){if(i.length===1){e(0);return}n.append('<div class="image-select-container"></div>'),t=n.find(".image-select-container"),t.append('<div class="image-select-inner"></div>'),r=t.find(".image-select-inner"),n.append('<div class="image-descriptions"></div>'),s=n.find(".image-descriptions"),jQuery.each(i,function(){r.append('<span class="image-select">&nbsp;</span>');var n=$(this).data("description");n&&s.append("<span class=image-description>"+n+"</span>")}),u=n.find(".image-select"),u.bind("click",v),o=s.find(".image-description"),e(0),h()}})()},Vista.ImagePopout=function(n){function i(){var i=$(this);t(i)}function t(n){var u=n.clone(),f=$(n[0]).naturalWidth(),r=$(n[0]).naturalHeight(),o=$(window).width()-150,e=$(window).height()-150,i=r,t=f;r>e?(i=e,t=e/r*f):f>o&&(t=o,i=o/f*r),u.attr("width",t).attr("height",i).css("position","inherit"),u.width(t),u.height(i),$.modal('<div id="frame-hook"></div>',{overlayClose:!0,opacity:50,modal:!0,containerCss:{backgroundColor:"#2B2725",width:t,height:i+15},overlayCss:{backgroundColor:"#000"},closeHTML:'<button type="button" id="close-gallery" class="user-action"><span class="icon">'+Vista.Lang.Shared.Close+"</span></button>"}),$("#frame-hook").append(u)}(function(){n.find("img.gallery-image").bind("click",i)})()},Vista.Images=function(){function n(n,t,i,r){function u(t){for(var f=[],h,s,o,u=0;u<t.length;u++)f.push(i(t[u]));h=Vista.GetImagesAsync(f,e),n.removeClass("loading"),s=new Vista.ImageGallery(n),r&&(o=new Vista.ImagePopout(n))}n.append('<div class="images" />');var e=n.find(".images"),f=$.get(t);$.when(f).done(u)}return{ImageGalleryFromFolder:function(t,i,r,u,f){var e=t.data("id"),h=Vista.Utilities.format(Vista.Urls.CDN.GetImageData,i,e,u,f),s=Vista.Urls.CDN.GalleryImage,o=function(n){return{ImagePath:Vista.Utilities.format(s,i,e,n.ImagePath,u,f)}},c=n(t,h,o,r)},AdvertImages:function(t,i,r){var f=Vista.Utilities.format(Vista.Urls.Ads.GetAdData,i,r),u=function(n){return{ImagePath:n.ImagePath,Link:n.Link}};n(t,f,u)}}}()