
function XMLHTTPRequest() { 
	var http = 0;
	if (window.XMLHttpRequest) {
		http = new XMLHttpRequest();
	} else {
		try { 
			http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try { 
			http = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) { 
				http = false; 
			} 
		}
	} 
	return http; 
}

function mostrar_pagina(url, div) {
	var http = XMLHTTPRequest();
	if (http) {
		http.onreadystatechange = function() {
			if (http.readyState == 4) {
				if (http.status == 200) {
					var retorno = unescape(http.responseText.replace(/\+/g," "));
					document.getElementById(div).innerHTML = retorno
				} else {
					//alert('There was a problem with the request.');
				}
			}		
		}
		http.open('GET', url, true);
		http.send(null);
	}
	else {
		//alert('Erro seu navegador nao suporta ajax');
	}
}	

function addEvent(obj, evType, fn) {
	if (typeof obj == "string") {
		if (null == (obj = $(obj))) {
			throw new Error("Cannot add event listener: HTML Element not found.");
		}
	}
	if (obj.attachEvent) {
		return obj.attachEvent(("on" + evType), fn);
	} else if (obj.addEventListener) {
		return obj.addEventListener(evType, fn, true);
	} else {
		throw new Error("Your browser doesn't support event listeners.");
	}
}

function iniciar() {	

var items = [], allItems = document.getElementsByTagName("li");
	
for (var i = 0; i < allItems.length; i++) {				
	allItems[i].onclick = function() {	
		for (var item = this.parentNode.firstChild; item; item = item.nextSibling) {		
			item.className = 'normal';			
		}
		this.className = 'current';				
		var padrao = /(<span(.*?)>(.*?)<\/span>)/i;	
		var pagina = this.innerHTML.replace(padrao, "$3");	
		var url = 'modules/abahome/receber.php?pagina=' + pagina;						
		mostrar_pagina(url, 'conteudo');						
		document.title = pagina;		
	}				
}	

var aba = document.getElementsByTagName("span");

	for (var j = 0; j < aba.length; j++) {		
		aba[j].onmouseover = function() {		
			if(this.className != 'link'){					
				this.className = 'link';
			} 	
		}		
		aba[j].onmouseout = function() {	
			if(this.className != 'normal'){		
				this.className = 'normal';
			} 	
		}
	}	
}

// quando terminar o carregamento da página, executa a "iniciarMudancaDeEnterPorTab"
addEvent(window, "load", iniciar);

