// JavaScript Document
function resizeMe(obj){
	docHeight = stats.document.body.scrollHeight
	obj.style.height = docHeight + 0 + 'px'
}
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) 
}

var timer;
function bodyOverlay(conteudo) {
	  var objBody = document.getElementsByTagName('body').item(0);
	  var sizesPage = getPageSize();
	  var bodyOverlay = document.createElement("div");
	  bodyOverlay.setAttribute('id','bodyOverlay');
	  if (conteudo != null){
		  bodyOverlay.innerHTML = conteudo;
	  }
	  bodyOverlay.style.height = arrayPageSize[1] + 'px'; // fundo com o tamanho total da página.
	  if (!document.getElementById('bodyOverlay')) {
		    objBody.insertBefore(bodyOverlay, objBody.firstChild);
	  }
	  /**
	   * Acrescentei isto aqui apenas para chamar a função removerOverlay
	   */
	//timer = window.setInterval('removerOverlay()',3000);
}

function removerOverlay() {
	/**
	 * Acrescentei este alerta apenas para avisar que esta função foi chamada
	 */
//	 alert('Estou chamando a função removerOverlay() para removermos este overlay sobre o body.');
//	 clearInterval(timer);
	 
	  var bodyOverlay = document.getElementById('bodyOverlay');
	  if (bodyOverlay) {
		    bodyOverlay.parentNode.removeChild(bodyOverlay);
			document.getElementById('foto_galeria').style.display = 'none';
			document.getElementById('foto_galeria').innerHTML = "";			
	  }
}
function carregar_foto(foto){
	bodyOverlay("");
	document.getElementById('foto_galeria').style.display = 'block';
	document.getElementById('foto_galeria').innerHTML = "<table border='0' align='center' cellpadding='2' cellspacing='0'><tr><td align='right'><img src='img_index/fechar.gif' alt='Fechar' width='20' height='18' onclick='javascript: removerOverlay();' style='cursor:hand;' /></td></tr><tr><td><img src='"+foto+"' class='Foto' /></td></tr></table>";

}
function abre_site(width, height, nome,barra) {
   var top; var left; 
   if (barra == "") {
   		barra = 0;
   }
  top = 10;
  left = ( (screen.width/2) - (width/2) )
	window.open(nome, "","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=1,width="+width+",height="+height+",left="+left+",top="+top);
}
function _login(frm){
	if(frm.usuario.value == ""){
		alert('Favor informar Usuário!');
		frm.usuario.focus();
		return false;
	} else if(frm.senha.value == ""){
		alert('Favor informar Senha!');
		frm.senha.focus();
		return false;
	}
}
