//Inicio Script POP-DHTML
var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var navegador_width = null;
var direcao = null;

function ap(){
	document.getElementById('pub').style.visibility="hidden";
}
function fechar(){
	//clearTimeout(tempo);	
	document.getElementById('pub').style.visibility="hidden";
	criarCookie('fecha',1,1);
}

function fechar_dhtml(){
	clearTimeout(tempo);	
	document.getElementById('pub').style.visibility="hidden";
	criarCookie('fecha',1,1);
}

function abrirsite(url){
	clearTimeout(tempo);	
	document.getElementById('pub').style.visibility="hidden";
	janela = window.open(url,'popup','');
}

function anima(tag){
	if (ie||w3)
	{
		navegador_width = document.body.offsetWidth -250 ;
	}
	else
	{
		navegador_width = window.outerWidth ;
		}

	mover(tag);
}

function mover(tag)
{

	var obj = document.getElementById('pub');
	
	if(tag){
		direcao = 1;
		obj.style.left = parseInt(obj.style.left)+1+'px';
	}
	else{
		direcao = 0;
		obj.style.left = parseInt(obj.style.left)-1+'px';
	}

  	tempo = setTimeout("mover("+tag+")",15);
	if ( parseInt(obj.style.left) == navegador_width ){
		clearTimeout(tempo);	
		anima(0);
	}
		
	if ( parseInt(obj.style.left) == -250 )
	{
		criarCookie('fecha',1,1);
		clearTimeout(tempo);	
	}	
	
}


function parar(tag)
{
		if (tag){
			clearTimeout(tempo);
		}	
		else {
			tempo = setTimeout("mover("+direcao+")",15);
		}

}

function mostra()
{
	if (!lerCookie('fecha'))
	{	
		document.getElementById('pub').style.visibility="visible";
		tempo = setTimeout("fechar_dhtml()",18000);
		//document.getElementById('pub').style.left = '-200px';		
		//anima(1);
		}
}

function initdhtml(){
	tempo = setTimeout("mostra()",1000);
}


function criarCookie(nome,valor,dias) {
	if (dias) {
		var date = new Date();
		date.setTime(date.getTime()+(dias*24*60*60*1000));
		var expirar = "; expires="+date.toGMTString();
	}
	else var expirar = "";
	document.cookie = nome+"="+valor+expirar+"; path=/";

}

function lerCookie(nome) {
	var nameEQ = nome + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

window.onload = initdhtml;