//initialisation
var change_ok = true;
//barree chargement  

function barre_charge(larg) {
  if (larg <= 100) {

    //document.getElementById("charge").innerHTML=parseInt(i/3)+"%";
	document.getElementById("charge").style.width=larg +'%';
	larg=larg+4;
	timerID=setTimeout("barre_charge("+larg+");", 50);
    }
	else{
clearTimeout(timerID);
document.getElementById("charge").style.visibility='hidden';
document.getElementById("anim").style.visibility='visible';
}
}
function description(texte){
	if (document.getElementById)
    {
    document.getElementById('descript').innerHTML = texte;
	document.getElementById('descript').style.border = '1px solid FF0000';
    }
	else if (document.all) 
    {
    document.all['descript'].innerHTML = texte;
	document.all['descript'].style.border = '1px solid FF0000';
    }
}
function cache_descript(){
	if (document.getElementById)
    {
    document.getElementById('descript').innerHTML = '';
	document.getElementById('descript').style.border = '0px solid FF0000';
    }
	else if (document.all) 
    {
    document.all['descript'].innerHTML = '';
	document.all['descript'].style.border = '0px solid FF0000';
    }
}
//chargement intermediaire des images
function test_cache(n_im){

	if (n_im.complete){
	clearTimeout(TimerId);
	document.getElementById('shoot').src=n_im.src;
	change_ok=true;
	}
	else{
	TimerId=setTimeout("affiche("+im2+")",900);

	}
}

function nvl_img(im){
im2=new Image();
im2.src=im;
document.getElementById('shoot').src='./img/chargeur.gif';
TimerId=setTimeout("test_cache(im2)",900);


}
//changement des images
function change(){

if (change_ok){
	change_ok=false;
	var nb_arg=change.arguments.length;
	var i=0;
	var uri=document.getElementById('shoot').src;
	

	while ( (uri.lastIndexOf(change.arguments[i]) == -1) || (i == nb_arg)){
		i++;
		
	}
	i++;
	
	if (i==nb_arg){
		i=0;
	}
	//document.getElementById('shoot').src = "./test/"+change.arguments[i];
	nvl_img("./photo/"+change.arguments[i]);

}
}

function vizu () {
imgbig = new Image();
imgbig.src = document.getElementById('shoot').src+'B';

waitForLoading();
}
function waitForLoading () {
var charge=window.open('about:blank', 'chargement', 'width=240', 'height=180','screenX=10','screenY=10','top=10','left=10');
charge.document.write('<html><body><img src="img/chargeur.gif" alt="chargement" /></body></html>');

if (!imgbig.complete) { setTimeout(waitForLoading, 30); return; }

charge.close();
var w = window.open('about:blank', 'visualisation', 'width='+imgbig.width+',height='+imgbig.height,'screenX=10','screenY=10','top=10','left=10');

w.document.write('<html><body><img src="'+imgbig.src+'" alt="Description" /></body></html>');

}

