var duration = 5; // #seconds pause
var foto;         // photo img element
var desc;         // description element

var fotos;        // list of phot urls
var nr;           // #nr in slideshow

function slide() {
     nr = 0;
     var running = (fotos != null);

     if ( !running ) {
       fotos = new Array();
       var gal = document.getElementById("gallery");
       var refs = gal.getElementsByTagName( "A" );
       for ( var i=0; i<refs.length; i++) {
         fotos[fotos.length] = refs[i];
       }
     }

     var myWin; // extra window
     myWin = open("", "displayWindow",
       "width=650,height=650,status=no,toolbar=no,menubar=no");

     myWin.document.open();
     myWin.document.write("<html><head><title>SlideShow\n");
     myWin.document.write("</title></head><body>");
     myWin.document.write("<img id='foto' src='" + fotos[nr].href + "' title='foto' /><br/>");
     myWin.document.write("<div id='desc'></>");
     myWin.document.write("</body></html>");
     myWin.document.close();

     foto = myWin.document.getElementById("foto");
     desc = myWin.document.getElementById("desc");

     if ( ! running ) {
       switchImg();
     }
       // for ();
     // newdoc.getElementById('foto').src = img[i].src;
}

function switchImg() {
     foto.src = fotos[nr].href;
     nr = ( nr + 1 ) % fotos.length;
     setTimeout("switchImg()", duration*1000);
}
