var req;
var divmaxx;
var divbr;
function loadXMLDoc(url) {
	req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true); 
		req.send(null);
	
	} else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP.4.0");
			} catch(e) {
			try {
			req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
			} catch(e) {
			try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
			try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
			req = false;
			}
		}
	}
}
	if (req) {
		 req.onreadystatechange = processReqChange;
		 req.open("GET", url, true);
		 req.send();
		}
	}
}

function processReqChange(){
			
	if (req.readyState == 4) {
		if (req.status == 200) {		
			document.getElementById(divbr).innerHTML = req.responseText;		
		} else {
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
			document.getElementById(divbr).innerHTML = "Houve um problema ao obter os dados:\n" + req.statusText;
			//loadXMLDoc("principal.php");
		}
	}
}

function links(codigo,divk) {
	divbr = divk;
	if (codigo == '1') {
		loadXMLDoc("principal.php? " + Math.ceil ( Math.random() * 100000 ) + "");
	} 
	
	if (codigo == '2') {
		loadXMLDoc("empresa.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '3') {
		loadXMLDoc("servicos.php? " + Math.ceil ( Math.random() * 100000 ) + "");
	}
	
	if (codigo == '4') {
		loadXMLDoc("clientes.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '5') {
		loadXMLDoc("produtos.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '6') {
		loadXMLDoc("contatos.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}

document.getElementById("divlink").background = 'green';
document.getElementById(divbr).innerHTML = 'Aguarde, informa&#231;&#245;es...';

}

function carregaServicos(codigo,divk) {
	divbr = divk;
	if (codigo == '1') {
		loadXMLDoc("administracao.php? " + Math.ceil ( Math.random() * 100000 ) + "");
	} 
	
	if (codigo == '2') {
		loadXMLDoc("analise.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '3') {
		loadXMLDoc("desenvolvimento.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '4') {
		loadXMLDoc("manutencao.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '5') {
		loadXMLDoc("treinamento.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	document.getElementById("divlinkServicos").background = 'green';
	document.getElementById("divlinkServicos").innerHTML = 'Aguarde, informa&#231;&#245;es...';
}

function carregaCadastro(codigo,divk) {
	divbr = divk;
	if (codigo == '1') {
		loadXMLDoc("cadastroContato.php? " + Math.ceil ( Math.random() * 100000 ) + "");
	} 
	
	if (codigo == '2') {
		loadXMLDoc("analise.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '3') {
		loadXMLDoc("desenvolvimento.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '4') {
		loadXMLDoc("manutencao.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	if (codigo == '5') {
		loadXMLDoc("treinamento.php? " + Math.ceil ( Math.random() * 100000 ) + "");	
	}
	
	document.getElementById("divlinkCadastro").background = 'green';
	document.getElementById("divlinkCadastro").innerHTML = 'Aguarde, Enviando Informa&#231;&#245;es';
}