// JavaScript Document
function AreaTotal(){
	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){ // todos menos Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...funcionaria tb no Explorer 6 modo Strict, Mozilla e Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// todos menos Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 modo Strict 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // outros Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	if (yScroll < windowHeight){
		AlturaTotal = windowHeight;
	} else {
		AlturaTotal = yScroll;
	}
	if (xScroll < windowWidth){
		LarguraTotal = windowWidth;
	} else {
		LarguraTotal = xScroll;
	}

	return [LarguraTotal,AlturaTotal,windowWidth,windowHeight];
}

function Overlay(uri,lang) {
	var w = 400;
	var h = 400;
	var objBody = document.getElementsByTagName('body').item(0);
	var Area = AreaTotal();
	var Largura = Area[0];
	var Altura = Area[1];
	var LarguraTela = Area[2];
	var AlturaTela = Area[3];
	var bodyOverlay = document.createElement("div");
	bodyOverlay.setAttribute('id','bodyOverlay');
	bodyOverlay.style.height = Altura + 'px'; // fundo com o tamanho total da página.
	if (!document.getElementById('bodyOverlay')) {
		objBody.insertBefore(bodyOverlay, objBody.firstChild);
	}
	var bed = document.createElement("div");
	bed.setAttribute('id','bedOverlay');
	bed.style.width = '100%';
	bed.style.height = Altura + 'px';
	bed.style.top = ((AlturaTela/2)-(h/2)) + "px";
	bed.style.left = ((LarguraTela/2)-(w/2)) + "px";
	objBody.insertBefore(bed, objBody.firstChild);
	
	var imagem = document.createElement("img");
	imagem.setAttribute('id','imgOverlay');
	imagem.setAttribute('src',uri);
	bed.appendChild(imagem);
	
	var fechar = document.createElement("a");
	fechar.setAttribute('id','fechar');
	if (lang==1) fechar.innerHTML = "fechar"; 
	else if (lang==3) fechar.innerHTML = "cerrar"; 
	else fechar.innerHTML = "close"; 
	fechar.setAttribute('href','javascript:removerOverlay()');
	fechar.style.width = (w-10) + "px";
	bed.appendChild(fechar);
}
function Overlayen(uri){
	Overlay(uri);
	fechar.innerHTML = "close";
}
function removerOverlay() {
	var bodyOverlay = document.getElementById('bodyOverlay');
	if (bodyOverlay) {
		bodyOverlay.parentNode.removeChild(bodyOverlay);
	}
	document.getElementById('bedOverlay').parentNode.removeChild(document.getElementById('bedOverlay'));
}
function Menu(uri,acao){
	var a = "";
	if (acao==1) a = "_hover";
	document.getElementById("menu_"+uri).src = "imagens/menu_"+uri+a+".gif";
}
function Valida(){
	if (document.getElementById('nome').value==""){
		alert("Preencha o seu nome no formulario");
		return false;
	} else if (document.getElementById('email').value==""){
		alert("Preencha o seu e-mail no formulario");
		return false;
	} else {
		return true;
	}
}
function Validate(){
	if (document.getElementById('nome').value==""){
		alert("Fill your name at the form");
		return false;
	} else if (document.getElementById('email').value==""){
		alert("Fill your e-mail adress at the form");
		return false;
	} else {
		return true;
	}
}
function tela(){
	var x,y;
	if (self.innerHeight){
		x = self.innerWidth;
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight){
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	} else if (document.body){
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	var ret = Array(x,y);
	return ret;
}
function SubmenuPopup(){
	if (document.getElementById("submenupopup").style.display == "none"){
		document.getElementById("submenupopup").style.display = "block";
	} else {
		document.getElementById("submenupopup").style.display = "none";
	}
}

