function bootstrap(){document.getElementById(containerid).innerHTML='<div class="loading"></div>';var a=document.createElement("script");a.setAttribute("src",url+"photosets/"+config.nsid);a.setAttribute("type","text/javascript");document.documentElement.firstChild.appendChild(a);var a=document.createElement("script");a.setAttribute("src",url+"tag_list/"+config.nsid);a.setAttribute("type","text/javascript");document.documentElement.firstChild.appendChild(a);if(bootstrap_page!=""){var a=document.createElement("script");a.setAttribute("src",url+bootstrap_page);a.setAttribute("type","text/javascript");document.documentElement.firstChild.appendChild(a)}}function latest_callback(a){latest_json=a.photos;latest()}function latest(){if(document.getElementById("title")){document.getElementById("title").innerHTML="Latest photos:";document.getElementById("descr").innerHTML=""}if(typeof latest_json!="undefined"){config.total=parseInt(latest_json.total);config.displayedpages=total(config.total,config.perpage,config.maxpages);config.photos=latest_json.photo;generate_latest_html()}else{config.page=1;load("latest/"+config.nsid)}}function photosets_callback(c){var a=document.getElementById("photosets_dropdown");photosets_json=c.photosets.photoset;for(var b=0;b<photosets_json.length;b++){var d=document.createElement("option");d.value=b;d.innerHTML=photosets_json[b].title._content;if(config.option==photosets_json[b].id){config.selectedIndex=b;d.selected=true}a.appendChild(d)}}function photoset_callback(a){photosets_ids[a.photoset.id]=a.photoset;photoset(config.selectedIndex)}function photoset(a){var b=photosets_json[a].id;if(document.getElementById("title")){document.getElementById("title").innerHTML="Photoset / "+photosets_json[a].title._content+" ";document.getElementById("descr").innerHTML=photosets_json[a].description._content}if(photosets_ids[b]){config.selectedIndex=a;config.total=parseInt(photosets_ids[b].total);config.displayedpages=total(config.total,config.perpage,config.maxpages);config.photos=photosets_ids[b].photo;generate_photoset_html(a)}else{config.page=1;load("photoset/"+b)}}function tags_callback(c){var a=document.getElementById("tags_dropdown");tags_json=c.who.tags.tag;for(var b=0;b<tags_json.length;b++){var d=document.createElement("option");d.value=b;d.innerHTML=tags_json[b]._content;a.appendChild(d)}}function tag_callback(a){tags_ids[tags_json[config.selectedIndex]._content]=a.photos;tag(config.selectedIndex)}function tag(b){var a=tags_json[b]._content;if(document.getElementById("title")){document.getElementById("title").innerHTML="Tag / "+tags_json[b]._content+" ";document.getElementById("descr").innerHTML=""}if(tags_ids[a]){config.selectedIndex=b;config.total=parseInt(tags_ids[a].total);config.displayedpages=total(config.total,config.perpage,config.maxpages);config.photos=tags_ids[a].photo;generate_tag_html(b)}else{config.page=1;load("tag/"+config.nsid+"/"+a)}}function generate_latest_html(){highlightMe("latest");generate_generic_html()}function generate_photoset_html(a){highlightMe("photosets");generate_generic_html()}function generate_tag_html(a){highlightMe("tags");generate_generic_html()}function generate_generic_html(){var e=0;var h=(config.page-1)*config.perpage;var b=h+config.perpage-1;b=config.total<=b?config.total-1:b;var g=config.photos;var a=document.getElementById(containerid);a.innerHTML="";for(var f=h;f<=b;f++){var d=g[f];var c="";c=getImageUrl(d,"");if(config.quality=="hd"){if(d.o_width){if(d.o_width>1280||d.o_height>1280){c=getImageUrl(d,"_b")}else{c=getOriginalImageUrl(d)}}}build_photo(a,d,c,e);e++}build_bottom_pagination(a);overlay_callback()}function build_bottom_pagination(c){var f=document.createElement("div");f.id="pagination";for(var e=1;e<=config.displayedpages;e++){var d="";if(e==config.page){d="selected"}var b='<a href="" onclick="config.page='+e+'; generate_generic_html(); return false" class="'+d+'">'+e+"</a>";f.innerHTML+=b}c.appendChild(f)}function highlightMe(d){var c=document.getElementById("latest_pagination");if(c&&c.hasChildNodes()){c=c.childNodes;for(var b=0;b<c.length;b++){c[b].className="page"}}var a=document.getElementById("photoset_pagination");if(a&&a.hasChildNodes()){a=a.childNodes;for(var b=0;b<a.length;b++){a[b].className="page"}}switch(d){case"photosets":document.getElementById("photosets_dropdown").style.background="#fdd1d1";document.getElementById("tags_dropdown").style.background="#FFFFFF";document.getElementById("latest_label").style.textDecoration="none";if(document.getElementById("photoset_"+config.page)){document.getElementById("photoset_"+config.page).className="pagesel"}break;case"tags":document.getElementById("photosets_dropdown").style.background="#FFFFFF";document.getElementById("tags_dropdown").style.background="#fdd1d1";document.getElementById("latest_label").style.textDecoration="none";break;case"latest":document.getElementById("photosets_dropdown").style.background="#FFFFFF";document.getElementById("tags_dropdown").style.background="#FFFFFF";document.getElementById("latest_label").style.textDecoration="underline";if(document.getElementById("latest_"+config.page)){document.getElementById("latest_"+config.page).className="pagesel"}break}}function getImageUrl(a,b){return"http://farm"+a.farm+".static.flickr.com/"+a.server+"/"+a.id+"_"+a.secret+b+".jpg"}function getOriginalImageUrl(a){return"http://farm"+a.farm+".static.flickr.com/"+a.server+"/"+a.id+"_"+a.originalsecret+"_o."+a.originalformat}function triptracker(){var e=new PhotoViewer();var c=document.getElementsByTagName("a");triptracker_index=0;for(var b=0;b<c.length;b++){var a=c[b];var d=String(a.getAttribute("rel"));if(a.getAttribute("href")){if(d.toLowerCase().match("triptracker")){e.add(a.getAttribute("href"));a.onclick=function(){e.show(this.getAttribute("num"))};triptracker_index=triptracker_index+1}}}}function load(b){document.getElementById(containerid).innerHTML='<div class="loading"></div>';var b=url+b;var a=document.createElement("script");a.setAttribute("src",b);a.setAttribute("type","text/javascript");document.documentElement.firstChild.appendChild(a)}function total(c,b,a){reste=c%b==0?0:1;if(c<=b){return 1}else{if(Math.floor(c/b)>a){return a}}return Math.floor(c/b)+reste}function getCookie(b,a){if(document.cookie.length>0){c_start=document.cookie.indexOf(b+"=");if(c_start!=-1){c_start=c_start+b.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_start,c_end))}}return a}function setCookie(b,c,a){var d=new Date();d.setDate(d.getDate()+a);document.cookie=b+"="+escape(c)+((a==null)?"":";expires="+d.toGMTString())+"; path=/"};
