var carregando = ''
+ '	<table width=100% height=300>'
+ '		<tr>'
+ '			<td align=center valign=middle>'
+ '				<obj' + 'ect classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="73" height="34">'
+ '					<pa' + 'ram name="movie" value="images/carregando.swf">'
+ '					<pa' + 'ram name="quality" value="high">'
+ '					<pa' + 'ram name="wmode" value="transparent">'
+ '					<em' + 'bed src="images/carregando.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="73" height="34"></embed>'
+ '				</obj' + 'ect>'
+ '			</td>'
+ '		</tr>'
+ '	</table>'
+ '';

try{
	xmlhttp = new XMLHttpRequest();
}catch(ee){
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}
}

historyIndex = 0;
defineHistorico = new Array();
defineHistorico[historyIndex] = new Array();
defineHistorico[historyIndex][1] = document.location;
defineHistorico[historyIndex][2] = 'defineAjax';
defineHistorico[historyIndex][3] = 'abre';

function atualizaConteudo(conteudoHTML)
{
	document.getElementById('conteudo').innerHTML = conteudoHTML;
	//document.getElementById('contenido').innerHTML = conteudoHTML;
	
	try
	{
		document.getElementById('contenido').parentNode.style.height = document.getElementById('conteudo').offsetHeight-226;
	}catch(e){}
	
	scripts = document.getElementById('conteudo').getElementsByTagName('SCRIPT');
	for( i=0 ; i<scripts.length ; i++ )
	{
		eval(scripts[i].innerHTML)	
	}
	
	inicializaLinks();
}

function defineAjax(oLink,abreFechaMenu)
{
	if(abreFechaMenu)
	{
		historyIndex++;
		defineHistorico[historyIndex] = new Array();
		defineHistorico[historyIndex][1] = oLink.href;
		defineHistorico[historyIndex][2] = 'defineAjax';
		defineHistorico[historyIndex][3] = abreFechaMenu;
	}
	linhas = oLink.href.split('?');
	partes = linhas[0].split('/');
	var anterior = '';
	linhas[0] = '';
	for( i=0 ; i<partes.length ; i++ )
	{
		linhas[0] = anterior;
		anterior += '' + partes[i] + '/';
	}
	//alert(linhas[0]);
	//return false;
	
	xmlhttp.open("GET",   linhas[0] + 'tela.php?' + linhas[1] ,true);
	//document.getElementById('divConteudo').className = 'conteudo';
	//document.getElementById('divConteudo').parentNode.className = 'conteudo';
	//document.getElementById('flashDestaque').style.visibility = 'hidden';
	if(defineHistorico[historyIndex][3]=='abre')
	{
		_abreMenuAnimado(document.getElementById('flashHome'));
	}
	else if(defineHistorico[historyIndex][3]=='fecha')
	{
		_fechaMenuAnimado(document.getElementById('flashHome'));
	}
	atualizaConteudo(carregando);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4){
			//alert(xmlhttp.responseText);
			atualizaConteudo(xmlhttp.responseText);
		}
	}
	xmlhttp.send(null);
	return false;
}

function enviaBusca(oForm, abreFechaMenu)
{
	
	if(oForm.elements['busca'].value.length < 3)
	{
		alert('Busca deve ter mais de 3 caracteres!');
		return false;
	}
	dados = '';
	for( i=0 ; i<oForm.length ; i++ )
	{
		dados += oForm.elements[i].name + '=' + escape(oForm.elements[i].value) + '&';
	}
	if( !oForm.action )
	{
		if(oForm.method=='post')
		{
			oForm.action = window.location;
		}
		else
		{
			linhas = window.location.href.split('?');
			oForm.action = linhas[0];
		}
	}
	if(abreFechaMenu)
	{
		historyIndex++;
		defineHistorico[historyIndex] = new Array();
		defineHistorico[historyIndex][1] = oForm.action;
		defineHistorico[historyIndex][2] = 'enviaBusca';
		defineHistorico[historyIndex][3] = abreFechaMenu;
		defineHistorico[historyIndex][4] = oForm.method=='post'?'post':'get';
		defineHistorico[historyIndex][5] = dados;
	}
	else
	{
		oForm.action = defineHistorico[historyIndex][1];
		oForm.method = defineHistorico[historyIndex][4]=='post'?'post':'get';
		dados = defineHistorico[historyIndex][5];
	}
	linhas = oForm.action.split('?');
	partes = linhas[0].split('/');
	var anterior = '';
	linhas[0] = '';
	ultimo = '';
	for( i=0 ; i<partes.length ; i++ )
	{
		linhas[0] = anterior;
		anterior += '' + partes[i] + '/';
		ultimo = partes[i];
	}
	
	if(oForm.method=='post')
	{
		linhas[1] = linhas[1] ? '?' + linhas[1] : '';
		xmlhttp.open( "POST" ,   linhas[0] + 'tela.php' + linhas[1] ,true);
		xmlhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" ); 
		xmlhttp.send(dados);
	}
	else
	{
		xmlhttp.open( "GET" ,   linhas[0] + 'tela.php?' + dados ,true);
		xmlhttp.send(null);
	}
	//document.getElementById('divConteudo').className = 'conteudo';
	//document.getElementById('divConteudo').parentNode.className = 'conteudo';
	//document.getElementById('flashDestaque').style.visibility = 'hidden';
	if(defineHistorico[historyIndex][3]=='abre')
	{
		_abreMenuAnimado(document.getElementById('flashHome'));
	}
	else if(defineHistorico[historyIndex][3]=='fecha')
	{
		_fechaMenuAnimado(document.getElementById('flashHome'));
	}
	atualizaConteudo(carregando);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4){
			//alert(xmlhttp.responseText);
			atualizaConteudo(xmlhttp.responseText);
		}
	}
	
	return false;
}

function inicializaLinks()
{
	osLinks = document.getElementsByTagName('A');
	for( i=0 ; i<osLinks.length ; i++ )
	{
		if(!osLinks[i].onclick)
		{
			osLinks[i].onclick = function(){ return defineAjax(this,'fecha'); };
		}
	}
	
	//busca = document.getElementById('formBusca');
	//busca.onsubmit = function(){ return enviaBusca(this) } ;
	
}

function historico(passo)
{
	if( typeof(defineHistorico[historyIndex+passo])=='undefined' ) return false;
	
	historyIndex = historyIndex+passo;
	
	if(defineHistorico[historyIndex][2]=='defineAjax')
	{
		var olink = document.getElementsByName('linkGlobal')[0];
		olink.href = defineHistorico[historyIndex][1];
		olink.click();
	}
	else if(defineHistorico[historyIndex][2]=='enviaBusca')
	{
		var oform = document.getElementsByName('formGlobal')[0];
		oform.action = defineHistorico[historyIndex][1];
		oform.method = defineHistorico[historyIndex][4];
		oform.elements[0].click();
	}
	if(defineHistorico[historyIndex][3]=='abre')
	{
		_abreMenuAnimado(document.getElementById('flashHome'));
	}
	else if(defineHistorico[historyIndex][3]=='fecha')
	{
		_fechaMenuAnimado(document.getElementById('flashHome'));
	}
}

function _abreMenuAnimado(objMenu)
{
}
function _fechaMenuAnimado(objMenu)
{
}