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 && http.status == 200) {
				var retorno = unescape(http.responseText.replace(/\+/g," "));
				document.getElementById(div).innerHTML = retorno
			}
		}
		http.open('GET', url, true);
		http.send(null);
	} else {
		alert('Erro seu navegador nao suporta ajax');
	}
}

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';
				//alert(item.value)
			}
			this.className = 'current';
			pagina = this.value;
			//var padrao = /(<span(.*?)>(.*?)<\/span>)/i;
			//var pagina = this.innerHTML.replace(padrao, "$3");
			// Posso fixar aqui a pagina na mao, ja que vai ser sempre a mesma
			// mas mesmo assim, preciso obter parametro pra passar pra consulta
			mostrar_pagina('receber.php?pagina=' + pagina, 'conteudo_aba');
			//document.title = pagina;
		}
	}

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

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

function iniciar2(cat, prox, sinal) {
	mostrar_pagina('receber.php?pagina=' + cat + '&next=' + prox + '&sinal=' + sinal, 'conteudo_aba');
}

$(document).ready(function() {
	iniciar();
	mostrar_pagina('receber.php?pagina=27', 'conteudo_aba');
});

