var current =  0;
var status = "nao";
var tempo=0;
var time;
function imgPreloader( code ){
	img = document.createElement("img");
	img.src = images_arr[ code ].src;
	if(images_arr[ code ].srctxt)
	{
	imgtxt = document.createElement("img");	
	imgtxt.src = images_arr[ code ].srctxt;
	imgtxt.alt = images_arr[ code ].alt+"txt";
	imgtxt.id = images_arr[ code ].id+"txt";
	}
	img.alt = images_arr[ code ].alt;
	img.id = images_arr[ code ].id;
	time = images_arr[ code ].time;
	img.onloaded = new function(){
        img.style.display = 'block';
		document.getElementById('foto').innerHTML='';
		if(images_arr[ code ].srctxt)
		{
		document.getElementById('foto').innerHTML='<div id="imgtexto" style="float:left; width:350px; padding-left:40px; *padding-left:70px;"></div>';
		document.getElementById('imgtexto').appendChild(imgtxt);
		}
		document.getElementById('foto').appendChild(img);
		document.getElementById('foto').style.display='block';
		onLoadImg();}
	window.status = "Carregando "+ (current + 1) + " de " + images_arr.length + " imagens.";
}
function onLoadImg(){
	
		if(status=="ok")
		{
		status="nao";
		current++;
	if( current < images_arr.length ){
		imgPreloader( current );
	}
	else if(current == images_arr.length )
	{
		current=0;
		imgPreloader( current );
	}
		}
		else
		{
			if(img.id=="sebrae" || img.id=="sebrae3" || img.id=="sebrae5")
		{
		novo = new classe();
		novo.setx(-70);
		novo.setlimit(0);
		novo.setid(img.id);
		valor = 10;
		move();
		}
		else if(img.id=="sebrae2" || img.id=="sebrae4")
		{
		novo = new classe();
		novo.setx(0);
		novo.setlimit(-70);
		novo.setid(img.id);
		valor = 10;
		moveLeft();
		}
		}
	tempo=0;
	contaTempo();	
}

function contaTempo()
{
	tempo+=1;
	if(tempo!=time)
	{
	}
	else
	{
	status="ok";
	onLoadImg();
	tempo=0;
	}
}
setInterval('contaTempo()',1000);
