var pagina_inicial = false;

function popups(nome, posX, posY, dia_expira, mes_expira, ano_expira, pg_inicial)
{
	this.nome  = nome;
	this.posX  = posX;
	this.posY  = posY;
	this.ativo = true;
	this.pg_inicial = pg_inicial;

	var ns = navigator.appName == "Netscape";
	ano_aux = 0;
	if (ns)
		ano_aux = 1900;

	hoje = new Date();
	dia  = hoje.getDate();
	mes  = hoje.getMonth()+1;
	ano  = hoje.getYear() + ano_aux;
	
	if (((dia_expira == 0 || mes_expira == 0 || ano_expira == 0) && (pg_inicial == pagina_inicial)) || pg_inicial == null)
		 this.ativo = true;
	else
	{
		if (new Date(ano, mes, dia) >= new Date(ano_expira, mes_expira, dia_expira))
			this.ativo = false;
		else
		{
			if ((pg_inicial == pagina_inicial) || (pg_inicial == null))
				this.ativo = true;
			else
				this.ativo = false;
		}
	}
}	

function getObject(nome_popup)
{
	var ns = navigator.appName == "Netscape";
	var ns4 = (ns && parseInt(navigator.appVersion) == 4);
	var ns5 = (ns && parseInt(navigator.appVersion) > 4); 

	if (ns4)
	   tDiv = document[nome_popup];
	else if (ns5)
	   tDiv = document.getElementById(nome_popup)
	else
	  tDiv = document.all[nome_popup];
	  
	return tDiv;
}

function atualizarPosicaoPopups(arr)
{
	for (i=0;i<arr.length;i++)
	{
		if (arr[i].ativo)
		{
			MostrarDIV(getObject(arr[i].nome));
			atualizarPosicaoPopup(arr[i].nome, arr[i].posX, arr[i].posY);
		}
		else
			esconder(arr[i].nome);
	}
}

function atualizarPosicaoPopup(nome_popup, posX, posY)
{
	tDiv = getObject(nome_popup);	  
	tDiv.style.top = posY;
	largura = document.body.offsetWidth;

	if (largura < 780)
		pedaco = 0;
	else
		pedaco = (largura-780)/2;
	
	tDiv.style.left = pedaco + posX;
}


//Função que põe cor na TR (linha) dos anúncios
function MouseOver(obj)
{
	obj.style.background = "#BCF5AB";
	obj.style.cursor = "hand";
	obj.style.color = "#FF0000";
}

//Função que retira a cor da TR (linha) dos anúncios
function MouseOut(obj)
{
	obj.style.background = "#FFFFFF";	
	obj.style.color = "#000000";
}

function MouseOut(obj, cor)
{
	obj.style.background = cor;
}

function MostrarDIV(layer)
{
	layer.style.visibility = 'visible';
}

function esconder(obj)
{
	obj_aux = getObject(obj);
    obj_aux.style.visibility='hidden';
}



