var Img = new Array();
var j=0;	
var erased = new Array();

for(var i=1;i<10;i++)
{
	Img[i] = new Image();
	Img[i].src = "www_pics/anim" + i + ".jpg";
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
} 

function opacity(id, opacStart, opacEnd, millisec) {
//speed for each frame
var speed = Math.round(millisec / 100);
var timer = 0;

//determine the direction for the blending, if start and end are the same nothing happens
if(opacStart > opacEnd) {
	for(i = opacStart; i >= opacEnd; i--) {
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		timer++;
	}
} else if(opacStart < opacEnd) {
	for(i = opacStart; i <= opacEnd; i++)
		{
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		timer++;
	}
}

}
	

function fadeout(id,value)
{
	opacity(id,value,0,500);

}

function fadein(id,value)
{
	opacity(id,0,value,500);
	
}

function effacer(ElementId)
{
	if(erased[ElementId]!=1)
	{ 
		document.getElementById(ElementId).value=''; 
		erased[ElementId]=1;
	}
}

function switch_pic()
{
		j=(j % 8)+1;
		fadeout('img_anim',100);
		setTimeout("document.getElementById('img_anim').src='"+Img[j].src+"'",500);
		setTimeout("fadein('img_anim',100)",500);

}


function diaporama ()
{

	setInterval("switch_pic()",5000);
	
}

