var imgbanner = new Array();
var href = new Array();
var atualbanner=0;
imgbanner[0] = "http://www.ifpr.edu.br/wp-content/uploads/2009/03/banner_if2.gif";
href[0] = "http://portal.mec.gov.br/redefederal/";
imgbanner[1] = "http://www.ifpr.edu.br/wp-content/themes/ifet_1.2/images/banner_centenario.jpg";
href[1] = "#";

function bannerOut(id, time) {
	target = id; //document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0) {
					clearInterval(i);
					if((atualbanner+1) >= imgbanner.length) atualbanner=0;
					else atualbanner++;
					startBanner('banner', time);
				}
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
}

function startBanner(id, time) {
	
	target = document.getElementById(id);
	setAlpha(target, 0);
	
	target.src = imgbanner[atualbanner];
	target.style.visibility="visible";
	cap = document.getElementById("link");
	cap.href = href[atualbanner];
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100) {
					clearInterval(i);
					if(imgbanner.length==1) return 0;
					setTimeout(function() { bannerOut(target,time); },3000);
					//wait(target, time);
				}
				setAlpha(target, alpha);
				alpha += 2;
			}, timer);
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}


