albums={load:function(){loadingBar.show();lychee.animate(".album, .photo","contentZoomOut");lychee.content.attr("data-search","");lychee.animate(".divider","fadeOut");startTime=(new Date).getTime();lychee.api("getAlbums","json",function(e){durationTime=(new Date).getTime()-startTime;if(durationTime>300)waitTime=0;else waitTime=300-durationTime;$.timer(waitTime,function(){$("#tools_album, #tools_photo").hide();$("#tools_albums").show();unsortedAlbum=new Object;unsortedAlbum.id=0;unsortedAlbum.title="Unsorted";unsortedAlbum.sysdate=e.unsortNum+" photos";unsortedAlbum.unsorted=1;if(e.unsortThumb0)unsortedAlbum.thumb0=lychee.upload_path+e.unsortThumb0;else unsortedAlbum.thumb0="";if(e.unsortThumb1)unsortedAlbum.thumb1=lychee.upload_path+e.unsortThumb1;else unsortedAlbum.thumb1="";if(e.unsortThumb2)unsortedAlbum.thumb2=lychee.upload_path+e.unsortThumb2;else unsortedAlbum.thumb2="";starredAlbum=new Object;starredAlbum.id="f";starredAlbum.title="Starred";starredAlbum.sysdate=e.starredNum+" photos";starredAlbum.star=1;if(e.starredThumb0)starredAlbum.thumb0=lychee.upload_path+e.starredThumb0;else starredAlbum.thumb0="";if(e.starredThumb1)starredAlbum.thumb1=lychee.upload_path+e.starredThumb1;else starredAlbum.thumb1="";if(e.starredThumb2)starredAlbum.thumb2=lychee.upload_path+e.starredThumb2;else starredAlbum.thumb2="";publicAlbum=new Object;publicAlbum.id="s";publicAlbum.title="Public";publicAlbum.sysdate=e.publicNum+" photos";publicAlbum.public=1;if(e.publicThumb0)publicAlbum.thumb0=lychee.upload_path+e.publicThumb0;else publicAlbum.thumb0="";if(e.publicThumb1)publicAlbum.thumb1=lychee.upload_path+e.publicThumb1;else publicAlbum.thumb1="";if(e.publicThumb2)publicAlbum.thumb2=lychee.upload_path+e.publicThumb2;else publicAlbum.thumb2="";smartData=build.divider("Smart Albums")+build.album(unsortedAlbum)+build.album(starredAlbum)+build.album(publicAlbum);if(e.albums){albumsData=build.divider("Albums");$.each(e.album,function(){albumsData+=build.album(this)})}else albumsData="";lychee.content.html(smartData+albumsData);lychee.animate(".album, .photo","contentZoomIn");document.title="Lychee";lychee.headerTitle.html("Albums").removeClass("editable");$("img").retina();loadingBar.hide()})})},loadInfo:function(e){if(e=="f"||e=="s"||e==0){lychee.headerTitle.removeClass("editable");lychee.api("getSmartInfo","json",function(t){switch(e){case"f":document.title="Lychee - Starred";lychee.headerTitle.html("Starred - "+t.starredNum+" photos");$("#button_edit_album, #button_trash_album, .button_divider").hide();break;case"s":document.title="Lychee - Public";lychee.headerTitle.html("Public - "+t.publicNum+" photos");$("#button_edit_album, #button_trash_album, .button_divider").hide();break;case"0":document.title="Lychee - Unsorted";lychee.headerTitle.html("Unsorted - "+t.unsortNum+" photos");$("#button_edit_album").hide();$("#button_trash_album, .button_divider").show();break}loadingBar.hide()})}else{params="getAlbumInfo&albumID="+e;lychee.api(params,"json",function(e){$("#button_edit_album, #button_trash_album, .button_divider").show();if(!e.title)e.title="Untitled";document.title="Lychee - "+e.title;lychee.headerTitle.html(e.title+" - "+e.num+" photos").addClass("editable");loadingBar.hide()})}},add:function(){title=prompt("Please enter a title for this album:","Untitled");lychee.closeModal();if(title.length>2&&title.length<31){loadingBar.show();params="addAlbum&title="+escape(title);lychee.api(params,"text",function(e){if(e)lychee.goto("a"+e);else loadingBar.show("error")})}else if(title.length>0)loadingBar.show("error","Error","Title to short or too long. Please try another one!")},hide:function(e){$(".album[data-id='"+e+"']").css("opacity",0).animate({width:0,marginLeft:0},300,function(){$(this).remove()})},"delete":function(e,t){loadingBar.show();params="deleteAlbum&albumID="+e+"&delAll="+t;lychee.api(params,"text",function(t){if(t){if(visible.albums()){albums.hide(e);loadingBar.hide()}else lychee.goto("")}else loadingBar.show("error")})},deleteDialog:function(e){if(e==0){f1="albums.delete(0, true);";f2="";modal=build.modal("Clear Unsorted","Are you sure you want to delete all photos from 'Unsorted'?
This action can't be undone!",["Clear Unsorted","Keep Photos"],[f1,f2]);$("body").append(modal)}else{if(visible.albums())albumTitle=$(".album[data-id='"+e+"'] .overlay h1").html();else albumTitle=lychee.title();f1="albums.delete("+e+", true);";f2="albums.delete("+e+", false);";modal=build.modal("Delete Album","Are you sure you want to delete the album '"+albumTitle+"' and all of the photos it contains? This action can't be undone!",["Delete Album and Photos","Keep Photos"],[f1,f2]);$("body").append(modal)}},rename:function(e){if(!e)oldTitle=lychee.title();else oldTitle="";if(!e)e=lychee.content.attr("data-id");newTitle=prompt("Please enter a new title for this album:",oldTitle);if(e!=""&&e!=null&&e&&newTitle.length>2&&newTitle.length<31){loadingBar.show();params="setAlbumTitle&albumID="+e+"&title="+encodeURI(newTitle);lychee.api(params,"text",function(t){if(t){if(visible.albums())$(".album[data-id='"+e+"'] .overlay h1").html(newTitle);else{lychee.headerTitle.html(newTitle+""+$("#title span").html()+"");document.title="Lychee - "+newTitle}loadingBar.hide()}else loadingBar.show("error")})}else if(newTitle.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},getArchive:function(){albumID=lychee.content.attr("data-id");if(location.href.indexOf("index.html")>0)link=location.href.replace(location.hash,"").replace("index.html","php/api.php?function=getAlbumArchive&albumID="+albumID);else link=location.href.replace(location.hash,"")+"php/api.php?function=getAlbumArchive&albumID="+albumID;location.href=link}};build={divider:function(e){return"

"+e+"

"},album:function(e){if(!e)return"";if(!e.thumb0)e.thumb0="img/no_images.png";if(!e.thumb1)e.thumb1="img/no_images.png";if(!e.thumb2)e.thumb2="img/no_images.png";if(!e.title)e.title="Untitled";if(e.title.length>18)e.title=e.title.substr(0,18)+"...";var t="";t+="
";t+="thumb";t+="thumb";t+="thumb";t+="
";t+="

"+e.title+"

";t+=""+e.sysdate+"";t+="
";if(e.star=="1")t+="";if(e.public=="1")t+="";if(e.unsorted=="1")t+="";t+="
";return t},photo:function(e){if(e=="")return"";if(!e.title)e.title="";if(!e.thumbUrl)e.thumbUrl="img/no_image.png";if(e.title.length>18)e.title=e.title.substr(0,18)+"...";var t="";t+="
";t+="thumb";t+="
";t+="

"+e.title+"

";t+=""+e.sysdate+"";t+="
";if(e.star=="1")t+="";if(e.public=="1")t+="";t+="
";return t},modal:function(e,t,n,r){var i="";i+="
";i+="
";i+="

"+e+"

";i+="";i+="

"+t+"

";$.each(n,function(e){if(e==0)i+=""+this+"";else i+=""+this+""});i+="
";i+="";i+="
";return i},addModal:function(){var e="";e+="
";e+="
";e+="

Add Album or Photo

";e+="";e+="
";e+="
";e+="Add new Album";e+="
";e+="
";e+="
";e+="Upload new Photo";e+="
";e+="
";e+="
";return e},signInModal:function(){var e="";e+="
";e+="
";e+="

Sign in

";e+="";e+="
Version "+lychee.version+"
";e+="Sign in";e+="
";e+="
";return e},uploadModal:function(){var e="";e+="
";e+="
";e+="";e+="
";e+="
";e+="
";return e},contextMenu:function(e){var t="";t+="
";t+="
";t+="";t+="";$.each(e,function(n){if(e[n][1].length!=0){t+=""}});t+="";t+="
"+e[n][0]+"
";t+="
";return t},infobox:function(e,t){var n="";n+="

About

";n+="
";if(e.public==1)e.public="Public";else e.public="Private";if(t==true)editTitleHTML="";else editTitleHTML="
";if(t==true)editDescriptionHTML="";else editDescriptionHTML="
";infos=[["","Basics"],["Name",e.title+editTitleHTML],["Uploaded",e.sysdate],["Description",e.description+editDescriptionHTML],["","Image"],["Size",e.size],["Format",e.type],["Resolution",e.width+" x "+e.height],["","Camera"],["Captured",e.takedate],["Make",e.make],["Type/Model",e.model],["Shutter Speed",e.shutter],["Aperture",e.aperture],["Focal Length",e.focal],["ISO",e.iso],["","Share"],["Privacy",e.public],["Short Link",e.shortlink]];$.each(infos,function(e){if(infos[e][1]==""||infos[e][1]==undefined||infos[e][1]==null)infos[e][1]="-";if(infos[e][0]==""){n+="";n+="

"+infos[e][1]+"

";n+=""}else{n+="";n+="";n+="";n+=""}});n+="
"+infos[e][0]+""+infos[e][1]+"
";n+="
";n+="
";return n}};contextMenu={album:function(e){e.preventDefault();mouse_x=e.pageX;mouse_y=e.pageY;albumID=$(this).attr("data-id");if(albumID=="0"||albumID=="f"||albumID=="s")return false;mouse_y-=$(document).scrollTop();items=[["Rename","albums.rename("+albumID+")"],["Delete","albums.deleteDialog("+albumID+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".album[data-id='"+albumID+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:mouse_y,left:mouse_x})},photo:function(e){e.preventDefault();mouse_x=e.pageX;mouse_y=e.pageY;photoID=$(this).attr("data-id");mouse_y-=$(document).scrollTop();items=[["Rename","photos.rename("+photoID+")"],["Move to Album","contextMenu.move("+photoID+", "+(mouse_x+150)+", "+(mouse_y+$(document).scrollTop())+")"],["Delete","photos.deleteDialog("+photoID+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+photoID+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:mouse_y,left:mouse_x})},move:function(e,t,n){n-=$(document).scrollTop();lychee.api("getAlbums","json",function(r){if(lychee.content.attr("data-id")==0){items=[]}else{items=[["Unsorted","photos.move("+e+", 0)"]]}if(!r.albums){items=[["Create new Album","albums.add()"]]}else{$.each(r.album,function(t){if(this.id!=lychee.content.attr("data-id")){if(!this.title)this.title="Untitled";items[items.length]=new Array(this.title,"photos.move("+e+", "+this.id+")")}else{items[items.length]=new Array("","")}})}contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+e+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:n,left:t-150})})},share:function(e,t,n){n-=$(document).scrollTop();items=[[" Make Private","photos.setPublic()"],[" Twitter","photos.share(0, "+e+")"],[" Facebook","photos.share(1, "+e+")"],[" Mail","photos.share(2, "+e+")"],[" Copy Link","photos.share(3, "+e+")"],[" Copy Shortlink","photos.share(4, "+e+")"]];contextMenu.close();$("body").css("overflow","hidden");$(".photo[data-id='"+e+"']").addClass("active");$("body").append(build.contextMenu(items));$(".contextmenu").css({top:n,left:t})},close:function(){$(".contextmenu_bg, .contextmenu").remove();$(".photo.active, .album.active").removeClass("active");$("body").css("overflow","scroll")}};loadingBar={show:function(e,t,n){if(!e)e="loading";switch(e){case"error":if(!t||!n){t="Error";n="Whoops, it looks like something went wrong. Please reload the site and try again!"}lychee.loadingBar.removeClass("loading uploading error").addClass(e).html("

"+t+": "+n+"

").show().css("height","40px");lychee.header.css("margin-Top","40px");$.timer(3e3,function(){loadingBar.hide()});break;case"loading":clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.data("timeout",setTimeout(function(){lychee.loadingBar.show().removeClass("loading uploading error").addClass(e);if(visible.controls())lychee.header.css("margin-Top","3px")},1e3));break}},hide:function(){clearTimeout(lychee.loadingBar.data("timeout"));lychee.loadingBar.html("").css("height","3px");if(visible.controls())lychee.header.css("marginTop","0px");$.timer(300,function(){lychee.loadingBar.hide()})}};lychee={init:function(e,t){this.version="1.1";this.api_path=e;this.upload_path=t;this.loadingBar=$("#loading");this.header=$("header");this.headerTitle=$("#title");this.content=$("#content");this.image_view=$("#image_view");this.infobox=$("#infobox")},ready:function(){$("#tools_albums").show();if(!mobileBrowser())$(".tools").tipsy({gravity:"n"});if(window.webkitNotifications){window.webkitNotifications.requestPermission()}lychee.api("loggedIn","text",function(e){if(e!=1){$("body").append(build.signInModal());$("#username").focus();if(localStorage){local_username=localStorage.getItem("username");if(local_username==null)return false;if(local_username.length>1)$("#username").val(local_username);$("#password").focus()}}else if(e){$(window).bind("popstate",lychee.load);lychee.load()}})},api:function(e,t,n){$.ajax({type:"POST",url:lychee.api_path,data:"function="+e,dataType:t,success:n,error:lychee.error})},login:function(){user=$("input#username").val();password=hex_md5($("input#password").val());params="login&user="+user+"&password="+password;lychee.api(params,"text",function(e){if(e){if(localStorage){localStorage.setItem("username",user)}$(window).bind("popstate",lychee.load);lychee.load();lychee.closeModal()}else{$("#password").val("").addClass("error");$(".message .button.active").removeClass("pressed")}})},logout:function(){lychee.api("logout","text",function(e){window.location.reload()})},upload:function(e){pre_progress=0;$(".upload_overlay").remove();$("body").append(build.uploadModal());var t=new FormData;for(var n=0;npre_progress){$(".progressbar div").css("width",t+"%");pre_progress=t}if(t>=100)$(".progressbar div").css("opacity",.2)}};$("#upload_files").val("");r.send(t)},load:function(){contextMenu.close();hash=document.location.hash.replace("#","");albumID="";photoID="";if(hash.indexOf("a")!=-1)albumID=hash.split("p")[0].replace("a","");else albumID="";if(hash.indexOf("p")!=-1)photoID=hash.split("p")[1];else photoID="";lychee.content.attr("data-id",albumID);lychee.image_view.attr("data-id",photoID);if(albumID&&photoID){if(lychee.content.html()==""||$("#search").val().length!=0){lychee.content.hide();photos.load(albumID,true)}photos.loadInfo(photoID)}else if(albumID){if(visible.infobox)photos.hideInfobox();if(!visible.controls())lychee.showControls();if(visible.imageview())photos.hideView();else photos.load(albumID,false)}else{if(visible.infobox)photos.hideInfobox();if(!visible.controls())lychee.showControls();if(visible.imageview())photos.hideView();albums.load()}},"goto":function(e){document.location.hash=e},title:function(){return lychee.headerTitle.html().replace($("#title span").html(),"").replace("","")},showControls:function(){clearTimeout($(window).data("timeout"));if(visible.imageview()){lychee.image_view.removeClass("full");lychee.loadingBar.css("opacity",1);lychee.header.css("margin-Top","0px");if($("#image_view #image.small").length>0){$("#image_view #image").css({marginTop:-1*($("#image_view #image").height()/2)+20})}else{$("#image_view #image").css({top:70,right:30,bottom:30,left:30})}}},hideControls:function(){if(visible.imageview()){clearTimeout($(window).data("timeout"));$(window).data("timeout",setTimeout(function(){lychee.image_view.addClass("full");lychee.loadingBar.css("opacity",0);lychee.header.css("margin-Top","-45px");if($("#image_view #image.small").length>0){$("#image_view #image").css({marginTop:-1*($("#image_view #image").height()/2)})}else{$("#image_view #image").css({top:0,right:0,bottom:0,left:0})}},500))}},closeModal:function(){$(".message_overlay").removeClass("fadeIn").css("opacity",0);$.timer(300,function(){$(".message_overlay").remove()})},animate:function(e,t){animations=[["fadeIn","fadeOut"],["contentZoomIn","contentZoomOut"]];if(!e.jQuery)e=$(e);for(i=0;i300)waitTime=0;else if(t)waitTime=0;else waitTime=300-durationTime;$.timer(waitTime,function(){photosData="";$.each(n,function(){photosData+=build.photo(this)});lychee.content.html(photosData);if(!t){lychee.animate(".album, .photo","contentZoomIn");$("#tools_albums, #tools_photo").hide();$("#tools_album").show();$("img").retina();albums.loadInfo(e)}})})},loadInfo:function(e){photos.showView();loadingBar.show();params="getPhotoInfo&photoID="+e;lychee.api(params,"json",function(e){if(!e.title)e.title="Untitled";document.title="Lychee - "+e.title;lychee.headerTitle.html(e.title).addClass("editable");$("#button_star a").removeClass("icon-star-empty icon-star");if(e.star=="1"){$("#button_star a").addClass("icon-star");$("#button_star").attr("title","Unstar Photo")}else{$("#button_star a").addClass("icon-star-empty");$("#button_star").attr("title","Star Photo")}if(e.public=="1"){$("#button_share a").addClass("active");$("#button_share").attr("title","Make Photo Private")}else{$("#button_share a").removeClass("active");$("#button_share").attr("title","Share Photo")}e.url=lychee.upload_path+e.url;if(visible.controls()&&photos.isSmall(e))lychee.image_view.html("
");else if(visible.controls())lychee.image_view.html("
");else if(photos.isSmall(e))lychee.image_view.html("
");else lychee.image_view.html("
");lychee.animate(image_view,"fadeIn");lychee.image_view.show();if(!visible.controls())lychee.hideControls();lychee.infobox.html(build.infobox(e)).show();$.timer(300,function(){lychee.content.show()});loadingBar.hide()})},isSmall:function(e){size=[["width",false],["height",false]];if(e.width<$(window).width()-60)size["width"]=true;if(e.height<$(window).height()-100)size["height"]=true;if(size["width"]&&size["height"])return true;else return false},showView:function(){$("#tools_albums, #tools_album").hide();$("#tools_photo").show();$("body").css("overflow","hidden")},hideView:function(){$("#tools_photo, #tools_albums").hide();$("#tools_album").show();$("body").css("overflow","scroll");albums.loadInfo(lychee.content.attr("data-id"));lychee.animate(image_view,"fadeOut");$.timer(300,function(){lychee.image_view.hide()})},showInfobox:function(){if(!visible.infobox())$("body").append("
");lychee.infobox.css("right","0px")},hideInfobox:function(){$("#infobox_overlay").remove();lychee.infobox.css("right","-320px")},hide:function(e){$(".photo[data-id='"+e+"']").css("opacity",0).animate({width:0,marginLeft:0},300,function(){$(this).remove();if(!visible.imageview()){imgNum=parseInt($("#title span").html().replace("- ","").replace(" photos",""))-1;$("#title span").html(" - "+imgNum+" photos")}})},"delete":function(e){loadingBar.show();params="deletePhoto&photoID="+e;lychee.api(params,"text",function(t){if(t){photos.hide(e);lychee.goto("a"+lychee.content.attr("data-id"));loadingBar.hide()}else loadingBar.show("error")})},deleteDialog:function(e){if(!e)e=lychee.image_view.attr("data-id");if(visible.imageview())photoTitle=lychee.title();else photoTitle=$(".photo[data-id='"+e+"'] .overlay h1").html();if(photoTitle=="")photoTitle="Untitled";f1="photos.delete("+e+");";f2="";modal=build.modal("Delete Photo","Are you sure you want to delete the photo '"+photoTitle+"'?
This action can't be undone!",["Delete Photo","Keep Photo"],[f1,f2]);$("body").append(modal)},rename:function(e){if(!e)oldTitle=lychee.title();else oldTitle="";if(!e)e=lychee.image_view.attr("data-id");newTitle=prompt("Please enter a new title for this photo:",oldTitle);if(e!=null&&e&&newTitle.length<31){loadingBar.show();if(newTitle=="")newTitle="Untitled";params="setPhotoTitle&photoID="+e+"&title="+encodeURI(newTitle);lychee.api(params,"text",function(t){if(t){if(visible.imageview()){$("#infobox .attr_name").html($("#infobox .attr_name").html().replace(lychee.title(),newTitle));lychee.headerTitle.html(newTitle);document.title="Lychee - "+newTitle}$(".photo[data-id='"+e+"'] .overlay h1").html(newTitle);loadingBar.hide()}else loadingBar.show("error")})}else if(newTitle.length>0)loadingBar.show("error","Error","New title to short or too long. Please try another one!")},move:function(e,t){if(t>=0){loadingBar.show();params="movePhoto&photoID="+e+"&albumID="+t;lychee.api(params,"text",function(t){if(t){photos.hide(e);lychee.goto("a"+lychee.content.attr("data-id"));loadingBar.hide()}else loadingBar.show("error")})}},setStar:function(){loadingBar.show();photoID=lychee.image_view.attr("data-id");params="setPhotoStar&photoID="+photoID;lychee.api(params,"text",function(e){if(e){if($("#button_star a.icon-star-empty").length){$("#button_star a").removeClass("icon-star-empty icon-star").addClass("icon-star");$("#button_star").attr("title","Unstar Photo")}else{$("#button_star a").removeClass("icon-star-empty icon-star").addClass("icon-star-empty");$("#button_star").attr("title","Star Photo")}photos.load(lychee.content.attr("data-id"),true);loadingBar.hide()}else loadingBar.show("error")})},setPublic:function(e){loadingBar.show();photoID=lychee.image_view.attr("data-id");params="setPhotoPublic&photoID="+photoID+"&url="+photos.getViewLink(photoID);lychee.api(params,"text",function(t){if(t){if($("#button_share a.active").length){$("#button_share a").removeClass("active");$("#button_share").attr("title","Make Private")}else{$("#button_share a").addClass("active");$("#button_share").attr("title","Share Photo");contextMenu.share(photoID,e.pageX,e.pageY)}photos.load(lychee.content.attr("data-id"),true);loadingBar.hide()}else loadingBar.show("error")})},setDescription:function(){description=prompt("Please enter a description for this photo:","");photoID=lychee.image_view.attr("data-id");if(description.length>0&&description.length<160){loadingBar.show();params="setPhotoDescription&photoID="+photoID+"&description="+escape(description);lychee.api(params,"text",function(e){if(e)photos.loadInfo(photoID);else loadingBar.show("error")})}else if(description.length>0)loadingBar.show("error","Error","Description to short or too long. Please try another one!")},share:function(e,t){loadingBar.show();params="sharePhoto&photoID="+t+"&url="+photos.getViewLink(t);lychee.api(params,"json",function(n){switch(e){case 0:link=n.twitter;break;case 1:link=n.facebook;break;case 2:link=n.mail;break;case 3:link="copy";modal=build.modal("Copy Link","You can use this link to share your image with other people: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus();break;case 4:link="copy";modal=build.modal("Copy Shortlink","You can use this link to share your image with other people: ",["Close"],[""]);$("body").append(modal);$(".copylink").focus();break;default:link="";break}if(link=="copy")loadingBar.hide();else if(link.length>5){location.href=link;loadingBar.hide()}else loadingBar.show("error")})},getViewLink:function(e){if(location.href.indexOf("index.html")>0)return location.href.replace("index.html"+location.hash,"view.php?p="+e);else return location.href.replace(location.hash,"view.php?p="+e)},previous:function(){albumID=lychee.content.attr("data-id");photoID=lychee.image_view.attr("data-id");params="previousPhoto&photoID="+photoID+"&albumID="+albumID;lychee.api(params,"json",function(e){if(e!=false)lychee.goto("a"+albumID+"p"+e.id)})},next:function(){albumID=lychee.content.attr("data-id");photoID=lychee.image_view.attr("data-id");params="nextPhoto&photoID="+photoID+"&albumID="+albumID;lychee.api(params,"json",function(e){if(e)lychee.goto("a"+albumID+"p"+e.id)})}};search={find:function(e){clearTimeout($(window).data("timeout"));$(window).data("timeout",setTimeout(function(){if($("#search").val().length!=0){params="search&term="+e;lychee.api(params,"json",function(e){albumsData="";if(e&&e.albums)$.each(e.albums,function(){albumsData+=build.album(this)});photosData="";if(e&&e.photos)$.each(e.photos,function(){photosData+=build.photo(this)});if(albumsData==""&&photosData=="")code="";else if(albumsData=="")code=build.divider("Photos")+photosData;else if(photosData=="")code=build.divider("Albums")+albumsData;else code=build.divider("Photos")+photosData+build.divider("Albums")+albumsData;if(lychee.content.attr("data-search")!=code){lychee.animate(".album, .photo","contentZoomOut");lychee.animate(".divider","fadeOut");$.timer(300,function(){lychee.content.attr("data-search",code);lychee.content.html(code);lychee.animate(".album, .photo","contentZoomIn")})}})}else search.reset()},250))},reset:function(){$("#search").val("");if(lychee.content.attr("data-search")!=""){lychee.content.attr("data-search","");lychee.animate(".divider","fadeOut");albums.load()}}};visible={albums:function(){if($("#tools_albums").css("display")=="block")return true;else return false},imageview:function(){if($("#image_view.fadeIn").length>0)return true;else return false},infobox:function(){if(parseInt(lychee.infobox.css("right").replace("px",""))==-320)return false;else return true},controls:function(){if(lychee.loadingBar.css("opacity")>0)return true;else return false}}