var i = function(id) {return document.getElementById(id);};
var xmlHttpBuilder = function() {
	var xmlHttp = null;
	try { xmlHttp = new XMLHttpRequest(); }
	catch(e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	finally { return xmlHttp; }
};

var xmlHttp = xmlHttpBuilder();

var request = function(param, response) {
		if(navigator.userAgent.indexOf("MSIE") > 0 ) {
			xmlHttp = null;
			xmlHttp = xmlHttpBuilder();
		}
		if (xmlHttp != null) {
			xmlHttp.onreadystatechange = response;
			xmlHttp.open("POST", "/backbone/index.php", true);
			xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
			xmlHttp.send(param);
		}
};
var done = function() {			
		return (((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) ? true : false);			
};
var addEvent = function(el, event, func) {
	if (el.addEventListener){
		el.addEventListener(event, func, false); 
	} else if (el.attachEvent) {
		el.attachEvent('on' + event, func);
	}
};
var nothing = function() {};

function capturaPop(pop){
	request("ajax=1&pop=" + pop , capturaPopCB);	
}

capturaPopCB =  function() {
		if (done()) {	 		
	 		eval(xmlHttp.responseText);
	 		
	 		if (!jsonResponse.erro){
	 			var tds = i('backbone').parentNode.parentNode.getElementsByTagName('td'); 
	 			//Informacoees do pop (Coluna de Navegacao)
	 			var tdnav = tds[2];
				var html = tdnav.innerHTML;
				var pos = (html.indexOf('<hr') >= 0 ? html.indexOf('<hr') : html.indexOf('<HR'));
				html = html.substring(pos + 1,html.length-1);
				pos = (html.indexOf('<hr') >= 0 ? html.indexOf('<hr') : html.indexOf('<HR'));
				html = html.substring(pos,html.length-1);
				tdnav.innerHTML = jsonResponse.nav + "" +html;			
				
				//Informacoes extras (Coluna central)
				var tconteudo = i('x_content');
				tconteudo.innerHTML = jsonResponse.conteudo;				
				
	 		}
	 			 		
		}
}