var total = 45;
var actuel = 1;
var chemin = "film/images/bobleponge_film";
var imgTemp;
var champ = document.getElementById("numero");
var img = document.getElementById("vue");
var loading = document.getElementById("loading");


function image_precedente() {
	if (actuel != 1 && loading.style.visibility == "hidden") {
		actuel--;
		image_maj();
	}
}

function image_suivante() {
	if (actuel != total && loading.style.visibility == "hidden") {
		actuel++;
		image_maj();
	}
}

function image_maj() {
	loading.style.visibility = "visible";

	if (actuel < 10)
		actuel = "0" + actuel.toString();
	else
		actuel = actuel.toString();

	imgTemp = new Image();
	imgTemp.src = chemin + actuel.toString() + ".jpg";
	setTimeout("image_wait()", 10);
}

function image_random() {
	if (loading.style.visibility == "hidden") {
		actuel = Math.round((total - 1) * Math.random()) + 1;
		image_maj();
	}
}

function image_wait() {
	if (imgTemp.complete == true) {
		champ.innerHTML = "(" + actuel + " / " + total.toString() + ")";
		img.src = imgTemp.src;
		loading.style.visibility = "hidden";
	}
	else
		setTimeout("image_wait()", 10);
}
