// JavaScript Document

// função para saber se o navegador suporta o XMLHTTP
function openAjax() {
	var ajax;
	try {
		ajax = new XMLHttpRequest();
	} catch(ee) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				ajax = false;
			}
		}
	}
	return ajax;
}

window.onload = loadFunctions;

 function loadFunctions() {
                aumentaFundoCinza();
				aumentaFundo();	
            }


// Utilizada para evitar digitar o document.getElementById
function gE(ID){
	return document.getElementById(ID);
}

// Utilizada para evitar digitar o document.getElementsByTagName
function gEs(tag) {
	return document.getElementsByTagName(tag);
}

/* Funções de terceiros */
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//

function aumentaFundoCinza(){
	var div = gE('popFundo');
	
	if (div){
		var tamPag = getPageSize();
		var width = arrayPageSize[0];
		var height = arrayPageSize[1];
		
		div.style.width = width + 'px';
		div.style.height = height + '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) 
}



// Função que valida o e-mail informado
function validaEmail(email){
	return email.search(/(\w[\w\.\+]+)@(.+)\.(\w+)$/)==0;
}


/* função para alterar o tamanho das fontes */
	var tam = 11;
	var lin = 1.5;
	function alterarTamanhoFonte(tipo, onde){
		
		var minimo = 7;
		var maximo = 20;
		vardomElement = gE(onde);
												  
		if( tipo == 'mais' ){
			if( tam < 16 ) tam += 2;
		}
		else{
			if( tam > 9 ) tam -= 2 ;
		}
		
		mudaFonte(tipo , document.getElementById(onde)) ;     
	}
	
	
	function mudaFonte( tipo , idM ){		
	  for( var i = 0 ; i < idM.childNodes.length ; i++ ){
		mudaFonte( tipo , idM.childNodes.item( i )  );
	  }
	  if( idM.style )
		idM.style.fontSize = tam+'px';
	}
	
/* função destinada a aumentar as lateria colocando um fundo branco na pagina */
function aumentaFundo(){
	var conteudo = gE('geral1');
	var rodape = gE('rodape');
	
	var tamPag = getPageSize();
	
	if (arrayPageSize[0] > 900){
		conteudo.style.width = '850px';
		rodape.style.width = '850px';
	}else{
		conteudo.style.width = '779px';
		rodape.style.width = '779px';
	}
}	
	
	
	// função para abrir pop-Up
	function abrePopUp(url, id, largura, altura){
		window.open(url, id, 'width='+largura+', height='+altura+', scrollbars=no');
	}