(function(e){function n(e,t){return(""+e).indexOf(t)!==-1}function r(e){for(var t in e){if(m_style[e[t]]!==undefined){return[e[t],prefixes[t]]}}}function i(e){var t=e.charAt(0).toUpperCase()+e.substr(1);props=(e+" "+domPrefixes.join(t+" ")+t).split(" ");return r(props)}(function(e){e.fn.hoverIntent=function(t,n){var r={sensitivity:7,interval:100,timeout:0};r=e.extend(r,n?{over:t,out:n}:t);var i,s,o,u;var a=function(e){i=e.pageX;s=e.pageY};var f=function(t,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if(Math.abs(o-i)+Math.abs(u-s)<r.sensitivity){e(n).unbind("mousemove",a);n.hoverIntent_s=1;return r.over.apply(n,[t])}else{o=i;u=s;n.hoverIntent_t=setTimeout(function(){f(t,n)},r.interval)}};var l=function(e,t){t.hoverIntent_t=clearTimeout(t.hoverIntent_t);t.hoverIntent_s=0;return r.out.apply(t,[e])};var c=function(t){var n=(t.type=="mouseover"?t.fromElement:t.toElement)||t.relatedTarget;while(n&&n!=this){try{n=n.parentNode}catch(t){n=this}}if(n==this){return false}var i=jQuery.extend({},t);var s=this;if(s.hoverIntent_t){s.hoverIntent_t=clearTimeout(s.hoverIntent_t)}if(t.type=="mouseover"){o=i.pageX;u=i.pageY;e(s).bind("mousemove",a);if(s.hoverIntent_s!=1){s.hoverIntent_t=setTimeout(function(){f(i,s)},r.interval)}}else{e(s).unbind("mousemove",a);if(s.hoverIntent_s==1){s.hoverIntent_t=setTimeout(function(){l(i,s)},r.timeout)}}};return this.mouseover(c).mouseout(c)}})(jQuery);jQuery.extend(jQuery.easing,{easeOutBack:function(e,t,n,r,i,s){if(s==undefined)s=1.70158;return r*((t=t/i-1)*t*((s+1)*t+s)+1)+n},easeOutQuint:function(e,t,n,r,i){return r*((t=t/i-1)*t*t*t*t+1)+n}});var t=function(e,t){if(typeof console!="undefined"&&typeof console.debug!="undefined"&&opts.debug===true){if(!t)console.log(e);else if(t=="info")console.info(e)}else{}};mod="modernizr",m=document.createElement(mod),m_style=m.style,domPrefixes="Webkit Moz O ms Khtml".split(" "),prefixes=" -webkit- -moz- -o- -ms- -khtml- ".split(" ");var s=i("backgroundSize");var o={init:function(n){var r=false,i;var o={speedView:600,speedRemove:400,showCaption:true,speedCaption:800,debug:false,loadingIndicator:"ajax-loader.gif",loadingIndicatorPos:"center",easing:"easeOutQuint",captionHeight:32,breathingSize:0,hoverIntent:true,useBgImg:false};opts=e.extend(o,n);t("Options","info");t("speedView: "+opts.speedView);t("speedRemove: "+opts.speedRemove);t("showCaption: "+opts.showCaption);t("speedCaption: "+opts.speedCaption);return this.each(function(){var n=e(this);n.addClass("original");n.data("originalWidth",n.width());n.data("originalHeight",n.height());n.data("originalLeft",n.position().left);n.data("originalTop",n.position().top);if(!n.parent().parent().hasClass("zoomContainer")){var r=n.parent().wrap('<div class="zoomContainer" />');var i=n.clone().appendTo(r.parent().parent()).addClass("trigger");r.css("width",n.data("originalWidth")+"px");r.css("height",n.data("originalHeight")+"px");r=n.parent().parent();if(s&&opts.useBgImg)var o=e('<div class="imageContainer"></div>').appendTo(r)}var u=n.attr("alt");var a=r.find(".gallerycaption");if(a.length==0)a=e('<div class="gallerycaption">'+u+"</div>").appendTo(r);n.attr("alt","");i.attr("alt","");n.data("image",n.attr("src"));if(typeof e.fn.hoverIntent=="function"&&opts.hoverIntent==true){i.css({"z-index":"110",opacity:"0"}).hoverIntent(function(){t("mouseenter on: "+n.attr("src"),"info");n.data("zoomedOut",false);e.fn.hoverZoom("loadImage",n,i,r)},function(){t("mouseleave on: "+n.attr("src"),"info");e.fn.hoverZoom("zoomOut",n,i,r)}).click(function(e){e.preventDefault();return false})}else{i.css({"z-index":"110",opacity:"0"}).hover(function(){t("mouseenter on: "+n.attr("src"),"info");e.fn.hoverZoom("loadImage",n,i,r)},function(){t("mouseleave"+n.attr("src"),"info");e.fn.hoverZoom("zoomOut",n,i,r)}).click(function(e){e.preventDefault();return false})}})},loadImage:function(n,r,i){t("function loadImage()","info");if(n.parent("a").attr("href")&&n.data("isLoaded")!=true){n.largeImgSrc=n.parent("a").attr("href");t("largeImg that should be loaded: "+n.largeImgSrc);loading=e('<img src="'+opts.loadingIndicator+'" class="loading" />').appendTo(i);if(opts.loadingIndicatorPos=="center"){loading.css({left:n.width()/2-loading.width()/2+"px",top:n.height()/2-loading.height()/2+"px"})}else if(opts.loadingIndicatorPos=="tr"){loading.css({left:n.width()-loading.width()+"px"})}else if(opts.loadingIndicatorPos=="br"){loading.css({left:n.width()-loading.width()+"px",top:n.height()-loading.height()+"px"})}else if(opts.loadingIndicatorPos=="bl"){loading.css({top:n.height()-loading.height()+"px"})}e("<img />").load(function(){t("ready loading image: "+this.src);n.next(".loading").remove();n.data("isLoaded",true);n.data("loadedWidth",this.width);n.data("loadedHeight",this.height);n.css({width:n.data("originalWidth"),height:n.data("originalHeight")});if(n.data("zoomedOut")!=true){n.attr("src",n.largeImgSrc);e.fn.hoverZoom("startZoom",n,r,i)}}).attr("src",n.largeImgSrc)}else{t("Image already in cache.");n.attr("src",n.largeImgSrc);e.fn.hoverZoom("startZoom",n,r,i)}},startZoom:function(n,r,i){t("function startZoom()","info");var o,u;i.addClass("zoomed");if(o==undefined)o=n.data("loadedWidth");if(u==undefined)u=n.data("loadedHeight");caption=i.find(".gallerycaption");var a=e.fn.hoverZoom("getDimensions",caption,i,o,u);t("returned dimensions: "+a);n.data("marginTop",0);n.data("marginLeft",0);triggerPos=r.offset();n.data("marginLeft",-triggerPos.left);n.data("marginTop",-triggerPos.top);if(n.closest("li").css("z-index")==0){n.closest("li").css({"z-index":"100"})}e.fn.hoverZoom("centerImage",n,i,a);newwidth=a[0]+"px";newheight=a[1]+"px";newdimensions=newwidth+" "+newheight;if(!s|opts.useBgImg===false){n.css({"z-index":"105"}).css({width:a[0]+"px",height:a[1]+"px"})}imageContainer=i.find(".imageContainer");if(s&&opts.useBgImg===true){property="'"+s[1]+"background-size"+"'";bgSize=a[0]+"px "+a[1]+"px";imageContainer.css({"background-image":"url("+n.largeImgSrc+")","background-repeat":"no-repeat","-moz-background-size":bgSize,"-webkit-background-size":bgSize,"-o-background-size":bgSize,"background-size":bgSize,position:"absolute"});n.hide()}i.css({"z-index":"100"}).stop(true,false).animate({top:n.data("itemTop"),left:n.data("itemLeft"),width:a[0]+"px",height:a[1]+"px",marginTop:n.data("marginTop")+"px",marginLeft:n.data("marginLeft")+"px"},opts.speedView+20,opts.easing,function(){if(caption.text()!="undefined"&&caption.text()!=""&&opts.showCaption===true)e.fn.hoverZoom("showCaption",i,a)});imageContainer.show().css({"z-index":"102"}).stop(true,false).animate({width:a[0]+"px",height:a[1]+"px"},opts.speedView+20,opts.easing)},showCaption:function(e,n){var r;t("function showCaption()","info");if(opts.showCaption==true&&caption!="undefined"){t("function showCaption()","info");caption=e.find(".gallerycaption");captionHeight=caption.outerHeight();var i=caption.css("paddingTop");i=i.replace("px","");r=n[1]-captionHeight;caption.css({top:r+"px","z-index":"101",width:"100%"}).css("display","block");newcaptionpos=captionHeight;e.animate({height:"+="+newcaptionpos+"px"},opts.speedCaption,opts.easing);caption.animate({top:"+="+newcaptionpos+"px"},opts.speedCaption,opts.easing)}},getViewport:function(){t("function getViewport()","info");e("body").data("viewport",[e(window).width(),e(window).height(),e(document).scrollLeft(),e(document).scrollTop()]);return[e(window).width(),e(window).height(),e(document).scrollLeft(),e(document).scrollTop()]},centerImage:function(n,r,i){t("function centerImage()","info");var s=e("body").data("viewport");t("Viewport"+s);n.data("itemLeft",s[2]+Math.round((s[0]-i[2]+opts.breathingSize*2)/2));n.data("itemTop",s[3]+Math.round((s[1]-i[3]+opts.breathingSize*2)/2));t("itemLeft: "+n.data("itemLeft"));t("itemTop: "+n.data("itemTop"))},getDimensions:function(n,r,i,s){t("function getDimensions()","info");var o=e.fn.hoverZoom("getViewport");var u=r.outerWidth()-r.width();var a=r.outerHeight()-r.height();var f=i/s;var l=o[0]/o[1];var c=n.text();var h=0;var p;var d;var v;if(c==""||opts.showCaption==false)p=0;else{p=n.outerHeight();h=a/2}if(f>l){d=o[0]-u-opts.breathingSize*2;v=Math.round(d/f);t("calculate max width based on page width")}else{v=o[1]-p-a-h;d=Math.round(v*f);t("calculate max height based on page height")}if(i>d||s>v){i=d;s=v}t("Viewport: "+o);t("maxWidth (excluding borders): "+d+", maxHeight (excluding borders): "+v);t("captionheight: "+p);finalWidth=i+u+opts.breathingSize*2;finalHeight=s+a+p+h+opts.breathingSize*2;t("final width and height of the container: "+finalWidth+","+finalHeight);return[i,s,finalWidth,finalHeight]},zoomOut:function(n,r,i){t("function zoomOut","info");n.attr("src",n.data("image"));i.find(".loading").remove();i.find(".gallerycaption").css("display","none");imageContainer=i.find(".imageContainer");if(i.hasClass("zoomed"))i.css({"z-index":"0"}).removeClass("zoomed").stop(true,false).animate({marginTop:"0",marginLeft:"0",top:n.data("originalTop"),left:n.data("originalLeft"),width:n.data("originalWidth"),height:n.data("originalHeight")},opts.speedRemove,opts.easing,function(){n.fadeIn();if(n.closest("li").css("z-index")==100){n.closest("li").css({"z-index":"0"})}});imageContainer.stop(true,false).animate({width:n.data("originalWidth"),height:n.data("originalHeight"),zIndex:"0"},opts.speedRemove,opts.easing,function(){e(this).hide()});n.css({"z-index":"0"}).stop(true,false).animate({marginTop:"0",marginLeft:"0",top:n.data("originalTop"),left:n.data("originalLeft"),width:n.data("originalWidth"),height:n.data("originalHeight")},opts.speedRemove,opts.easing,function(){if(n.closest("li").css("z-index")==100){n.closest("li").css({"z-index":"0"})}});n.data("zoomedOut",true)}};e.fn.hoverZoom=function(t){if(o[t]){return o[t].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof t==="object"||!t){return o.init.apply(this,arguments)}else{e.error("Method "+t+" does not exist on jQuery.zoomer")}}})(jQuery)