//Declaração de variáveis globais
var intMargem, divTicker, mskTickerOffset=0;

/*
	Controle da velocidade do ticker NoAr
	Quanto maior, mais devagar, pois a velocidade refere-se ao refresh rate.
*/
var tkVelocidadeOut = 20;
var tkVelocidadeOver = 60;
var tkVelocidade = tkVelocidadeOut;

/*
	tkIncremnto também influencia na velocidade.
	O incremento é o número de pixels que é movimentado a cada chamada da função de mover o ticker
	Quanto maior o incremento, mais rápido.
*/
var tkIncremento = 2


function loadFlash(archive, width, height, img){	
	document.write("<object type='application/x-shockwave-flash' data='"+  archive +"' width='"+ width +"' height='"+ height +" '><param name='movie' value='"+ archive +"' /><param name='wmode' value='transparent' /><img src='" + img + "' width='"+ width +"' height='"+ height +"' alt='Destaque' /></object>");	
}//function

function PNGHack(){
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
		window.attachEvent("onload", fnLoadPngs);
	}//if
}//function

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			var src = img.src;
			var div = document.createElement("DIV");
			div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')"
			div.style.width = img.width + "px";
			div.style.height = img.height + "px";
			img.replaceNode(div);
		}//if
		img.style.visibility = "visible";
	}//for
}//function

function IniciaNoAr(){

   this.posicaoInicial = parseInt(document.getElementById("divNoAr").parentNode.style.width);
   this.intMargem = this.posicaoInicial;
   document.getElementById("divNoAr").style.marginLeft = this.posicaoInicial + "px";
   document.getElementById("divNoAr").style.visibility = "visible";
   AnimaNoAr();

}//function

/*
	Função AnimaTicker()
	Movimenta o ticker
*/
function AnimaNoAr(){

	//Verifica se já exibiu todo o texto
	
	if(parseInt(document.getElementById("divNoAr").style.marginLeft) <= (this.posicaoInicial * -1)){

		//Se sim, reposiciona o item no final da fila
		this.intMargem = this.posicaoInicial;
		document.getElementById("divNoAr").style.marginLeft = this.posicaoInicial+"px";

	}//if

	//Decrementa a margem
	this.intMargem = this.intMargem - this.tkIncremento;
	document.getElementById("divNoAr").style.marginLeft = this.intMargem+"px";

	//Aciona a função novamente no intervalo definido pela velocidade
	setTimeout(AnimaNoAr);

}//function

function UR_Start() 
{
	UR_Nu = new Date;
	
	UR_Indhold = showFilled(UR_Nu.getDate()) + "." + showString(UR_Nu.getMonth()) + "." + showFilled(UR_Nu.getYear()) + " " + showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
	document.getElementById("spanRelogio").innerHTML = UR_Indhold;
	setTimeout("UR_Start()",1000);
}

function showFilled(Value) 
{
	return (Value > 9) ? "" + Value : "0" + Value;
}

function showString(Value)
{
   var meses = new Array();
       meses[0] = "JAN";
       meses[1] = "FEV";
       meses[2] = "MAR";
       meses[3] = "ABR";
       meses[4] = "MAI";
       meses[5] = "JUN";
       meses[6] = "JUL";
       meses[7] = "AGO";
       meses[8] = "SET";
       meses[9] = "OUT";
       meses[10] = "NOV";
       meses[11] = "DEZ";
       
   return(meses[Value]);
}//function

function lightbox(pagina,largura,altura,rolagem)
{
	//alert(altura);
	//alert(largura);
    document.getElementById("contlight").innerHTML="<div style='border-bottom:5px solid #3c3c36; border-right:5px solid #3c3c36; width:" + largura + "px; height:" + altura + "px; background-color:#FFFFFF'><iframe src='"+ pagina + "' width='100%' height='100%' scrolling='auto' frameborder='no' style='border:3px solid #ffffff'></iframe><div style='background:#FFF;border-right:6px solid #FFF;padding-top:4px;padding-bottom:4px;text-align:right;width:"+largura+"'><a href='javascript:fechaLightbox();'>Fechar</a></div></div>";
	document.getElementById("contlight").style.width = largura;
	document.getElementById("contlight").style.height = altura;
	//document.getElementById("contlight").style.border = "2px solid #000000";

// Calcula tamanho do browser para atribuir ao lightebox e centralizá-lo

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ){
    // Não IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE maior que 6
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE menor que 6
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 
 //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );


// Posicionando o Flash 
    document.getElementById("contlight").style.top = (myHeight - altura)/2 +"px";
	document.getElementById("contlight").style.left = (myWidth - largura)/2 +"px";
	
	
// Corrigindo o bug do ie6

 var userAgent=navigator.userAgent, version=0;
 browser = navigator.appName;
 version = parseFloat(userAgent.substring(userAgent.indexOf('MSIE')+4,userAgent.length));
 
 // se a versão do IE for menor que 7, não existe a propriedade FIXED. assim, atribuimos uma ancora para elevar o visitante ao topo da página e atribuimos absolute ao lightbox garantindo assim a exibição.
 
	if(browser == "Microsoft Internet Explorer" && version < "7.0" ){
		document.getElementById("contlight").style.position = "absolute";
		document.getElementById("contlight").style.top = "170px";
	}
 
 // Criando a mascara escura no fundo
 // Pego o tamanho do maior div da página e faço a comparação entre ela e o tamanho do browser
 
	document.getElementById("lightbox").style.width = document.body.offsetWidth +"px";
	document.getElementById("lightboxFundo").style.width = document.body.offsetWidth + "px";

	if(document.getElementById("divGeral").offsetHeight < document.body.offsetHeight){
		document.getElementById("lightbox").style.height = document.body.offsetHeight +"px";
		document.getElementById("lightboxFundo").style.height = document.body.offsetHeight + "px";
	}else{
		document.getElementById("lightbox").style.height = document.getElementById("divGeral").offsetHeight +"px";
		document.getElementById("lightboxFundo").style.height = document.getElementById("divGeral").offsetHeight +"px";
	}//if
	// Fazendo o conteúdo aparecer
	document.getElementById("lightbox").style.display = "block";
	location.href = "#topo";
} 

function fechaLightbox(){
	parent.document.getElementById("lightbox").style.display = "none";
    parent.document.getElementById("contlight").innerHTML="&nbsp;";
}

