+ picdata=json;
+
+ /* if ID is set, just show one pictures, else create an array of pictures */
+ if (ID>=0)
+ {
+ var singlepicspace=pics.selectAll("li").data(picdata, function(d){return ID;}).enter().append("li").append("div").attr("class","singlepic");
+ singlepicspace.append("div").attr("class","left").append("img").attr("src",webbase+"/icons/left.png");
+ singlepicspace.append("img")
+ .attr("class","large")
+ .attr("src",function(d) {
+ s= d.base_uri+'/'+d.filename;
+ s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>',webbase+'/Photos-small/');
+ return s;
+ });
+ singlepicspace.append("div").attr("class","right").append("img").attr("src",webbase+"/icons/right.png");
+
+ update_thumbnails();
+ }
+ else
+ {
+ d3.select(".nextprev").select("ul").selectAll("li").remove();
+ pics.selectAll("li").data(picdata)
+ .enter().append("li")
+ .append("a")
+ .on("click", function(d) { load_pic(d.id); })
+ .append("img")
+ .attr("src",function(d) {
+ count++;
+ s= d.base_uri+'/'+d.filename;
+ s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>',webbase+'/Photos-tiny/');
+ return s;
+ });
+ };
+
+ checkbutton();
+ });
+
+ update_permalink()
+}
+
+function update_permalink() {
+ /* update permalink */
+
+ permalink = webbase;
+
+ if(T!="")
+ permalink += '/tag/' + T;
+ if(page!=1)
+ permalink += '/page/' + page;
+ if(ID>0)
+ permalink += '/pic/' + ID;
+
+ d3.select(".permalink").html("Permalink: <a href=\""+permalink+"\">"+permalink+"</a>");
+}
+
+function prev_page() {
+ if (page>=2) page=page-1;
+ load_content();
+}
+
+function next_page() {
+ page=page+1;
+ load_content();
+}
+
+function prev_pic() {
+}
+
+function next_pic() {
+}
+
+function load_pic(myid) {
+ ID=myid;
+ update_page_index();
+ update_thumbnails();
+ load_content();
+}
+
+function tagcloud() {
+
+ url = webbase+"/getjson.php?CLOUD=1";
+
+ pics.selectAll("li").remove();
+
+ var svgelement=pics.append("li")
+ .append("svg").attr("width",400).attr("height",400);
+
+ /* update pics */
+ d3.json(url, function(json) {
+ svgelement.selectAll("text").data(json).enter().append("text")
+ .style("font-size", function(d){return (Math.log(d.count+1)/2.0)+"em"})
+ .text(function(d) { return d.name+" "; })
+ .on("mouseover", function(d){ d3.select(this).style("color","red")} )
+ .on("mouseout", function(d){ d3.select(this).style("color","white")} )
+ .on("click", function(d) { document.location.href=webbase+'/tag/'+d.name })
+ });
+}
+
+function update_thumbnails(){
+ if(T!="")
+ url2 = webbase+"/getjson.php?NP=1&T="+T+"&ID="+ID;
+ else
+ url2 = webbase+"/getjson.php?NP=1&ID="+ID;
+
+ var IDprev=-1;
+ var IDnext=-1;
+ var IDcurr=-1;
+ d3.json(url2, function(json2) {
+ /* figure out where the arrows on the pic should link to */
+ all=""
+ for (var i in json2){
+ if( IDcurr != ID )
+ {
+ IDprev = IDcurr;
+ IDcurr = IDnext;
+ IDnext = json2[i].id;
+ };
+ }
+
+ var thumbs= d3.select(".nextprev").select("ul").selectAll("li").data(json2, function(d) {return d.id;});
+
+ thumbs.enter().append("li")