(function(b){window.di=window.di||{};var a=window.di;a.pages=a.pages||{};a.pages.featuredContent=function(){var p=false,J=a.constants,A=J.featuredContent,s=a.utils,l=A.imageDimensions.preview,k=A.imageDimensions.thumbnail,D=false,w=false,v=function(){},H=v,y=v,I=v,x=v,t=v,j=v,g=null,m=null,o=false,C=false,B=[],e=0,G={thumbScrollSpeed:500,startDelay:10,holdTime:5000,autoStart:true,disabled:false,stopAfterClick:true,stopOnHover:true,restartAfterClickDelay:15000,reloadAfterLoadingDelay:true,maxLoadingDelay:60000},f=b.extend({},G);function r(u){if(!o||!B||B.length<1){return false;}var c=e-1<0?B.length-1:e-1;if(u&&f.stopAfterClick){t(true);}C=false;if(H(c,u)&&B.length>3){I(1);}return true;}function h(u){if(!o||!B||B.length<1){return false;}var c=e+1===B.length?0:e+1;if(u&&f.stopAfterClick){t(true);}C=false;if(H(c,u)&&B.length>3){I(-1);}return true;}function q(c){if(!B||B.length<1||c>=B.length||c<0){return null;}var u=B[c];return s.getImageUrl({guid:p?null:u.guid,filename:p?u.fileName:null,type:J.imgTypes.preview,width:l.width,height:l.height,fill:true,trim:true});
}H=function(Q,R){if(!B||B.length<1||Q>=B.length||Q<0||Q===e){return false;}var P=B[Q],O=Q+1===B.length?0:Q+1;e=Q;R=typeof R==="boolean"?R:!f.stopOnHover;var K=q(Q);function M(){var V=a.pages.common.$getAbToolbar(P.guid,p?["stillStatic"]:null,function(){if(f.stopAfterClick){t(true);}});var U=function(){b(this).blur();return false;};var T=b("<div/>").addClass("featuredItem").css("backgroundImage","url("+K+")").append(o?b("<div/>").addClass("fcNav fcHoverOnly").append(b("<a/>").attr({href:"#",title:"Click to view the previous Featured Image"}).text("Previous").bind("click",function(){b(this).blur().unbind().bind("click",U);r(true);return false;})):null,o?b("<div/>").addClass("fcNav fcNavRight fcHoverOnly").append(b("<a/>").attr({href:"#",title:"Click to view the next Featured Image"}).text("Next").bind("click",function(){b(this).blur().unbind().bind("click",U);h(true);return false;})):null,b("<div/>").addClass("featuredMetadata fcHoverOnly").append(b("<div/>").addClass("transparency"),b("<div/>").addClass("fmContent captionText").text(P.caption).prepend(V)));
if(R){T.find(".fcHoverOnly").css("display","block");}var W=b("#featuredContent");W.prepend(T)[w?"addClass":"removeClass"]("expandedThumbs");W.find(".featuredItem:last").fadeOut().queue(function(){W.find(".featuredItem:last").remove();b(this).dequeue();});}var L=false;var N=window.setTimeout(function(){if(!L){var T=b("#featuredContent .featuredItem:last");if(T.find(".largeLoading").length===0){T.prepend(b("<div/>").addClass("largeLoading").append(b("<span/>").text("Loading...")).hide());}T.find(".largeLoading").fadeIn("fast");C=true;t();window.clearTimeout(m);if(f.reloadAfterLoadingDelay){m=window.setTimeout(function(){C=false;j();},f.maxLoadingDelay);}}},750);var c=b("<img/>").bind("load",function(){L=true;window.clearTimeout(N);window.clearTimeout(m);if(C){C=false;x();}M();}).bind("error",function(){M();}).attr("src",K);if(o&&!J.request.isLowBandwidth){var S=q(O);if(S){var u=b("<img/>").attr("src",S);}}return true;};function n(){var Q=b("#featuredThumbnails"),S=b("#featuredThumbnails .container:first"),X=function(aa){return aa.offset().left;
},O=function(){return X(Q)+1;},u=k.home.width+1,T=Q.width(),M=S.width(),R=S.position().left,V=R-M,N=Math.ceil((M+T)/M)+1;S.data("pos",R).css("zIndex",1);for(var U=1;U<N;U++){var Z=(U*M)+R;S.clone(true).css({left:Z,zIndex:U*2}).data("pos",Z).appendTo(Q);}Q.find(".container:last").css("left",V).data("pos",V);function L(ab,aa){if(typeof ab!=="number"||ab===0){return false;}ab=Math.round(ab);aa=typeof aa==="boolean"?aa:true;Q.find(".container").each(function(){var ae=b(this),ad=ae.data("pos");if(ad<V){var ag=V;Q.find(".container").each(function(){var ai=b(this).position().left;ag=ai>ag?ai:ag;});ad=ag+M;ae.css("left",ad).data("pos",ad);}else{if(ad>R+((N-1)*M)){var ah=10*M;Q.find(".container").each(function(){var ai=b(this).position().left;ah=ai<ah?ai:ah;});ad=ah-M;ae.css("left",ad).data("pos",ad);}}var ac=ad+ab,af=f.thumbScrollSpeed;if(aa){ae.animate({left:Math.round(ac)},af);}else{ae.css("left",Math.round(ac));}ae.data("pos",ac);});return true;}y=function(ac,aa){if(!ac.jquery&&!ac.hasClass(".thumb")){return false;
}var ab=O()-X(ac)-u;return L(ab,aa);};I=function(aa,ab){if(typeof aa!=="number"||aa===0){return false;}aa=Math.round(aa);var ac=aa*u;return L(ac,ab);};if(B&&B.length>0){var c=function(){b(this).blur();return false;};b("#featuredContent .featuredItem:last").prepend(b("<div/>").addClass("fcNav fcHoverOnly").append(b("<a/>").attr({href:"#",title:"Click to view the previous Featured Image"}).text("Previous").bind("click",function(){b(this).blur().unbind().bind("click",c);r(true);return false;})),b("<div/>").addClass("fcNav fcNavRight fcHoverOnly").append(b("<a/>").attr({href:"#",title:"Click to view the next Featured Image"}).text("Next").bind("click",function(){b(this).blur().unbind().bind("click",c);h(true);return false;})));}o=true;var P=null,W=false;function K(){if(W&&!f.disabled){h();}g=setTimeout(K,f.holdTime);}x=function(){if(f.disabled||W){return;}W=true;if(P!==null){clearTimeout(P);P=null;}g=setTimeout(K,f.holdTime);};t=function(ab){ab=typeof ab==="boolean"?ab:false;if(!W&&!ab){return;
}W=false;clearTimeout(g);g=null;var aa=f.restartAfterClickDelay;if(ab&&f.stopAfterClick&&(aa===true||(typeof aa==="number"&&aa>0))){if(P!==null){clearTimeout(P);P=null;}aa=typeof aa==="number"?Math.round(aa):G.restartAfterClickDelay;P=setTimeout(function(){x();},aa);}};var Y=false;Q.bind("mouseover.stopScroll",function(){if(!f.disabled&&f.stopOnHover){Y=true;t();}}).bind("mouseout.startScroll",function(){if(!f.disabled&&Y){Y=false;x();}});if(!f.disabled&&f.autoStart){x();}}function E(L){if(!L||!L.lightboxContents||L.lightboxContents.length<4){return false;}b("#featuredContent").data("data",L);p=L.useStaticImagery;B=L.lightboxContents.damResults||[];var M=b("#featuredThumbnails"),u=B.length,N=M.find(".container:first").width((k.home.width+1)*u);b.each(B,function(R,Q){if(R===u){return false;}if(R===0&&b(".featuredItem.ajax").length>0){e=-1;H(R,false);}function S(T){if(!p&&(T.ctrlKey||T.metaKey)&&T.shiftKey){var U=window.open();U.location.href=J.cmsHandle.findImagery+".html#guid="+Q.guid;return false;
}if(f.stopAfterClick){t(true);}if(H(R,false)&&B.length>3){y(b(this));}s.executeContentsChangedAlert();}if(b(".fct_"+R).length===0){var P={guid:p?null:Q.guid,filename:p?Q.fileName:null,type:J.imgTypes.thumbnail,height:k.home.height,width:k.home.width,fill:true,trim:true};var O=s.getImageUrl(P);N.append(b("<div/>").addClass("thumb fct_"+R).attr({title:"Click to view this image ("+Q.captionTruncated+")"}).css({backgroundImage:"url("+O+")"}).bind("click.switchImage",S));}else{b(".fct_"+R).bind("click.switchImage",S);}});n();if(o&&!J.request.isLowBandwidth){var c=q(1);if(c){var K=b("<img/>").attr("src",c);}}}function F(){D=true;var u=b("<img/>").attr("src","/docroot/images/action_buttons.gif"),M=b("<img/>").attr("src","/docroot/images/arrows_slide.gif"),Q=b("<img/>").attr("src","/docroot/images/ani_wait_gray.gif");if(!J.request.isLowBandwidth){var N=b("<img/>").attr("src","/docroot/images/ani_wait_icon.gif");}var R=b("#featuredContent"),P=false,K=R.find(".featuredItem").length>0,c={top:R.offset().top,left:R.offset().left,bottom:R.offset().top+R.height(),right:R.offset().left+R.width()};
if(K){var O=b("#hdn_fcFirstGuid").remove().val();if(typeof O==="string"){R.find(".featuredItem:last .fmContent").prepend(a.pages.common.$getAbToolbar(O));}else{R.find(".featuredItem.static:last .fmContent").prepend(a.pages.common.$getAbToolbar(null,["stillStatic"]));}}else{R.append(b("<div/>").addClass("featuredItem ajax").append(b("<div/>").addClass("largeLoading").append(b("<span/>").text("Loading..."))));var T=b("#featuredThumbnails .container");if(T.length<=0){b("#featuredThumbnails").append(b("<div/>").addClass("container"));}}function S(U,W){var V=w?b("#featuredThumbnails").outerHeight():0;return U>=c.left&&U<=c.right&&W>=c.top&&W<=c.bottom-V;}b("body").bind("mousemove",function(V){var U=V.pageX,W=V.pageY;if(S(U,W)){if(o&&f.stopOnHover){P=true;t();}b.data(R,"hoverShowing",true);R.find(".fcHoverOnly").fadeIn("fast");}else{if(o&&P){P=false;if(!C){x();}}b.data(R,"hoverShowing",false);R.find(".fcHoverOnly").fadeOut("fast");}});R.bind("click.showHovers",function(){if(!b.data(R,"hoverShowing")){b.data(R,"hoverShowing",true);
R.find(".fcHoverOnly").removeClass("fcHoverOnly");}});var L={callback:E};if(a.pages.featuredContent.forceStatic===true){L.forceStatic=true;}if(a.pages.featuredContent.randomize===true){L.randomize=true;}a.ajax.featuredContent.getFeaturedContent(L);}j=function(){if(!D){return false;}t();window.clearTimeout(m);m=null;b("#featuredContent .featuredItem").remove();b("#featuredThumbnails").empty();F();};function z(K){if(!D){return false;}K=typeof K==="boolean"?K:!w;if(K){f.disabled=true;t();}w=K?true:false;var u=b("#featuredContent"),N=u.height(),P=N-b("#featuredThumbnails").outerHeight(),M=[{$elt:b(".featuredItem"),dims:[N,P],prop:"height",speed:500},{$elt:b(".featuredItem .fcNav a"),dims:[120,70],prop:"top",speed:500},{$elt:b("#featuredThumbnails"),dims:[b("#quickSearch").width(),b("#primarySections").width()],prop:"width",speed:1000}];for(var c=0;c<M.length;c++){var O=M[c],L={};L[O.prop]=O.dims[K?1:0];O.$elt.animate(L,O.speed);}if(!K){f.disabled=false;x();}}function d(c){if(!c||!c.lightboxContents){return false;
}var u=b("#relatedThumbnails").data("data",c);p=c.useStaticImagery;var K=b("<div/>");b.each(c.lightboxContents.damResults,function(Q,P){var O={guid:p?null:P.guid,filename:p?P.fileName:null,type:J.imgTypes.thumbnail,height:k.landing.height};if(A.squareLandingThumbs){O.width=k.landing.height;O.fill=true;O.trim=true;}var L=s.getImageUrl(O);var N=b("<img/>").addClass("thumb").bind("load.thumbLoaded",function(){b(this).fadeIn();}).attr({id:"tn_"+Q,alt:"Thumbnail with VIRIN: "+P.virin,title:"Image with VIRIN: "+P.virin+(!p?" (Click to view the details for this still image)":""),longdesc:P.captionTruncated,src:L}).hide();var M=J.cmsHandle.findImagery+".html#guid="+P.guid;K.append(p?N:b("<a/>").attr("href",M).append(N));});u.empty().append(K.children());}function i(){b(document).ajaxError(function(L,K,u){b("#relatedThumbnails").empty().hide();});b("#relatedThumbnails").empty().append(b("<div>").addClass("largeLoading").html("<span>Loading...</span>"));var c={callback:d};if(a.pages.featuredContent.forceStatic===true){c.forceStatic=true;
}a.ajax.featuredContent.getLandingThumbs(c);}return{initFull:function(){F();},initLanding:function(){i();},prev:function(){if(!D){return false;}return r();},next:function(){if(!D){return false;}return h();},showItem:function(c){if(!D){return false;}return y(c);},shiftSpaces:function(c){if(!D){return false;}return I(c);},setScrollParams:function(c){if(!D){return;}c=c||G;f=b.extend({},f,c);},startScroll:function(){if(!D){return;}f.disabled=false;x();},stopScroll:function(){if(!D){return;}f.disabled=true;t();},reload:function(){j();},changeThumbMode:function(c){z(c);}};}();})(window.jQuery);