var cn = 0;
var active = false;

function showFirstImage() {
 document.writeln("<div id=\"bigPicture\" style=\"display:none;\"><img src=\"img/" + entry[0]["file"] + "\" name=\"bigPicture\" width=\"400\" height=\"400\" /></div>");
}

function showGalery() {
 for(var i=0; i < entry.length; i++) {
  document.write("<div id=\"thumb_" + i + "\" style=\"display:none;\"><a href=\"javascript:showImage(" + i + ");\" border=\"0\"><img src=\"img/thumbnails/" + entry[i]["file"] + "\" width=\"100\" height=\"100\" /></a></div>");
  
 }
 for(var i=0; i < entry.length; i++) {
  new Effect.Appear("thumb_" + i, { from: 0.0, to: 1.0, duration: (i+Math.random())*0.5 });
 }
}

function startDiashow() {
 if (cn == entry.length) { cn = 0; }
 document.images["bigPicture"].src = "img/" + entry[cn]["file"]
 new Effect.Appear("bigPicture", { from: 0.0, to: 1.0, duration: 1.5});
 if (entry.length > 1 ) {
  cn++;
  active = window.setTimeout("startDiashow()", 5000);
 }
}

function showImage(i) {
 clearTimeout(active);
 cn = i;

 startDiashow();
}
