/*
 * jQuery Peepshow
 * Copyright 2011 ZULIUS LLC All rights reserved. 
 *
 * jQuery plugin for creating an image gallery. The plugin centers/crops/expands groups of images
 * contained in unordered list elements <li>.
 *
 * Demo: http://demos.zulius.com/jquery/peepshow
 *
 * Dev notes:
 * - An image group is simply a set of images contained within a list element <li>.
 * - Groups of images are wrapped with a relatively positioned image-wrap div for cropping/centering purposes.
 * - Auto centering wraps the entire jq-peepshow element with a relatively positioned
 *   div.jq-peepshow-auto-center so floated elements can be centered.
 * - Hover events are bound to the image-wrap div's. Public methods 'expand' and 'shrink'
 *   can be called on either the image-wrap div's or their parent li's.
 * - Expansion/shrinkage is done to the image-wrap div's.
 * - Once the image-wrap div has been added to the DOM, the plugin assumes
 *   it has no child images of class "exclude". 
 *
 *
 * @fileOverview jQuery Peepshow 
 * @author ZULIUS LLC 
 * @version 1.1.7
 */
(function($){var opt,$container,interval={id:null,length:null,firstImageLength:null},pluginImagesPreloaded=false,touch={enabled:false,init:function(mode){switch(mode){case false:touch.enabled=false;break;case true:touch.enabled=true;break;default:if(typeof(mode)=="string"&&mode.toLowerCase()=="auto"){touch.enabled="ontouchstart" in window?true:false}break}if(!touch.enabled){return}setTimeout(function(){window.scrollTo(0,1)},100);var ua=window.navigator.userAgent;if(ua.match(/iphone/i)||ua.match(/ipod/i)||ua.match(/ipad/i)){touch.ios=true}$container.addClass("touch")},$expanded:undefined,overlayFadeTimeoutId:undefined,orientationTriggered:false,ios:false},methods={init:function(options){$container=this;opt=$.extend({},jQuery.fn.peepshow.defaults,options);_validateOpt();$container.addClass(opt.containerClass);touch.init(opt.touchMode);if(opt.autoCenter){$container.wrap($("<div></div>").addClass("jq-peepshow-auto-center"))}if(opt.autoMargin){_autoMargin(this)}if(typeof(opt.itemsPerRow)=="string"&&opt.itemsPerRow.toLowerCase()=="auto"){_autoRows(this)}_setFirstImageRotationSpeed();return this.each(function(){var rowItemCount=0,$lis=$(this).children("ul").children("li");$lis.each(function(){rowItemCount++;if(parseInt(opt.itemsPerRow)){rowItemCount=_layoutRows(this,rowItemCount)}_crop(this);var $images=$(this).find("img").not(opt.excludeSelector);_bindLoad($images);_preloadPluginImages(this);_bindExpand(this)})})},expand:function(){if(touch.enabled){return _touchExpand.call(this)}var $this=$(this),$imgWrap=$this.hasClass(opt.wrapClass)?$this:$this.find("."+opt.wrapClass);if($imgWrap.data("expanded")){return}var $img=$($imgWrap.find("img")[0]),imgW=$img.width(),imgH=$img.height(),expandDim=_applyExpansionLimits(imgW,imgH);$imgWrap.stop(true,true);var expandArgs={"margin-left":"-"+((parseInt(expandDim[0])/2))+"px","margin-top":"-"+((parseInt(expandDim[1])/2))+"px",width:expandDim[0],height:expandDim[1],top:"50%",left:"50%"};_setGroupMaxDim($imgWrap,expandArgs.width,expandArgs.height);_showOverlay({imgWrap:$imgWrap,img:$img});function _doneGrown(el,imgEl){$(el).data("expanded",true).parent("li").addClass("expanded");$(imgEl).addClass("shown")}if(!opt.expandSpeed){$imgWrap.css(expandArgs);_doneGrown($imgWrap,$img);return}$imgWrap.animate(expandArgs,{duration:opt.expandSpeed,easing:opt.expandEasing,complete:function(e){_doneGrown(this,$img)}})},shrink:function(){_unrotate(this)},destroy:function(){if(opt.autoCenter){this.unwrap()}if(touch.enabled){_touchShrinkUnbind()}return this.find("."+opt.wrapClass).each(function(){var $this=$(this);$this.unbind("mousemove"+opt.hoverIntentOptions.bindNamespace+" mouseenter"+opt.hoverIntentOptions.bindNamespace+" mouseleave"+opt.hoverIntentOptions.bindNamespace);$this.removeData("expanded").removeData("displayedImageIndex").removeData("rotateState").removeData("maxDim");$this.find("."+opt.wrapClass).unbind("load error load"+opt.bindNamespace+"-center");$this.find(".rotate-state-button").unbind("click"+opt.bindNamespace)})}};function _validateOpt(){if(typeof(opt.itemsPerRow)=="number"){opt.itemsPerRow=parseInt(opt.itemsPerRow)}opt.crop[0]=_css2num(opt.crop[0]);opt.crop[1]=_css2num(opt.crop[1]);opt.minExpansion[0]=_css2num(opt.minExpansion[0]);opt.minExpansion[1]=_css2num(opt.minExpansion[1]);opt.maxExpansion[0]=_css2num(opt.maxExpansion[0]);opt.maxExpansion[1]=_css2num(opt.maxExpansion[1]);opt.autoMarginRatio=parseFloat(opt.autoMarginRatio);opt.rotateSpeed=parseInt(opt.rotateSpeed);if(opt.crop[0]>opt.minExpansion[0]){opt.minExpansion[0]=opt.crop[0]}if(opt.crop[1]>opt.minExpansion[1]){opt.minExpansion[1]=opt.crop[1]}if(opt.crop[0]>opt.maxExpansion[0]){opt.maxExpansion[0]=opt.crop[0]}if(opt.crop[1]>opt.maxExpansion[1]){opt.maxExpansion[1]=opt.crop[1]}}function _css2num(value){return parseInt(value,10)||0}function _autoRows(container){var containerParentWidth=$(container).parent().width(),$childLi=$(container).children("ul").children("li"),totalLiWidth=0,avgLiWidth=0,itemsPerRow=0;if(!$childLi.length){return false}$childLi.each(function(){var $this=$(this);totalLiWidth+=opt.crop[0]+_css2num($this.css("margin-right"))+_css2num($this.css("margin-left"))+_css2num($this.css("padding-right"))+_css2num($this.css("padding-left"))});avgLiWidth=totalLiWidth/$childLi.length;if(avgLiWidth<=0){return false}itemsPerRow=Math.floor(containerParentWidth/avgLiWidth);if(itemsPerRow<=0){return false}opt.itemsPerRow=itemsPerRow;return true}function _autoMargin(container){var containerParentWidth=$(container).parent().width(),$childLi=$(container).children("ul").children("li"),rowLiWidth=0,marginRight=0,marginBottom=0;if(!opt.autoMarginRatio){return false}if(opt.crop[1]){marginBottom=parseInt(opt.crop[1])*parseFloat(opt.autoMarginRatio)}if(opt.crop[0]){marginRight=parseInt(opt.crop[0])*parseFloat(opt.autoMarginRatio);if(parseInt(opt.itemsPerRow)&&opt.itemsPerRow>0){for(var i=0;i<opt.itemsPerRow;i++){if(!$childLi[i]){continue}var $li=$($childLi[i]);rowLiWidth+=parseInt(opt.crop[0])+_css2num($li.css("padding-left"))+_css2num($li.css("padding-right"))}var marginRightRow=marginRight*(opt.itemsPerRow-1);rowLiWidth+=marginRightRow;if(rowLiWidth>containerParentWidth){marginRight=(marginRightRow-(rowLiWidth-containerParentWidth))/(opt.itemsPerRow-1);if(marginRight<1){marginRight=1}marginBottom=marginRight}}}if(marginRight){$childLi.css("margin-right",marginRight)}if(marginBottom){$childLi.css("margin-bottom",marginBottom)}}function _layoutRows(el,rowItemCount){if(rowItemCount==1||(rowItemCount==(opt.itemsPerRow+1))){$(el).addClass("first")}if(rowItemCount==opt.itemsPerRow){$(el).addClass("last");rowItemCount=0}return rowItemCount}function _touchUpdateOverlayCount(arg){arg=$.extend({},{current:undefined,total:undefined,imgWrap:touch.$expanded},arg);var $overlayTop=arg.imgWrap.find(".overlay.top:first");if(arg.current==undefined){arg.current=arg.imgWrap.data("displayedImageIndex")+1;arg.current=arg.current==undefined?1:arg.current}if(arg.total==undefined){arg.total=arg.imgWrap.find("img").length}var countText=arg.current+"/"+arg.total;arg.imgWrap.find(".overlay.top:first .count:first").text(countText)}function _showOverlay(arg){arg=$.extend({},{showTop:false,forceBottom:opt.playPauseButton,img:undefined,imgWrap:undefined,fadeOutTopAfter:2000},arg);var $imgWrap=$(arg.imgWrap);if(arg.img==undefined){var displayedImageIndex=$imgWrap.data("displayedImageIndex");arg.img=$($imgWrap.find("img")[displayedImageIndex])}var $overlayTop=$imgWrap.children(".overlay.top");$overlayBottom=$imgWrap.children(".overlay.bottom"),text=$(arg.img).attr(opt.captionAttribute);if(!arg.forceBottom&&(!text||typeof(text)!="string"||!text.length)){if($overlayBottom.is(":visible")){$overlayBottom.fadeOut("fast")}}else{$overlayBottom.children("span").text(text);if($.browser.msie){$overlayBottom.css("filter",$overlayBottom.css("filter"))}if(!$overlayBottom.is(":visible")){$overlayBottom.fadeIn(_getTransitionSpeed())}}if(touch.enabled&&arg.showTop){clearTimeout(touch.overlayFadeTimeoutId);$overlayTop.fadeIn(_getTransitionSpeed());if(arg.fadeOutTopAfter){touch.overlayFadeTimeoutId=setTimeout(function(){if($overlayTop.is(":visible")){$overlayTop.fadeOut("fast")}},arg.fadeOutTopAfter)}}}function _hideOverlay(imgWrap){$(imgWrap).children(".overlay").hide()}function _bindExpand(liEl){if(opt.bindNamespace){opt.hoverIntentOptions.bindNamespace=opt.bindNamespace+"-hover"}opt.hoverIntentOptions.over=function(e){$(this).peepshow("expand");_rotate(this)};opt.hoverIntentOptions.out=function(e){$(this).peepshow("shrink")};return $(liEl).children("."+opt.wrapClass).each(function(){var $imgWrap=$(this);if(!$imgWrap.find("img").length){return}if(touch.enabled){var $anchors=$imgWrap.find("a").has("img").not(opt.excludeSelector);$anchors.each(function(){var $this=$(this),clickEvents=[],boundEvents=$this.data("events"),onclick=$this.attr("onclick");if(onclick){$this.data("onclickEvent",onclick);$this.removeAttr("onclick")}if(boundEvents&&boundEvents.click){$.each(events.click,function(){clickEvents.push(this)});$this.unbind("click")}if(!clickEvents.length){return}$this.data("boundClickEvents",clickEvents)});$imgWrap.bind("click"+opt.bindNamespace,function(e){e.preventDefault();if($(this).data("expanded")){return}_touchExpand.call(this);_rotate(this);return false});return}$imgWrap.hoverIntent(opt.hoverIntentOptions)})}function _setFirstImageRotationSpeed(){var ratio=2.5,firstImageInterval=parseInt(opt.rotateSpeed-(ratio*opt.hoverIntentOptions.interval));interval.firstImageLength=firstImageInterval>opt.hoverIntentOptions.interval?firstImageInterval:opt.rotateSpeed}function _rotate(e){var $this=$(this),$imgWrap;if(!e){$imgWrap=$this.hasClass(opt.wrapClass)?$this:$this.find("."+opt.wrapClass)}else{$imgWrap=e.target==undefined?$(e):$(e.target);$imgWrap=$imgWrap.hasClass(opt.wrapClass)?$imgWrap:$imgWrap.find("."+opt.wrapClass)}var $allImages=$imgWrap.find("img");if(interval.id!=null){_unrotate($imgWrap);return}if($allImages.length<2){return}_setRotateState($imgWrap,"play",$imgWrap.children(".overlay").children(".rotate-state-button"));interval.length=interval.firstImageLength;interval.id=setInterval(function(){if(_getRotateState($imgWrap)=="pause"){return}if(interval.length==interval.firstImageLength){interval.length=parseInt(opt.rotateSpeed);clearTimeout(interval.id);interval.id=setInterval(arguments.callee,interval.length)}var index=$imgWrap.data("displayedImageIndex"),nextIndex,$shown,$next;if(index==undefined){index=0}nextIndex=$allImages[index+1]==undefined?0:index+1;$shown=$($allImages[index]);$next=$($allImages[nextIndex]);if(!$next.attr("complete")){if(opt.showLoader&&(opt.playPauseButton)){_showNextLoader($imgWrap);return}}$shown.addClass("last-shown");$next.css({opacity:0,display:"inline"}).addClass("shown");var __transitionImages=function(){if(!opt.transitionEffect||(typeof(opt.transitionEffect)!="string")||opt.transitionEffect.toLowerCase()=="none"){$shown.css({opacity:0}).removeClass("shown last-shown");$next.css({opacity:1});return}var speed=_getTransitionSpeed();switch(opt.transition){case"fade":default:$next.animate({opacity:1},speed,function(){$shown.removeClass("shown last-shown")});$shown.animate({opacity:0},speed);break}};$imgWrap.data("displayedImageIndex",(nextIndex));if(touch.enabled){_touchUpdateOverlayCount({imgWrap:$imgWrap,current:nextIndex+1,total:$allImages.length});_showOverlay({imgWrap:$imgWrap,fadeOutTopAfter:0,img:$next,showTop:false});_touchPositionExpanded({imgWrap:$imgWrap,fade:false,callback:__transitionImages})}else{_showOverlay({imgWrap:$imgWrap,img:$next});_expandResize($imgWrap,$next,__transitionImages)}},interval.length)}function _setRotateState(imgWrap,state,button){$(imgWrap).data("rotateState",state);if(button!=undefined){if(state=="pause"){$(button).addClass("paused");return}$(button).removeClass("paused")}}function _getRotateState(imgWrap){return $(imgWrap).data("rotateState")}function _flipRotateState(imgWrap,button){if(_getRotateState(imgWrap)=="play"){_setRotateState(imgWrap,"pause",button);return}_setRotateState(imgWrap,"play",button)}function _getTransitionSpeed(){var speed=300;if(opt.transitionEffectSpeedRatio&&opt.rotateSpeed){speed=opt.transitionEffectSpeedRatio*opt.rotateSpeed}return speed}function _unrotate(e){var $this=(this),$imgWrap;if(!e){$imgWrap=$this.hasClass(opt.wrapClass)?$this:$this.find("."+opt.wrapClass)}else{$imgWrap=e.target==undefined?$(e):$(e.target);$imgWrap=$imgWrap.hasClass(opt.wrapClass)?$imgWrap:$imgWrap.find("."+opt.wrapClass)}clearInterval(interval.id);interval.id=null;var $allImages=$imgWrap.find("img");$imgWrap.stop(true,true);$allImages.stop(false,true).removeClass("last-shown shown").css({opacity:0});var $shown=$allImages.first();$shown.css({opacity:1,display:"inline","z-index":1});$imgWrap.data("displayedImageIndex",0);_shrink($imgWrap)}function _shrink(imgWrap){var $imgWrap=$(imgWrap);if(!$imgWrap.data("expanded")){return}var shrinkArgs={position:"absolute",left:0,top:0,width:"100%",height:"100%","margin-top":0,"margin-left":0};$imgWrap.stop(true,true);if(touch.enabled){var $imgs=$imgWrap.find("img");$imgs.each(function(){var $img=$(this),origDim=$img.data("origDim");$img.removeClass("shown");if(origDim!=undefined&&origDim.length==2){$img.css({width:origDim[0],height:origDim[1]})}});$imgWrap.css(shrinkArgs);_center($imgs[0]);_touchShrinkUnbind.call($imgWrap)}else{if(!opt.shrinkSpeed){$imgWrap.css(shrinkArgs).find("img").removeClass("shown")}else{$imgWrap.stop(true,true).animate(shrinkArgs,{duration:opt.shrinkSpeed,easing:opt.shrinkEasing,complete:function(){$(this).find("img").removeClass("shown")}})}}_hideOverlay(imgWrap);$imgWrap.data({expanded:false,displayedImageIndex:0}).removeData("maxDim").parent("li").removeClass("expanded")}function _setGroupMaxDim(imgWrap,width,height){var $imgWrap=$(imgWrap),maxDim=$imgWrap.data("maxDim"),updateMaxDim=false;if(maxDim==undefined){$imgWrap.data("maxDim",[width,height]);return}if(width>maxDim[0]){maxDim[0]=width;updateMaxDim=true}if(height>maxDim[1]){maxDim[1]=height;updateMaxDim=true}if(!updateMaxDim){return}$imgWrap.data("maxDim",maxDim)}function _preloadPluginImages(el){if(pluginImagesPreloaded){return false}var preload=[],$imgWrap=$(el).children("."+opt.wrapClass).first(),spinnerSrc=$imgWrap.css("background-image");if(spinnerSrc){spinnerSrc=spinnerSrc.replace(/"/g,"").replace(/url\(|\)$/ig,"");preload.push(spinnerSrc)}for(var i=0,len=preload.length;i<len;++i){if(typeof(preload[i])!="string"||preload[i].toLowerCase()=="none"){continue}$("<img/>")[0].src=preload[i]}pluginImagesPreloaded=true}function _bindLoad(images){$(images).each(function(){if(this.complete){_display(this);return}$(this).one("load",function(e){_display(this)}).one("error",_displayErrorImg)})}function _displayErrorImg(e){if(this.src==opt.imageNotFound){return false}var $this=$(this),origSrc=$(this).attr("src");$this.attr({"orig-src":origSrc,src:opt.imageNotFound});if($this.attr("complete")){_display(this);return true}$(this).one("load",function(e){_display(this)});return true}function _display(images){return $(images).each(function(){var $this=$(this);$this.unbind("load");_center(this);_hideNextLoader($this.closest("."+opt.wrapClass));if(!$this.siblings().length&&$this.parent("a").length){if(!$this.parent("a").prev().length){$this.css("display","inline");_hideBgLoader(this)}return}if(!$this.prev().length){$this.css("display","inline");_hideBgLoader(this)}})}function _showNextLoader(imageWrap){$(imageWrap).children(".overlay").children(".rotate-state-button").addClass("loading")}function _hideNextLoader(imageWrap){$(imageWrap).children(".overlay").children(".rotate-state-button").removeClass("loading")}function _hideBgLoader(el){var $el=$(el);if(!$el.hasClass(opt.wrapClass)){$el.closest("."+opt.wrapClass).removeClass("loading");return}$el.removeClass("loading")}function _crop(el){var $el=$(el);$el.css({width:opt.crop[0],height:opt.crop[1]});if($el.children("."+opt.wrapClass).length){return}var $imgWrap=$("<div></div>"),imgWrapClass=opt.wrapClass,$imgs=$el.find("img").not(opt.excludeSelector),$anchors=$el.find("a").has("img").not(opt.excludeSelector);if(opt.roundCorners){imgWrapClass+=" round"}if(opt.showLoader){imgWrapClass=imgWrapClass+" loading"}$imgWrap.attr({"class":imgWrapClass});if($anchors.length){$anchors.wrapAll($imgWrap)}else{$imgs.wrapAll($imgWrap)}var countText=$imgs.length?"1/"+$imgs.length:"",$overlayTop=$('<div class="overlay top"><a class="back" href="">&#9664&nbsp;&nbsp;Back</a><div class="count">'+countText+"</div></div>").css("display","none"),$overlayBottom=$('<div class="overlay bottom"></div>').css("display","none"),$spanText=$("<span></span>");$overlayBottom.append($spanText);if(opt.playPauseButton){var button=$('<a title="pause"></a>').addClass("rotate-state-button");$overlayBottom.append(button)}$overlayBottom.append($spanText);$imgWrap=$el.children("."+opt.wrapClass);$imgWrap.append($overlayTop,$overlayBottom);if(opt.playPauseButton&&!touch.enabled){$imgWrap.children(".overlay.bottom").children(".rotate-state-button").bind("click"+opt.bindNamespace,_playPause)}}function _playPause(e){if(e!=undefined){e.preventDefault()}if(opt.showLoader&&$(this).hasClass("loading")){return false}_flipRotateState($(this).parents("."+opt.wrapClass),this);return false}function _center(img){return $(img).each(function(){var $this=$(this),width=$this.width(),height=$this.height();$this.css({"margin-top":"-"+(parseInt(height)/2)+"px","margin-left":"-"+(parseInt(width)/2)+"px",top:"50%",left:"50%"})})}function _uncenter(){return this.each(function(){$(this).css({"margin-top":0,"margin-left":0,left:0,top:0})})}function _expandResize(imgWrap,img,cb){var $imgWrap=$(imgWrap),$img=$(img),imgW=$img.width(),imgH=$img.height(),imageWrapW=$imgWrap.width(),imageWrapH=$imgWrap.height(),__done=typeof cb==="function"?cb:undefined;if(opt.retainMaxExpansion&&maxDim&&(maxDim[0]<=imgWrapW)&&(maxDim[1]<=imgWrapH)){if(__done!==undefined){__done()}return}var mleft=imgW,mtop=imgH,expandArgs={"margin-top":0,"margin-left":0,top:"50%",left:"50%",width:imgW,height:imgH};if(opt.retainMaxExpansion){var maxDim=$imgWrap.data("maxDim"),setMaxDim=false;if(maxDim==undefined||maxDim.length!=2){setMaxDim=true}else{if(maxDim[0]>expandArgs.width){expandArgs.width=maxDim[0];mleft=maxDim[0]}else{setMaxDim=true}if(maxDim[1]>expandArgs.height){expandArgs.height=maxDim[1];mtop=maxDim[1]}else{setMaxDim=true}}if(setMaxDim){_setGroupMaxDim($imgWrap,expandArgs.width,expandArgs.height)}}var expandDim=_applyExpansionLimits(expandArgs.width,expandArgs.height);expandArgs.width=expandDim[0];mleft=expandDim[0];expandArgs.height=expandDim[1];mtop=expandDim[1];expandArgs["margin-left"]="-"+(parseInt(mleft)/2)+"px";expandArgs["margin-top"]="-"+(parseInt(mtop)/2)+"px";$imgWrap.stop(true,true);if(!opt.expandSpeed){$imgWrap.css(expandArgs);if(__done!==undefined){__done()}return}$imgWrap.animate(expandArgs,{duration:opt.expandSpeed,easing:opt.expandEasing,complete:function(){if(__done!==undefined){__done()}}})}function _applyExpansionLimits(width,height){if(width<opt.minExpansion[0]){width=opt.minExpansion[0]}else{if(width>opt.maxExpansion[0]){width=opt.maxExpansion[0]}}if(height<opt.minExpansion[1]){height=opt.minExpansion[1]}else{if(height>opt.maxExpansion[1]){height=opt.maxExpansion[1]}}return[width,height]}function _touchExpanded($imgWrap,e){if(e!=undefined){e.preventDefault()}var $target=$(e.target),$overlayTop=$imgWrap.children(".overlay.top");switch(true){case ($target.hasClass("rotate-state-button")):_playPause.call($target,e);var state=_getRotateState($imgWrap),oarg={imgWrap:$imgWrap,showTop:true,fadeOutTopAfter:0};if(state=="play"){delete (oarg.fadeOutTopAfter)}_showOverlay(oarg);return;case ($target.hasClass("back")):return _unrotate($imgWrap);case ($overlayTop.is(":visible")&&$target.attr("nodeName").toLowerCase()=="img"):var $a=$target.parent("a");if($a.length){var onclick=$a.data("onclickEvent"),href=$a.attr("href"),target=$a.attr("target");if(onclick){eval("(function(){"+onclick+"}); onclick();")}var clickEvents=$a.data("clickEvents");if(clickEvents!=undefined&&clickEvents.length){for(var i=0;i<clickEvents.length;$i++){$a.trigger(clickEvents[i])}}if(href&&!href.match(/^\s*javascript:/i)){if(target&&target.toLowerCase()=="_blank"){window.open(href,"_self")}else{window.location.replace(href)}_unrotate($imgWrap)}}return}if(_getRotateState($imgWrap)=="pause"){return}_showOverlay({imgWrap:$imgWrap,showTop:true})}function _touchExpand(){var $this=$(this),$imgWrap=$this.hasClass(opt.wrapClass)?$this:$this.find("."+opt.wrapClass);if($imgWrap.data("expanded")){return}touch.$expanded=$imgWrap;$imgWrap.data({expanded:true,displayedImageIndex:0}).parent("li").addClass("expanded");$("body").css("overflow","hidden");try{$("body").bind("touchstart"+opt.bindNamespace,function(e){return _touchExpanded.call(this,$imgWrap,e)})}catch(err){}_showOverlay({imgWrap:$imgWrap,showTop:true});_touchPositionExpanded.call({imgWrap:$imgWrap});$(window).bind("orientationchange"+opt.bindNamespace,function(e){touch.orientationTriggered=true;_touchPositionExpanded({fade:false});setTimeout(function(){touch.orientationTriggered=false},500)}).bind("scroll"+opt.bindNamespace,function(e){if(touch.orientationTriggered){touch.orientationTriggered=false;return}if(!touch.ios){return}if($(window).scrollTop()==0){return _unrotate($imgWrap)}})}function _touchPositionExpanded(arg){arg=$.extend({},{imgWrap:touch.$expanded,fade:true,callback:undefined},arg);var dii=arg.imgWrap.data("displayImageIndex")?arg.imgWrap.data("displayImageIndex"):0,$img=$(arg.imgWrap.find("img")[dii]),vw=window.innerWidth,vh=window.innerHeight,iOrigDim=$img.data("origDim"),iw=iOrigDim==undefined?$img.width():iOrigDim[0],ih=iOrigDim==undefined?$img.height():iOrigDim[1],expandTop=0,expandLeft=0;if(iOrigDim==undefined){$img.data("origDim",[iw,ih])}if(vw<iw){iw=vw;ih="auto"}else{if(vh<ih){ih=vh;iw="auto"}}if(touch.ios){expandTop=window.pageYOffset;expandLeft=window.pageXOffset}var cssArgs={position:"fixed",width:vw,height:vh,top:expandTop,left:expandLeft};if(arg.fade){cssArgs.opacity=0.4}arg.imgWrap.css(cssArgs);if(arg.fade){arg.imgWrap.animate({opacity:1},"fast")}$img.css({width:iw,height:ih,position:"relative"});iw=$img.width();ih=$img.height();$img.css({"margin-top":"-"+((parseInt(ih)/2))+"px",top:"50%",left:"auto","margin-left":"auto"});if(typeof(arg.callback)=="function"){arg.callback()}}function _touchShrinkUnbind(){$(window).unbind("orientationchange"+opt.bindNamespace).unbind("scroll"+opt.bindNamespace);$("body").css("overflow","auto").unbind("touchstart"+opt.bindNamespace);if($(this).hasClass(opt.wrapClass)){_touchUpdateOverlayCount({imgWrap:this,current:1})}}jQuery.fn.peepshow=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof method==="object"||!method){return methods.init.apply(this,arguments)}else{$.error("Method "+method+" does not exist on jQuery.peepshow")}}};jQuery.fn.peepshow.defaults={autoCenter:true,autoMargin:true,autoMarginRatio:0.25,bindNamespace:".jq-peepshow",containerClass:"jq-peepshow",captionAttribute:"caption",crop:[200,200],excludeSelector:"img.exclude",expandEasing:"swing",expandSpeed:0,hoverIntentOptions:{sensitivity:9,interval:100,timeout:0},imageNotFound:"img/image-not-found.jpg",itemsPerRow:3,maxExpansion:[500,500],minExpansion:[300,300],playPauseButton:false,retainMaxExpansion:true,rotateSpeed:1700,roundCorners:false,showLoader:true,shrinkEasing:"swing",shrinkSpeed:0,touchMode:"auto",transitionEffect:"fade",transitionEffectSpeedRatio:0.27,wrapClass:"image-wrap"}})(jQuery);
/*
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*   sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*   interval: 100,   // number = milliseconds of polling interval
*   over: showNav,  // function = onMouseOver callback (required)
*   timeout: 0,   // number = milliseconds delay before onMouseOut function call
*   out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
* @modifiedBy  Timbo White, ZULIUS LLC
*
*
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0,bindNamespace:".hoverIntent"};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove"+cfg.bindNamespace,track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove"+cfg.bindNamespace,track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove"+cfg.bindNamespace,track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind("mouseenter"+cfg.bindNamespace,handleHover).bind("mouseleave"+cfg.bindNamespace,handleHover)}})(jQuery);
