<!--
//comentar o JS para não conflitar ao validar HTML
/**
 * Controle de Banners
 * 
 * @author Rafael Ravena @gotoweb
 * @version 1.0
 * 
 * copyright 2008, Gotoweb Informática
 * 
 */

// ***************************************************************
// cria a classe SingleBanner
// ***************************************************************
function SingleBanner(url_, img_, id_){
	this.img	= img_;
	this.url	= url_;
	this.id		= id_;
}
// ***************************************************************
// cria a classe Banners
// ***************************************************************
function Banners(width_, height_, timeOut_){
	// ***********************************************************
	// propriedades privadas
	// ***********************************************************
	var wid = width_;
	var hei = height_;
	var tim = timeOut_;
	var pos = 0;
	var tempo;
	var tempoEsconde;
	var banners = new Array();
	var divRecebe = "";
	this.bannerName = "";
	function start(){
		var doc = document.getElementById(divRecebe);
		doc.style.display="block";
		//remover elemento
		try{
			var rem = document.getElementById(divRecebe+"placeHolder");
			rem.parentNode.removeChild(rem);
		}catch(ex){
		}
		//criar o conteiner do banner
		var bloco = document.createElement("div");
		bloco.setAttribute("id", divRecebe+"placeHolder");
		bloco.style.width=(wid)+"px";
		bloco.style.height=(hei)+"px";
		bloco.style.border="0px solid";
		bloco.style.margin="0px";
		bloco.style.padding="0px";
		bloco.style.display="block";
		doc.appendChild(bloco);
		//criar o conteiner da imagem
		var blocoImg = document.createElement("div");
		blocoImg.setAttribute("id", divRecebe+"placeHolderBanner");
		blocoImg.style.width=wid+"px";
		blocoImg.style.height=hei+"px";
		blocoImg.style.overflow="hidden";
		blocoImg.style.margin="0px";
		blocoImg.style.padding="0px";
		blocoImg.style.border="0px solid";
		blocoImg.style.display="block";
		bloco.appendChild(blocoImg);
		//criar link
		var aHref = document.createElement("a");
		aHref.setAttribute("target", "blank");
		aHref.setAttribute("id", divRecebe+"a");
		blocoImg.appendChild(aHref);
		//criar imagem
		var image = document.createElement("img");
		image.setAttribute("align", "center");
		image.setAttribute("id", divRecebe+"img");
		image.setAttribute("border", "0");
		aHref.appendChild(image);
		image.style.zIndex = "1000";
		//criar botão "anterior"
		var last = document.createElement("img");
		last.setAttribute("src", "imagens/last.png");
		bloco.appendChild(last);
		last.setAttribute("alt", "anterior");
		last.setAttribute("border", "0");
		last.setAttribute("id", divRecebe+"Last");
		last.style.position = "absolute";
		last.style.marginLeft = "-5px";
		last.style.marginTop = "-30px";
		last.style.display = "none";
		last.onmouseover = function(){
			window.clearTimeout(tempoEsconde);
		}
		last.onmouseout = function(){
			window.clearTimeout(tempoEsconde);
			var divParente = this.parentElement.parentElement;
			tempoEsconde = setTimeout("document.getElementById(\""+divParente.id+"Last\").style.display=\"none\";document.getElementById(\""+divParente.id+"Next\").style.display=\"none\";", 500);
		}
		last.onclick = function(){
			window.clearTimeout(tempo);
			pos-2<0?pos=banners.length+pos-2:pos-=2;
			var divParente = this.parentElement.parentElement;
			tempo = setTimeout(divParente.id+".loopar();",10);
		}
		//criar botão "próximo"
		var next = document.createElement("img");
		next.setAttribute("src", "imagens/next.png");
		bloco.appendChild(next);
		next.setAttribute("alt", "próximo");
		next.setAttribute("border", "0");
		next.setAttribute("id", divRecebe+"Next");
		next.style.position = "absolute";
		next.style.marginLeft = (wid-25)+"px";
		next.style.marginTop = last.style.marginTop;
		next.style.display = "none";
		next.onmouseover = function(){
			window.clearTimeout(tempoEsconde);
		}
		next.onmouseout = function(){
			window.clearTimeout(tempoEsconde);
			var divParente = this.parentElement.parentElement;
			tempoEsconde = setTimeout("document.getElementById(\""+divParente.id+"Last\").style.display=\"none\";document.getElementById(\""+divParente.id+"Next\").style.display=\"none\";", 500);
		}
		next.onclick = function(){
			window.clearTimeout(tempo);
			var divParente = this.parentElement.parentElement;
			tempo = setTimeout(divParente.id+".loopar();",10);
		}
	}
	function imagem(){
		var objA = document.getElementById(divRecebe+"a");
		objA.href = "banners.asp?url="+banners[pos].url+"&id="+banners[pos].id
		var obj = document.getElementById(divRecebe+"img");
		obj.src = banners[pos].img;
		obj.onmouseover = function(){
			window.clearTimeout(tempoEsconde);
			document.getElementById(divRecebe+"Last").style.display = "block";
			document.getElementById(divRecebe+"Next").style.display = "block";
		}
		obj.onmouseout = function(){
			var divParente = this.parentElement.parentElement.parentElement.parentElement;
			tempoEsconde = setTimeout("document.getElementById(\""+divParente.id+"Last\").style.display=\"none\";document.getElementById(\""+divParente.id+"Next\").style.display=\"none\";", 500);
		}
	}
	this.loopar = function(){
		window.clearTimeout(tempo);
		start();
		imagem();
		pos>=banners.length-1?pos=0:pos++;
		tempo = window.setTimeout(this.bannerName+'.loopar();', tim);
	}
	this.addBanner = function(url_, img_, id_){
		banners[banners.length] = new SingleBanner(url_, img_, id_);
	}
	this.Start = function(div){
		divRecebe = div;
		this.loopar();
	}
}
-->