var imagesleft = null;
var numimagesleft = 0;
var currentimageleft = 0;
var nextimageleft = 1;

var currentopacity = 100;

var ie = navigator.userAgent.indexOf('MSIE') + 1;

initimage = function()
{
	imagesleft = document.getElementById("imgleft");
	
	if(imagesleft)
	{
		numimagesleft = imagesleft.childNodes.length;
		imagesleft.childNodes[0].style.display = 'block';
		
		if(ie){imagesleft.childNodes[0].filters.alpha.opacity = '100'}
		else{if(!isNaN(imagesleft.childNodes[0].style.opacity)){imagesleft.childNodes[0].style.opacity = '1.0';}}		
	}
	
	if(numimagesleft > 1)setTimeout('switchimage()', 5000);
	
}

switchimage = function()
{
	//als currentopacity 100 is dan zet de volgende image zichtbaar
	if(currentopacity == 100)	
		if(numimagesleft > 1)imagesleft.childNodes[nextimageleft].style.display = 'block';
			
	currentopacity -= 10;	
	
	if(ie)
	{
		if(numimagesleft > 1){
		imagesleft.childNodes[currentimageleft].filters.alpha.opacity = currentopacity;
		imagesleft.childNodes[nextimageleft].filters.alpha.opacity = (100 - currentopacity);}
	}
	else 
	{
		if(!isNaN(imagesleft.childNodes[currentimageleft].style.opacity))
		{
			if(numimagesleft > 1){
			imagesleft.childNodes[currentimageleft].style.opacity = '0.'+ currentopacity;		
			imagesleft.childNodes[nextimageleft].style.opacity = (currentopacity ? '0.'+ (100 - currentopacity) : '1.0');}
		} 
	}
		
	if(currentopacity == 0)
	{
		if(numimagesleft > 1){
		imagesleft.childNodes[currentimageleft].style.display = 'none';	
		currentimageleft = nextimageleft;
		nextimageleft = (currentimageleft + 1) % numimagesleft;}
		
		currentopacity = 100;
		setTimeout('switchimage()', 5000);
	}
	else
	{		
		setTimeout('switchimage()', 80);
	}
}

window.onload = initimage;
