function getHTTPObject()
{
	if(window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	else
	if(window.ActiveXObject)
	{
		var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
		
		for(var i = 0; i < prefixes.length; i++)
		{
			try
			{
				return new ActiveXObject(prefixes[i] + ".XMLHTTP");
			} catch (e) { alert("Seu browser n�o suporta AJAX!"); }
		}
	}
}

function consultar(campo){
	codigo = campo;
	ajax = getHTTPObject();	
	ajax.onreadystatechange = processChange;
  ajax.open('POST', 'codigos/noticias_div_xml.php?codigo='+codigo, true);
  // xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   //xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	//ajax.open('POST', 'codigos/noticias_div_xml.php', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	//ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	ajax.setRequestHeader("Pragma", "no-cache");
	ajax.send(1);
        
       // document.getElementById('menu').innerHTML += codigo +;
//alert("deu");

}

function processChange() 
{
		var xmlobj = ajax.responseText;
		if (xmlobj){
		         // document.getElementById('p'+i).innerHTML +='';
                   document.getElementById('centro').innerHTML = xmlobj;
                 // document.getElementById('p'+i).innerHTML ="<a href='index.php?pagina="+codiNoticia+"'>"+titiNoticia+"</a>";
                 //alert('foram encontradas'+xmlobj);
                  
				  }
				  //else alert('nao');
//alert('foram encontradas '+codNoticia.length);
//document.write(""+fotos);
}


/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="no" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("left").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="left_side") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate


//scrool elieber
var ancho = 520 //anchura del cuadro
var alto = 320 //altura del cuadro
var marco = 0 //0 para que notenga marco (borde)
var fondo = '#FFFFFF' //color de fondo del cuadro
var pausilla = 5000 //tiempo de la pausa en milisegundos (2000 = 2 segundos)
var cursor = "default;" //cursor que se quiera sobre el cuadro

//no tocar el c�digo a partir de aqu�
var det = true;
function escribe(){
document.write ('<div id="mami" style="width:' + ancho + 'px; height:' + alto + 'px; position:relative;  overflow:hidden; margin-left: auto; margin-right: auto;padding: 1px 1px">')
document.write('<table style="background-color:' + fondo + '; border: ' + marco + 'px solid #666666; width: ' + ancho + 'px; height: 100%"><tr><td style="vertical-align: top; ">')
document.write ('<div id="uno" style="top:' + alto +'px; width:' + ancho + 'px; height:' + alto + 'px;  ">')
document.write (noticias[0])
document.write ('</div>')
document.write ('<div id="dos" style="top:' + (alto) +'px; width:' + ancho + 'px; height:' + alto + 'px; ">')
document.write (noticias[0])
document.write ('</div>')
document.write('</td></tr></table>')
document.write ('</div>')
if(navigator.appName == "Netscape")
{altoUno = document.getElementById('uno').offsetHeight}
else
{altoUno = document.getElementById('uno').clientHeight}
document.getElementById('uno').onmouseover =function(){
	det = true;
	}
document.getElementById('uno').onmouseout =function(){
	det = false;
	clearTimeout(tiempo)
	escrolea()
	}
document.getElementById('dos').onmouseover =function(){
	det = true;
	}
document.getElementById('dos').onmouseout =function(){
	det = false;
	clearTimeout(tiempo)
	 escrolea()
	 }
}
desp = 1
var cont = 0
var pos,pos2
function escrolea(){
pos = document.getElementById('uno').style.top
pos = pos.replace(/px/,"");
pos = pos.replace(/pt/,"");
pos = new Number(pos);
pos2 = document.getElementById('dos').style.top
pos2 = pos2.replace(/px/,"");
pos2 = pos2.replace(/pt/,"");
pos2 = new Number(pos2);
pos -= desp
pos2 -= desp

if (pos2 == desp){
	var contenidos = ""
	document.getElementById('uno').style.top = alto + "px"
	document.getElementById('uno').innerHTML = noticias[cont]
	document.getElementById('dos').style.top = 0
	if(cont == noticias.length-1){
		cont=0
		}
	else{
		cont++
		}
	pausa()
	return false
	}
else{
	if (pos == desp){
		var contenidos = ""
		document.getElementById('dos').style.top = alto + "px"
		document.getElementById('dos').innerHTML = noticias[cont]
		document.getElementById('uno').style.top = 0
		if(cont == noticias.length-1){
		cont=0
		}
		else{
			cont++
			}
		pausa()
		return false
		}
	else{
		document.getElementById('uno').style.top = pos + "px"
		document.getElementById('dos').style.top = pos2 + "px"
		}
	}
tiempo = window.setTimeout('escrolea()',50)
}
var tiempo
function pausa(){
clearTimeout(tiempo)
if (det == false){
	tiempo = setTimeout ('continuar()',pausilla)
	}
}
function continuar(){
if(det == false){
	escrolea()
	}
}
document.write('<style type="text/css">')
document.write ('#uno {')
document.write ('font-size: 13px;')
document.write ('font-weight: none;')
document.write ('color: #006699;')
if(cursor == "pointer" || cursor == "hand"){
cursor = (navigator.appName == "Netscape")?'pointer;':'hand;';
}
document.write ('cursor:' + cursor)
document.write ('position:absolute;}')
document.write ('#dos {')
document.write ('font-size: 13px;')
document.write ('font-weight: none;')
document.write ('color: #006699;')
document.write ('cursor:' + cursor)
document.write ('position:absolute;}')
document.write ('</style>')

