var speed = 150 
var pause = 3000
var timerID = null
var bannerRunning = false
var ar = new Array()

ar[0] = "MATURA"
ar[1] = "MOVIMENTO DE APOIO AO TURISMO DO OESTE PAULISTA"

var currentMessage = 0
var offset = 0

function stopBanner() 
{

  if (bannerRunning)
  clearTimeout(timerID)
  bannerRunning = false
}

function startBanner()
{
  stopBanner()
  showBanner()
}

function showBanner()
{
  var text = ar[currentMessage]
  if (offset < text.length)
  {
    if (text.charAt(offset) == " ")
    offset++ 
    var partialMessage = text.substring(0, offset + 1) 
    window.status = partialMessage
    offset++ // IE sometimes has trouble with "++offset"
    timerID = setTimeout("showBanner()", speed)
    bannerRunning = true
  } 
  else
  {
    offset = 0
    currentMessage++
	if (currentMessage == ar.length)
      currentMessage = 0
    timerID = setTimeout("showBanner()", pause)
    bannerRunning = true
  }
}

//startBanner();



function carregaFundo()
{
  bod = document.getElementsByTagName('body').item(0);
  ndiv = document.createElement('div');
  ndiv.setAttribute('id','fJanela');
  ndiv.style.position = 'absolute';
  pg = getPageSize();
  ndiv.style.top='0px'; 
  ndiv.style.left='0px'; 
  ndiv.style.width=pg[0];
  ndiv.style.height=pg[1];
  ndiv.style.backgroundColor='#000000';
  ndiv.style.filter="alpha(opacity=50)";
  ndiv.style.opacity="0.5";
  bod.appendChild(ndiv);
}

function criajanela(pag,tit)
{
//  alert(pag);
  frm = document.getElementById('frmcar');
  frm.src = 'janela.php?pag='+pag+'&titulo='+tit;
}

function criafigura(fig)
{
  im = new Image();
  im.src = fig;
  s = '<table border="0" cellpadding="0" cellspacing="0" width="'+im.width+'"';
  s += '      style="border:1px solid #000000;padding:10px;background:#FFFFFF">';

  s += '<tr>';
  s += '<td align="right"><a href="javascript:removeJanela()">X</a></td>';  
  s += '</tr>';
  
  s += '<tr>';
  s += '<td>';
  s += '<img src="'+fig+'" border="0" onclick="removeJanela()" alt="clique aki pra fechar">';
  s += '</td>';  
  s += '</tr>';

  s += '</table>';
  carregajanela(s);
}

function carregajanela(txt)
{
  carregaFundo();
  bod = document.getElementsByTagName('body').item(0);
  div = document.createElement('div');
  div.innerHTML = txt;
  div.style.position = 'absolute';
  div.setAttribute('id','dJanela');
  pg = getPageSize();
  bod.appendChild(div);
  div.style.top = (pg[3] / 2) + document.body.scrollTop - (div.offsetHeight / 2);
  div.style.left = (pg[0] / 2) - (div.offsetWidth / 2);
}

function trocafig(im,num)
{
  if (num == 1)
    im.src = 'caixa/fechard.gif';
  else
    im.src = 'caixa/fechare.gif';
}

function removeJanela()
{
  if (document.getElementById('dJanela'))
  { 
	bod = document.getElementsByTagName('body').item(0);
	div = document.getElementById('dJanela');
	ndiv = document.getElementById('fJanela');
	bod.removeChild(div);  
	bod.removeChild(ndiv);  
  }
}

function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
//	if(yScroll < windowHeight){
//		pageHeight = windowHeight;
//	} else { 
		pageHeight = yScroll;
//	}

	// for small pages with total width less then width of the viewport
//	if(xScroll < windowWidth){	
//		pageWidth = windowWidth;
//	} else {
		pageWidth = xScroll;
//	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}
