window.clik||(clik={});
clik.rotator={init:function(e){if($.browser.msie&&$.browser.version<7&&"isStyle2"in clik&&clik.isStyle2){e.initialTimeout=0;e.timeout=0}var c={element:"",image_sets_id:1,photoArray:[],initialTimeout:5E3,timeout:5E3,opacity:0.8,showPanels:false,showControls:false,autoHidePanels:true,speed:1E3,link:false,extraTitle:"",extraDetails:"",relatedContentSections:"",updateDocumentTitle:false,updateHash:false,keyControls:false,randomise:true,stopOnHover:true},a=$.extend({},c,e),b,d,f,g=$(a.element),h,i,j=g.parent(),
n=j.closest(".contentsection"),p=false,m=function(){window.clearTimeout(d);j.find(".overlay").stop(true,true).not(".empty").slideDown(500)},s=function(q,k){k=typeof k!="undefined"?k:500;window.clearTimeout(d);d=setTimeout(function(){j.find(".overlay").stop(true,true).slideUp(k,function(){$(this).hide()})},k)},t=function(){window.clearTimeout(f);j.find(".controls").stop(true,true).fadeIn(500)},r=function(q,k){k=typeof k!="undefined"?k:500;window.clearTimeout(f);f=setTimeout(function(){j.find(".controls").stop(true,
true).fadeOut(k);$(document).unbind(".imageSlideshowControls")},k)},l=function(){},o=function(q,k){i=typeof h[0]=="string"?""+i:parseInt(i,10);var y=getNextId(i,h,k||q.data&&q.data.previous);p=true;u(q,y)},u=function(q,k){var y=a.link=="gallery"?getHomeImageLink(k):a.link;if(k&&k!=-1){k=""+k;if(!(a.photoArray&&k in a.photoArray||k in(a.photoArray=backgrounds))){$.ajax({url:"gallery_"+thumbnails[k].galleries_id+".js",dataType:"script",type:"get",complete:$.proxy(function(){a.photoArray=window[e.photoArray||
c.photoArray];u.call(this,q,k)},this)});return false}g=updateImage({nextPhoto:a.photoArray[k],img:g.find("img")[0],$photo:g,$title:j.find(".imageTitleContainer").add(a.extraTitle),$detail:j.find(".imageDetailsContainer").add(a.extraDetails),$detailContainer:$(a.relatedContentSections),updateDocumentTitle:a.updateDocumentTitle,updateHash:a.updateHash,speed:a.speed,href:y,onBefore:function(){var x=$(this),w=function(F,E){var A=$(this),B=A.children(),C=B.outerHeight(true);return A.height("").height()!=
C?E:x.height()+C-B.height()},D=x.find("a").css("display","inline-block").closest(".contentsection").height(w);$("body").trigger("doPhotoViewColumns").trigger("pageContentChange",[{type:"photos",id:k}]);D.doManualAlign({inner:x.find("img"),crop:x.find("a"),padding:n.children(".contentpadding")}).height(w);D.clikIEContainerWidth(".photo>a")},onAfter:function(){$(a.relatedContentSections).find(".gallery").trigger("clikCarouselUpdate",[k]);n.trigger("clikCarouselUpdate",[k]);l()}}).parent()}i=k;z()},
v=function(q,k,y,x){var w;q.data("raphHeight",q.height()).height("");k.height=Math.min(k.maxheight||Infinity,k.height||q.height()-1);k.width=Math.min(k.maxwidth||Infinity,k.width||q.width()-1);q.height(q.data("raphHeight"));w={left:(q.width()-k.width+k.stroke.width*2)/2,top:(q.height()-k.height+k.stroke.width*2)/2};Raphael(q[0],(k.width||q.width())+w.left+1,(k.height||q.height())+w.top+1).clik.arrow($.extend(k,{reflect:y,offset:w,rolloverTime:x}))},z=function(){window.clearTimeout(b);if(a.timeout>
0)b=setTimeout(function(){n.trigger("goNext")},a.timeout)};if(g.length){if(typeof a.photoArray=="string")a.photoArray=window[a.photoArray];if(!("keyControl"in e)&&a.showControls)a.keyControl=true;switch(a.image_sets_id){case "gallery":if((i=(document.location.hash.match(".*photos_id=(.+)$")||["",""])[1])&&i in thumbnails||(i=clik.getPrefixedClass(g.attr("id"),"imagePhoto_"))&&i in thumbnails||(i=clik.getPrefixedClass($("body").attr("class"),"content_"))&&i in thumbnails)h=galleries[thumbnails[i].galleries_id].photoIDs;
else if((h=clik.getPrefixedClass($("body").attr("class"),"content_"))&&h in galleries){h=galleries[h].photoIDs;i=h[0]}else{h=[];i=""}break;case "galleryindex":h=[];$.each(galleries,function(){h.push(randomListVal(this.featured_images))});i=h[0];break;default:h=imageSets[a.image_sets_id]||"";i=a.randomise?randomListVal(h):h.split(",")[0];h=h.split(",")}i=parseInt(i,10);if(!a.extraTitle&&a.relatedContentSections)a.extraTitle=$(a.relatedContentSections).find(".replaceable_photo-photo_caption");n.addClass("slideshow");
if(a.initialTimeout>0)b=setTimeout(function(){n.trigger("goNext");j.trigger("mouseleave.clikSlideTimeout")},a.initialTimeout);if(a.showPanels){j.append('<div class="imageTitleContainer overlay"><div class="imageTitle"></div></div>').append('<div class="imageDetailsContainer overlay"><div class="imageDetails"></div></div>');j.find(".overlay").alphaBackground(a.opacity).width(j.closest(".contentpadding").width()||j.width());a.autoHidePanels?j.hoverNS(m,s,"clikSlidePanels"):m()}else s({},0);if(a.showControls){j.append('<div class="imagePrevious controls"></div><div class="imageNext controls"></div>');
l=function(){v(j.find(".imageNext").height("").height(function(q,k){return k}).empty(),a.nextsvg,false,500);v(j.find(".imagePrevious").height("").height(function(q,k){return k}).empty(),a.previoussvg,true,500)};j.find(".imageNext").bind("click",o);j.find(".imagePrevious").bind("click",{previous:true},o);a.autoHidePanels?j.hoverNS(t,r,"clikSlideControls"):t()}else r({},0);if(a.keyControl)$(document).unbind(".imageSlideshowControls"+(!a.showControls?"On":"")).bind("keydown.imageSlideshowControls"+(!a.showControls?
"On":""),function(q){var k={left:37,right:39};if(q.target.form)return true;switch(q.keyCode||q.which){case k.left:n.trigger("goPrevious");break;case k.right:n.trigger("goNext");break;default:return true}return false});if($.browser.msie&&$.browser.version<7){n.filter(function(){return $(this).css("position")!="absolute"}).width(n.parent().width());j.width(n.width()).children(":not(.controls)").width(j.width())}a.updateHash&&$(window).bind("hashchange",function(){var q=i;if(!p&&(i=((document.location.hash||
document.location.href).match(".*(?:photos_id=|photo_)(.+)(?:.html)?$")||["",""])[1])&&i in thumbnails)n.trigger("goTo",[i]);else{i=q;p=false}});n.unbind().bind("goNext",o).bind("goPrevious",{previous:true},o).bind("goTo",u).trigger("goTo",[i]);a.stopOnHover&&j.hoverNS(function(){window.clearTimeout(b)},z,"clikSlideTimeout")}}};
