function show(item){
	document.getElementById("cat"+item).style.visibility = 'visible';
}


function hidde(item){
	document.getElementById("cat"+item).style.visibility = 'hidden';
}

function obterRequest() {
	//Obtêm requisição idenpendente do navegador.
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, e IEs novos(IE7>=).
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
        	http_request.overrideMimeType('text/xml');

	} else if (window.ActiveXObject) { // IE(antigos)
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	
	if (!http_request) {
		alert('Não foi possivel criar instância de XMLHTTP no navegador utilizado.');
		return false;
	}
	
	return http_request;
}

request = null;

function obterInserirTopo() {
	request = obterRequest();
	request.open("GET", "topo.jsp", false);
	request.onreadystatechange = writeTopo;
	request.send(null);	
}

function writeTopo() {
	if (request.readyState == 4) {
		if (request.status == 200) {
			var response = request.responseText;
			document.write(response);
		}
	}
}

function obterInserirRodape() {
	/*request = obterRequest();
	request.open("POST", "modeloDiv.xml", false);
	request.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=iso-8859-1");
	request.onreadystatechange = writeRodape;
	request.send(null);*/
	/*
	request = obterRequest();
	request.open("GET", "modeloDiv.xml", false);
	request.onreadystatechange = writeRodape;
	request.send(null);
	*/
	request = obterRequest();
	request.open("GET", "rodape.jsp", false); //Terceiro parâmetro fala se vai ser assincrono ou sincrono. Se vai carregar ou não outros conteúdos enquanto o ajax estiver processando.
	request.onreadystatechange = writeRodape;
	request.send(null);
	
}

function writeRodape() {
	/*if (request.readyState == 4) {
		if (request.status == 200) {
			var xmldoc = request.responseXML;
			var root_node = xmldoc.getElementsByTagName('ratings').item(0);
			alert(root_node.innerHTML);
			alert(root_node.firstChild.data);
		} else {
			alert('There was a problem with the request.');
		}
	}*/
	if (request.readyState == 4) {
		if (request.status == 200) {
			var response = request.responseText;
			document.write(response);
		}
	}
	
}

//Busca um único elemento DOM, conforme parâmetros passado.
	function buscarElemento(root,tipo) {		
		var elemento = null;
		for(var i=0;i<root.childNodes.length;i++) {					
			if(root.childNodes[i].nodeType==1) {			
				if(root.childNodes[i].nodeName==tipo.toUpperCase()) {								
					return root.childNodes[i];
				}
				elemento = buscarElemento(root.childNodes[i],tipo);
				if(elemento != null)
					return elemento;
			}
		}
		return null;
	}

var widthPopup = 650;
var heightPopup = 485;
	
function popUpCenter(url, x, y) {
	if(x==null || y==null) {
		x=widthPopup;
		y=heightPopup;
	}
	
	var winl = (screen.width - x) / 2;
	var wint = (screen.height - y) / 2;
		
	param = 'scrollbars=0,menubar=0,location=0,resizable=1,toolbar=0,status=1,modal=yes,width=' + x;
	param += ',height=' + y + ',top=' + wint + ',left=' + winl;
	var win = window.open(url, 'popup', param);
	document.janelaPopup=win;
}

function popUpCenterPublicidade(url, x, y) {
	if(x==null || y==null) {
		x=widthPopup;
		y=heightPopup;
	}
	
	var winl = (screen.width - x) / 2;
	var wint = (screen.height - y) / 2;
		
	param = 'scrollbars=0,menubar=0,location=0,resizable=0,toolbar=0,status=0,modal=yes,width=' + x;
	param += ',height=' + y + ',top=' + wint + ',left=' + winl;
	var win = window.open(url, 'popup', param);
	document.janelaPopup=win;
	try {
		//win.focus();
	} catch(e) {}
}

function BuscaElementosForm(idForm) {
	var elementosFormulario = document.getElementById(idForm).elements;
	var qtdElementos = elementosFormulario.length;
	var queryString = "";    var elemento;    
	//Cria uma funcao interna para concatenar os elementos do form    
	this.ConcatenaElemento = function(nome,valor) {
		if (queryString.length>0) {
			queryString += "&";
		}
		queryString += encodeURIComponent(nome) + "=" + encodeURIComponent(valor);
	};
	//Loop para percorrer todos os elementos
	for (var i=0; i<qtdElementos; i++) {
		//Pega o elemento
		elemento = elementosFormulario[i];
		if (!elemento.disabled) {
			//Trabalha com o elemento caso ele nao esteja desabilitado
			switch(elemento.type) {
				//Realiza a acao dependendo do tipo de elemento
				case 'text': case 'password': case 'hidden': case 'textarea':
					this.ConcatenaElemento(elemento.name,elemento.value);
					break;
				case 'select-one':
					if (elemento.selectedIndex>=0) {
						this.ConcatenaElemento(elemento.name,elemento.options[elemento.selectedIndex].value);
					}
					break;
				case 'select-multiple':
					for (var j=0; j<elemento.options.length; j++) {
						if (elemento.options[j].selected) {
							this.ConcatenaElemento(elemento.name,elemento.options[j].value);
						}
					}
					break;
				case 'checkbox': case 'radio':
					if (elemento.checked) {
						this.ConcatenaElemento(elemento.name,elemento.value);
					}
					break;
				}
			}
		}
	return queryString;
}

// FUNCOES DOM
function addEvent(obj,type,fn){
	if(obj.addEventListener)obj.addEventListener(type,fn,true)
	if(obj.attachEvent)obj.attachEvent("on"+type,fn)
}

// Funcao Mover Banner Lateral
desabilitarMoverBannerLateral = false;
function moverBannerLateral(obj,x,y,delay) {
	if(desabilitarMoverBannerLateral)
		return;
	
	var noIMG = document.getElementById("idIMGBannerLateral");
	noIMG.src = "img/bannersLateral/bannerLateral17.jpg";
	var url = "http://www.damasiogoiania.com.br/dg/boletins/boletim70.htm";
	//noIMG.onclick = function() {document.location = url;};
	//noIMG.style.cursor="pointer";
	noIMG.onclick = function() {window.open(url)};
	noIMG.style.cursor="hand";
			
	var resol = screen.width;
	if (resol > 800){
		var obj = "idBannerLateral";		
		var x = 772;
		var y = 5;
		var delay = 10;
		var startX = x;
		startY = y ;
		if(document.getElementById(obj) == null)
			return;		
		function getObjXY(id) {
			var el = document.getElementById(id);
			el.sP = function(x,y){this.style.left=x;this.style.top=y;};
			el.x = startX;
			el.y = startY;
			return el;
		}
		window.setObjXY = function() {
			var positionY = document.body.scrollTop;
			fltObj.y += (positionY + startY - fltObj.y)/8;
			fltObj.sP(fltObj.x, fltObj.y);
			setTimeout("setObjXY()",delay);
		}
		fltObj = getObjXY(obj);
		setObjXY();
		setTimeout(function(){document.getElementById(obj).style.display='';},20);
	}
}

addEvent(window,"load",moverBannerLateral);