/***************************************************
		AJAX
****************************************************/

try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}
fila=[]
ifila=0

function preload(n, div)
{
	document.getElementById(div).innerHTML="<div class='loading' id='loading'></div>";

	//Adiciona à fila
	fila[fila.length]=[n,div];

		
	//Se não há conexões pendentes, executa
	if((ifila+1)==fila.length) 
	{
 		load();	
	}
}
function load()
{
   var content

   xmlhttp.open("GET",fila[ifila][0],true);

	
 
  // xmlhttp.overrideMimeType('text/html');
    
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
           
	    content=unescape(xmlhttp.responseText);
	    document.getElementById(fila[ifila][1]).innerHTML=content;

	    ifila++;
            if(ifila<fila.length) setTimeout("load()",20);
        }
    }  
    //Executa
    xmlhttp.send(null)    
}
function doAction()
{
	if (document.getElementById("menu"))
	{ 

		var x_axe = document.getElementById("menu");
		var links = x_axe.getElementsByTagName("a");
	
		for(var i=0; i < links.length; i++)
		{
			links[i].onclick=actionXAxe;
		}
	
		document.getElementById('first').className='selected';
		preload('load.php?content=presentation.html', 'main');
	}
}
function actionXAxe(e)
{
	//bug ie correction
	if(typeof(e)=='undefined') var e=window.event;
	source=e.target?e.target:e.srcElement;
	
	//bug Konqueror/Safari correction
	if(source.nodeType==3) source=source.parentNode;

	//Obtém o número quebrando a url
	n=source.getAttribute("content");

	var x_axe=document.getElementById("menu");
	var links=x_axe.getElementsByTagName("a");
	
	for(var i=0;i<links.length;i++)	links[i].className="";
	
	this.className="selected";

	preload('load.php?content='+n, "main");
	//Cancela o click (evita a navegação)
	return false;
}
function hide(id)
{
	var i = id.split(";");

	for (var j=0;j<i.length;j++)
	{
 		if (document.getElementById(i[j])) document.getElementById(i[j]).style.visibility = 'hidden';
	}
}
function show(id)
{
	var i = id.split(";");

	for (var j=0;j<i.length;j++)
	{
  		if (document.getElementById(i[j])) document.getElementById(i[j]).style.visibility = 'visible';
	}
}
if (xmlhttp) window.onload=doAction