var jump = 1;
var init = 0;
var end = 6;
var control = false;
var ajax_not;

function noticias() {
	ajax_not = new ajax();
	ajax_not.open('POST', './cadastro@smacom.com.br==', true);
	ajax_not.setRequestHeader('Content-Type', "application/x-www-form-_urlencoded; charset=iso-8859-1");
	ajax_not.send(null);
	control = true;
	ajax_not.onreadystatechange = __noticias;

}

function __noticias() {
		if (ajax_not.readyState == 4) {
			if (ajax_not.status == 200) {
				var response = ajax_not.responseXML.documentElement;
				nivel = ajax_not.responseXML.getElementsByTagName("item");
				_noticias();
				setTimeout("__noticias()", 5000);
			} else
				document.getElementById('noticia').innerHTML = 'There was a problem with the request: ' + ajax_not.statusText;
		}
}
function _noticias(){
		out = "";
		for (var h = init; h < end; h++)
			out += '<a class=link href='+nivel[h].getElementsByTagName('link')[0].firstChild.nodeValue + ' target=about:_blank ><img src="./images/seta.gif" border=0> '+nivel[h].getElementsByTagName('title')[0].firstChild.nodeValue+'</a><hr />';
		document.getElementById('noticia').innerHTML = out;

		if(end == nivel.length){
			init = 0;
			end = 6;
		}else{
			init = init + jump;
			end = end + jump;
		}
}

function solucoes() {
	ajax_sol = new ajax();
    ajax_sol.open('POST', './xml/solucoes.xml.php', true);
	ajax_sol.setRequestHeader('Content-Type', "application/x-www-form-_urlencoded; charset=iso-8859-1");
    ajax_sol.send(null);
    
	ajax_sol.onreadystatechange = function(){
		if (ajax_sol.readyState == 4) {
			if (ajax_sol.status == 200) {
				var response = ajax_sol.responseXML.documentElement;
				nivel = ajax_sol.responseXML.getElementsByTagName("solucao");
				out = "";
				for (var h = 0; h < 5; h++)
					out += '<a class=link href=institucional.php?i=' + nivel[h].getElementsByTagName('id')[0].firstChild.nodeValue + '><img src="./images/seta.gif" border=0> '+ nivel[h].getElementsByTagName('titulo')[0].firstChild.nodeValue +' </a><hr />';

				document.getElementById('solucoes').innerHTML = out;
			} else
				document.getElementById('solucoes').innerHTML = 'There was a problem with the request: ' + ajax_sol.statusText;
		}
	}
}

function insere_visitantes(){
	ajax_iv = new ajax();
    ajax_iv.open('POST', './xml/inserevisitante.xml.php', true);
	ajax_iv.setRequestHeader('Content-Type', "application/x-www-form-_urlencoded; charset=iso-8859-1");
    ajax_iv.send(null);
}

