(function(){var a,b=Object.prototype.hasOwnProperty;a=function(c,d){var e,f,g;if(!this instanceof a)return new a(c,d);g=this,g.addEvent=function(a,b,c){if((a!=null?a.addEventListener:void 0)!=null)return a!=null?a.addEventListener(b,c,!1):void 0;if((a!=null?a.attachEvent:void 0)!=null)return a["e"+b+c]=c,a[b+c]=function(){return a["e"+b+c](window.event)},a!=null?a.attachEvent("on"+b,a[b+c]):void 0},g.addUrl=function(){var a,c,d,e;c={api_key:"6cb7449543a9595800bc0c365223a4e8",extras:"url_s,url_m,url_z,url_l",format:"json",jsoncallback:"flickrshow_jsonp_"+g.constants.random,page:g.settings.page,per_page:g.settings.per_page},g.settings.licence!=null&&(c.license=g.settings.licence),g.settings.license!=null&&(c.license=g.settings.license),g.settings.gallery!=null?(c.method="flickr.galleries.getPhotos",c.gallery_id=g.settings.gallery):g.settings.group!=null?(c.method="flickr.groups.pools.getPhotos",c.group_id=g.settings.group):g.settings.set!=null?(c.method="flickr.photosets.getPhotos",c.photoset_id=g.settings.set):g.settings.person!=null?(c.method="flickr.people.getPhotosOf",c.user_id=g.settings.person):g.settings.tags!=null||g.settings.user!=null?(c.method="flickr.photos.search",g.settings.tags!=null&&(c.tags=g.settings.tags),g.settings.user!=null&&(c.user_id=g.settings.user)):c.method="flickr.photos.getRecent",d="http://api.flickr.com/services/rest/?";for(a in c){if(!b.call(c,a))continue;e=c[a],d+=a+"="+e+"&"}return d},g.animate=function(a,b,c,d,e){var f;g.constants.intervals[e]!=null&&window.clearInterval(g.constants.intervals[e]),f=function(){var d,f;return d=Math.round(a.style[b].replace(/([a-zA-Z]{2})$/,"")),f=Math.round(c-d),Math.abs(f)>1?a.style[b]=Math.floor(d+f/2)+"px":(a.style[b]=c+"px",window.clearInterval(g.constants.intervals[e]))},g.constants.intervals[e]=window.setInterval(f,d/1.5)},g.onClickLeft=function(){if(g.constants.isLoading===!0)return;g.constants.imageCurrent=g.constants.imageCurrent-1<0?g.constants.imageTotal-1:g.constants.imageCurrent-1,g.animate(g.elements.images,"left","-"+g.constants.imageCurrent*g.elements.target.offsetWidth,g.constants.speed,"i"),g.showTitle(),typeof g.settings.onMove=="function"&&g.settings.onMove(g.elements.images.childNodes[g.constants.imageCurrent].childNodes[0])},g.onClickPlay=function(){var a;g.constants.isPlaying===!1?(g.constants.isPlaying=!0,g.elements.buttons.childNodes[2].style.backgroundImage="url("+g.constants.base_url+"static/images/is.png)",a=function(){return g.onClickRight()},g.constants.intervals.playing=window.setInterval(a,g.settings.interval),typeof g.settings.onPlay=="function"&&g.settings.onPlay()):(g.constants.isPlaying=!1,g.elements.buttons.childNodes[2].style.backgroundImage="url("+g.constants.base_url+"static/images/ip.png)",window.clearInterval(g.constants.intervals.playing),typeof g.settings.onPause=="function"&&g.settings.onPause(g.elements.images.childNodes[g.constants.imageCurrent].childNodes[0]))},g.onClickRight=function(){if(g.constants.isLoading===!0)return;g.constants.imageCurrent=g.constants.imageCurrent+2>g.constants.imageTotal?0:g.constants.imageCurrent+1,g.animate(g.elements.images,"left","-"+g.constants.imageCurrent*g.elements.target.offsetWidth,g.constants.speed,"i"),g.showTitle(),typeof g.settings.onMove=="function"&&g.settings.onMove(g.elements.images.childNodes[g.constants.imageCurrent].childNodes[0])},g.onLoadImage=function(a){var b,c,d,e,f,h;d=a.srcElement||a.target,b=d.offsetHeight,c=d.offsetWidth,c>b?(f=Math.ceil(g.elements.target.offsetWidth+g.elements.target.offsetHeight/100),e=Math.ceil(f/c*b)):(e=Math.ceil(g.elements.target.offsetHeight+g.elements.target.offsetHeight/100),f=Math.ceil(e/b*c)),d.style.height=e+"px",d.style.left=Math.round((g.elements.target.offsetWidth-f)/2)+"px",d.style.position="absolute",d.style.top=Math.round((g.elements.target.offsetHeight-e)/2)+"px",d.style.width=f+"px",g.constants.imageLoaded=g.constants.imageLoaded+1,h=Math.round(g.constants.imageLoaded/g.constants.imageTotal*240),g.animate(g.elements.loading.childNodes[0],"width",h<=36?36:h,"loading"),g.constants.imageLoaded===g.constants.imageTotal&&(g.showTitle(),g.elements.container.removeChild(g.elements.loading),g.elements.images.style.visibility="visible",g.constants.isLoading=!1,g.settings.autoplay===!0&&g.onClickPlay(),typeof g.settings.onLoad=="function"&&g.settings.onLoad())},g.onLoadJson=function(a){var b,c,d,e,f,h,i,j,k,l,m,n;g.elements.script.parentNode.removeChild(g.elements.script);if(a.photoset!=null){m=a.photoset.photo;for(f=0,k=m.length;f<k;f++)j=m[f],j.owner=a.photoset.owner;a.photos=a.photoset}if(a.stat!=null&&a.stat==="fail"||!a.photos)throw"Flickrshow: "+(a.message||"There was an unknown error with the data returned by Flickr");g.constants.imageTotal=a.photos.photo.length,n=a.photos.photo;for(f=0,l=n.length;f<l;f++)j=n[f],h=document.createElement("img"),h.setAttribute("data-flickr-title",j.title),h.setAttribute("data-flickr-photo_id",j.id),h.setAttribute("data-flickr-owner",j.owner),h.setAttribute("rel",f),h.style.cursor="pointer",h.style.display="block",h.style.margin="0",h.style.padding="0",d=g.elements.target.offsetHeight*g.elements.target.offsetWidth,e=j.height_z*j.width_z,b=j.height_m*j.width_m,c=j.height_s*j.width_s,j.url_m||(j.url_m=j.url_s),j.url_z||(j.url_z=j.url_m),j.url_l||(j.url_l=j.url_z),d>e?h.src=j.url_l+"?"+g.constants.random:d>b?h.src=j.url_z+"?"+g.constants.random:d>c?h.src=j.url_m+"?"+g.constants.random:h.src=j.url_s+"?"+g.constants.random,i=document.createElement("li"),i.style.left=f*g.elements.target.offsetWidth+"px",i.style.height=g.elements.target.offsetHeight+"px",i.style.margin="0",i.style.overflow="hidden",i.style.padding="0",i.style.position="absolute",i.style.top="0",i.style.width=g.elements.target.offsetWidth+"px",i.appendChild(h),g.elements.images.appendChild(i),g.addEvent(h,"load",g.onLoadImage)},g.onLoadWindow=function(a){g.elements.target=typeof g.elements.target=="string"?document.getElementById(g.elements.target):g.elements.target,g.elements.target.innerHTML='<div class="flickrshow-container" style="background:transparent;height:'+g.elements.target.offsetHeight+"px;margin:0;overflow:hidden;padding:0;position:relative;width:"+g.elements.target.offsetWidth+'px"><div class="flickrshow-loading" style="background:transparent url('+g.constants.base_url+'static/images/bg.png);border-radius:12px;height:24px;left:50%;margin:-12px 0 0 -120px;overflow:hidden;padding:0;position:absolute;top:50%;width:240px;-moz-border-radius:12px;-webkit-border-radius:12px"><div class="flickrshow-loading-bar" style="background:#000;border-radius:12px;height:24px;left:0;margin:0;padding:0;position:absolute;top:0;width:0;-moz-border-radius:12px;-webkit-border-radius:12px"></div></div><ul class="flickrshow-images" style="background:transparent;height:'+g.elements.target.offsetHeight+"px;left:0;list-style:none;margin:0;padding:0;position:absolute;top:0;visibility:hidden;width:"+g.elements.target.offsetWidth+'px"></ul><div class="flickrshow-buttons" style="background:transparent url('+g.constants.base_url+"static/images/bg.png);height:40px;margin:0;padding:0;position:absolute;top:"+g.elements.target.offsetHeight+"px;width:"+g.elements.target.offsetWidth+'px"><div class="flickrshow-buttons-left" style="background:#000 url('+g.constants.base_url+'static/images/il.png) 50% 50% no-repeat;border-radius:12px;cursor:pointer;height:24px;left:auto;margin:0;padding:0;position:absolute;right:40px;top:8px;width:24px;-moz-border-radius:12px;-webkit-border-radius:12px"></div><div class="flickrshow-buttons-right" style="background:#000 url('+g.constants.base_url+'static/images/ir.png) 50% 50% no-repeat;border-radius:12px;cursor:pointer;height:24px;left:auto;margin:0;padding:0;position:absolute;right:8px;top:8px;width:24px;-moz-border-radius:12px;-webkit-border-radius:12px"></div><div class="flickrshow-buttons-play" style="background:#000 url('+g.constants.base_url+'static/images/ip.png) 50% 50% no-repeat;border-radius:12px;cursor:pointer;height:24px;left:8px;margin:0;padding:0;position:absolute;right:auto;top:8px;width:24px;-moz-border-radius:12px;-webkit-border-radius:12px;"></div><p class="flickrshow-buttons-title" style="background:#000;border-radius:12px;color:#FFF;cursor:pointer;font:normal normal 600 11px/24px helvetica,arial,sans-serif;height:24px;left:40px;margin:0;overflow:hidden;padding:0;position:absolute;right:auto;text-align:center;text-shadow:none;text-transform:capitalize;top:8px;width:'+(g.elements.target.offsetWidth-112)+'px;-moz-border-radius:12px;-webkit-border-radius:12px">&nbsp</p></div></div>',g.elements.container=g.elements.target.childNodes[0],g.elements.buttons=g.elements.target.childNodes[0].childNodes[2],g.elements.images=g.elements.target.childNodes[0].childNodes[1],g.elements.loading=g.elements.target.childNodes[0].childNodes[0],!1===g.settings.hide_buttons&&(g.addEvent(g.elements.images,"click",g.toggleButtons),g.addEvent(g.elements.container,"mouseover",g.showButtons),g.addEvent(g.elements.container,"mouseout",g.hideButtons),g.addEvent(g.elements.buttons.childNodes[0],"click",g.onClickLeft),g.addEvent(g.elements.buttons.childNodes[1],"click",g.onClickRight),g.addEvent(g.elements.buttons.childNodes[2],"click",g.onClickPlay),g.addEvent(g.elements.buttons.childNodes[3],"click",g.showFlickr)),window["flickrshow_jsonp_"+g.constants.random]=g.onLoadJson,g.elements.script=document.createElement("script"),g.elements.script.async=!0,g.elements.script.src=g.addUrl("flickrshow_jsonp_"+g.constants.random),(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(g.elements.script)},g.hideButtons=function(){if(g.constants.isLoading===!0||g.constants.isButtonsOpen===!1)return;g.constants.isButtonsOpen=!1,g.animate(g.elements.buttons,"top",g.elements.target.offsetHeight,g.constants.speed,"buttons")},g.showButtons=function(){if(g.constants.isLoading===!0||g.constants.isButtonsOpen===!0)return;g.constants.isButtonsOpen=!0,g.animate(g.elements.buttons,"top",g.elements.target.offsetHeight-40,g.constants.speed,"buttons")},g.toggleButtons=function(){g.constants.isButtonsOpen===!0?g.hideButtons():g.showButtons()},g.showFlickr=function(){var a;a=g.elements.images.childNodes[g.constants.imageCurrent].childNodes[0];if(a==null)return;window.location="http://www.flickr.com/photos/"+a.getAttribute("data-flickr-owner")+"/"+a.getAttribute("data-flickr-photo_id")+"/"},g.showTitle=function(){var a;a=g.elements.images.childNodes[g.constants.imageCurrent].childNodes[0];if(a==null)return;g.elements.buttons.childNodes[3].innerHTML=g.constants.imageCurrent+1+"/"+g.constants.imageTotal+" - "+a.getAttribute("data-flickr-title")},g.constants={base_url:"http://www.flickrshow.co.uk/",intervals:[],imageCurrent:0,imageLoaded:0,imageTotal:0,isButtonsOpen:!1,isLoading:!0,isPlaying:!1,random:Math.floor(Math.random()*999999999999),speed:100},g.elements={buttons:null,button1:null,button2:null,button3:null,button4:null,container:null,images:null,loading:null,script:null,target:null},g.settings={autoplay:!1,gallery:null,group:null,hide_buttons:!1,interval:3e3,license:"1,2,3,4,5,6,7",onLoad:null,onMove:null,onPlay:null,onPause:null,page:"1",person:null,per_page:"50",set:null,tags:null,user:null},g.elements.target=c;for(e in d){if(!b.call(d,e))continue;f=d[e],g.settings[e]=f}return d.flickr_group!=null&&(g.settings.group=d.flickr_group),d.flickr_photoset!=null&&(g.settings.set=d.flickr_photoset),d.flickr_tags!=null&&(g.settings.tags=d.flickr_tags),d.flickr_user!=null&&(g.settings.user=d.flickr_user),g.addEvent(window,"load",g.onLoadWindow),{constants:g.constants,elements:g.elements,settings:g.settings,left:g.onClickLeft,right:g.onClickRight,play:g.onClickPlay}},window.jQuery!=null&&(window.jQuery.fn.flickrshow=function(b){return new a(window.jQuery(this)[0],b)})}).call(this)
