function yox_flickr(){function m(a,j){return"http://farm"+a.farm+".static.flickr.com/"+a.server+"/"+(a.primary||a.id)+"_"+a.secret+j+".jpg"}var g=jQuery,o="http://www.flickr.com/",p="http://api.flickr.com/services/rest/",r=/\d+@N\d+/,s=/http:\/\/(?:www\.)?flickr\.com\/(\w+)\/(?:([^\/]+)\/(?:(\w+)\/?(?:([^\/]+)\/?)?)?)?(?:\?(.*))?/,t=this,q={api_key:"cd6c91f9721f34ead20e6ebe03dd5871",format:"json"};this.getImagesData=function(a,j){function k(){var b={};a.onLoadBegin&&a.onLoadBegin();g.jsonp({url:p,
async:false,dataType:"jsonp",data:e,callbackParameter:"jsoncallback",success:function(h){b.images=t.getImagesDataFromJson(h,e);if(h.photosets||h.collections)g.extend(b,{createGroups:true});if(b.images.length>0&&(e.setThumbnail&&!e.setSinglePhotosetThumbnails||a.isSingleLink))g.extend(b,{isGroup:true,link:(o+"photos/"+h.photoset.owner+"/sets/"+h.photoset.id+"/").replace(/\s/g,"_"),thumbnailSrc:a.isSingleLink?undefined:m(h.photoset.photo[0],n[e.thumbsize]),title:"None"});j&&j(b);a.onLoadComplete&&a.onLoadComplete()},
error:function(){a.onLoadError&&a.onLoadError("Flickr plugin encountered an error while retrieving data")}})}var i=true,l={method:"flickr.urls.lookupUser",onData:function(b){return{user_id:b.user.id,username:b.user.username._content}}},c={};if(a.dataUrl){var d=a.dataUrl.match(s),f;if(d[5]){f=Yox.queryToJson(d[5]);g.extend(c,f)}if(d&&d.length>1)if(d[1]=="search"){c.method="flickr.photos.search";c.text=f.q;if(f.w){f.w=f.w.replace("%40","@");if(f.w.match(r))c.user_id=f.w}if(!f||!f.sort)c.sort="relevance";
i=false}else{switch(d[3]){case undefined:c.method="flickr.people.getPublicPhotos";break;case "sets":g.extend(c,{method:d[4]||a.dataSourceOptions.photoset_id?"flickr.photosets.getPhotos":"flickr.photosets.getList",photoset_id:d[4]});break;case "galleries":g.extend(c,{method:d[4]?"flickr.galleries.getPhotos":"flickr.galleries.getList",gallery_id:d[4]});if(d[4]){i=true;l={method:"flickr.urls.lookupGallery",onData:function(b){return{gallery_id:b.gallery.id,title:b.gallery.title}}}}break;case "collections":g.extend(c,
{method:"flickr.collections.getTree",collection_id:d[4]});break;default:c.method="flickr.photos.search";break}g.extend(c,{username:d[2],type:d[3]})}}var e=jQuery.extend({},{imageSize:"medium",thumbsize:"smallSquare",setThumbnail:true,setSinglePhotosetThumbnails:true,setTitle:true,method:"flickr.photosets.getList",extras:"description"},c,a.dataSourceOptions,q);e.media="photos";if(e.user&&e.photoset_id)e.method="flickr.photosets.getPhotos";c=screen.width>screen.height?screen.width:screen.height;if(!e.imageSize||
c.width<=800&&e.imageSize!="medium")e.imageSize="medium";i?g.jsonp({url:p,async:false,dataType:"jsonp",data:g.extend({url:a.dataUrl,method:l.method},q),callbackParameter:"jsoncallback",success:function(b){g.extend(e,l.onData(b));k()}}):k()};var n={smallSquare:"_s",thumbnail:"_t",small:"_m",medium:"",large:"_b",original:"_o"};this.getImagesDataFromJson=function(a,j){var k=a.photoset||a.photos,i;if(k)i=a.photoset?a.photoset.photo:a.photos.photo;else if(a.photosets)i=a.photosets.photoset;else if(a.collections)i=
a.collections.collection[0].set;var l=[],c=a.photoset?"/in/set-"+a.photoset.id:"";if(i){var d=n[j.thumbsize],f=n[j.imageSize];jQuery.each(i,function(e,b){var h={thumbnailSrc:m(b,d),link:(o+"photos/"+(b.owner||j.user_id)+"/"+b.id+c).replace(/\s/g,"_"),media:{src:m(b,f),title:k?b.title:b.title._content+(!k?" ("+b.photos+" images)":""),alt:b.title._content||b.title,description:b.description?b.description._content:undefined}};if(!k)h.data={photoset_id:b.id};l.push(h)})}return l}};
