var timer=8;
var photos=['bunner1','bunner2','bunner3','bunner4','bunner5','bunner6'];
var img;
var count=1;

function addLoadListener(fn)
{
	if(typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if(typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if(typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		var oldfn = window.onload;
		if(typeof window.onload != 'function')
		{
			window.onload=fn;
		}
		else
		{
			window.onload=function()
			{
				oldfn();
				fn();
			};
		}
	}
}

function startSlideshow()
{
	img=document.getElementById('slide');
	window.setTimeout('nextSlide()',timer*1000);
}

function nextSlide()
{
	var next=new Image();
	
	next.onerror=function()
	{
		alert('Falha ao carregar imagem.');
	};

	next.onload=function()
	{
		img.src=next.src;
		img.width=next.width;
		img.height=next.height;
		
		if(++count==photos.length){count=0;}
		window.setTimeout('nextSlide()',timer*1000);
	};

	next.src='i/'+photos[count]+'.jpg';
}

addLoadListener(startSlideshow);
