var srcs = new Object;
srcs['1999-05-15-212258.jpg'] = 'Having fun at Bakken, one of the worlds oldest amusement parks (Charlottenlund, Denmark, June 1999)';
srcs['1999-07-29-111717.jpg'] = 'Summer (Sabaudia, Italy, August 1999)';
srcs['1999-08-01-175827.jpg'] = 'Hot water basin from one of the ancient imperial baths, behind the Senate (Rome, Italy, September 1999)';
srcs['1999-08-04-160427.jpg'] = 'View of the park of the Reggia di Caserta with its elaborate fountains and canals (Caserta, Italy, September 1999)';
srcs['1999-08-04-163056.jpg'] = 'The splendid park of the royal palace (Caserta, Italy, September 1999)';
srcs['1999-08-05-115201.jpg'] = 'Ruins of temples and sanctuaries of the 5th century BCE (Pæstum, Italy, September 1999)';
srcs['1999-08-05-120620.jpg'] = 'Greek temple of the Doric order from 500 BCE (Pæstum, Italy, September 1999)';
srcs['1999-08-07-112621.jpg'] = 'Marvellous bike but pale legs (camping at Forza Agrò Sicily, September 1999)';
srcs['1999-08-09-132727.jpg'] = 'Packing the bike and preparing to leave, 45°C in the shade (camping at Forza Agrò Sicily, September 1999)';
srcs['1999-08-12-184228.jpg'] = 'Molesting a 12th century Norman bridge, the Ponte Ammiraglio in Palermo, with a scooter almost as old (Palermo, Italy, September 1999)';
srcs['1999-08-14-191654.jpg'] = 'Enjoying the shade at Villa Niscemi (Palermo, Italy, September 1999)';
srcs['1999-08-17-121823.jpg'] = 'The island of Motya in Sicily with the remains of a Fenecian city, destroyed in 394 BCE by Selinunte (Sicily, September 1999)';
srcs['1999-08-17-184412.jpg'] = 'One of the best preserved hellenistic temples in the world, with some fool in the foreground (Segesta, Sicily, September 1999)';
srcs['2000-07-02-193140.jpg'] = 'Wind-turbines in front of the port (Copenhagen, Denmark, August 2000)';
srcs['2000-08-05-194232.jpg'] = 'Sferracavallo, a sicilian fishing village (Palermo, Italy, September 2000)';
srcs['2000-08-06-134117.jpg'] = 'Mosaics of hunting scenes at Villa del Casale (Piazza Armerina, Sicily, September 2000)';
srcs['2000-08-15-173222.jpg'] = 'View of Palermo from the pilgrims pathway to the sanctuary on Monte Pallegrino (Palermo, Italy, September 2000)';
srcs['2000-08-18-123737.jpg'] = 'Roman amphitheatre (Siracusa, Italy, September 2000)';
srcs['2000-08-18-151151.jpg'] = 'Nothing beats eating cool watermelon when it is more than 40°C in the shade (Siracusa, Italy, September 2000)';
srcs['2000-08-22-112638.jpg'] = 'View of the towers of the medieval town of San Gimignano (Tuscany, Italy, September 2000)';
srcs['2000-08-23-172645.jpg'] = 'Tuscan landscape seen from the hill of San Gimignano (Tuscany, Italy, September 2000)';
srcs['2000-08-24-174243.jpg'] = 'Heading for Monteriggioni, a medieval fortified village (near Siena, Italy, September 2000)';
srcs['2000-08-24-194334.jpg'] = 'Dinner at the camping (San Gimignano, Italy, September 2000)';
srcs['2000-08-25-121758.jpg'] = 'View of Firenze from the Piazza Michelangelo (Florence, Italy, September 2000)';
srcs['2000-08-29-115922.jpg'] = 'Preparing for the road (leaving San Gimignano, Italy, September 2000)';
srcs['2000-09-01-161810.jpg'] = 'View of the Forum of Trajan towards the Piazza Venezia (Rome, October 2000)';
srcs['2000-09-01-164445.jpg'] = 'Under the cool, shady colonnades of the most splendid Imperial Forum ever built -- or what is left of it (Forum of Trajan, Rome, October 2000)';
srcs['2001-04-29-180109.jpg'] = 'Babysitting, being baby-sat or whatever, I don\'t know (May 2001)';
srcs['2001-05-05-163447.jpg'] = 'Viking ships made and operated at the Viking Ship Museum (Roskilde, Denmark, June 2001)';
srcs['2001-05-11-153512.jpg'] = 'Having a nice chat with one of the local ducks (Copenhagen, Denmark, June 2001)';
srcs['2001-05-13-153616.jpg'] = 'Sunny day at Dragør, a well-preserved Danish fishing village (Dragør, Denmark, June 2001)';
srcs['2001-06-08-221158.jpg'] = 'Feeding the ugly ducklings and their beautiful parents (Copenhagen, Denmark, July 2001)';
srcs['2001-09-20-121738.jpg'] = 'Getting married (Palermo, Sicily, October 2001)';
srcs['2001-09-20-124740.jpg'] = 'Just got married (Palermo, Sicily, October 2001)';
srcs['2001-09-20-131133.jpg'] = 'Just got married (Palermo, Sicily, October 2001)';
srcs['2001-09-20-145200.jpg'] = 'Sicilian wedding party (Palermo, Sicily, October 2001)';
srcs['2001-09-20-145302.jpg'] = 'Sicilian wedding party (Palermo, Sicily, October 2001)';
srcs['2001-09-20-162156.jpg'] = 'Sicilian wedding party (Palermo, Sicily, October 2001)';

var prefix = '/rene/slides';

var speed = 15000;

// This is to avoid repetitions
var repeat = Math.floor(srcs.length/5);
var images = new Array();
var i = 0;

for (var s in srcs) {
    if (srcs[s] == 0) {
	srcs[s] = s;
    }

    images[i] = new Image(320, 240);
    images[i].src = prefix + '/' + s;
    images[i].alt = srcs[s];
    images[i].title = srcs[s];
    images[i].can_show = 1;
    i++;
}

function set_image(image) {
    document.photo.src = image.src;
    document.photo.alt = image.alt;
    document.photo.title = image.title;

    var element = document.getElementById
	? document.getElementById('photocaption')
	: (document.all
	   ? document.all['photocaption']
	   : null);
    if (element) {
	if (element.innerHTML) {
	    element.innerHTML = image.alt;
	}
	if (element.href) {
	    element.href = image.src.replace(/\.jpg$/, "-large.jpg");
	}
    }
}

function change_image() {
    var max = images.length;
    var i = Math.floor(Math.random() * max);
    while (--max >= 0 
	   && (!images[i].complete || images[i].can_show <= 0)) {
	if (++i >= images.length) {
	    i = 0;
	}
    }

    if (images[i].complete) {
	set_image(images[i]);
    }

    images[i].can_show = -repeat;
    for (i = images.length; --i >= 0; ) {
	images[i].can_show++;
    }
}

function change_image_callback() {
    change_image();
    window.setTimeout(change_image_callback, speed);
}

set_image(images[Math.floor(Math.random() * images.length)]);
window.setTimeout(change_image_callback, 10000);

