	abre_popup_produto = function (id_produto,menu_id,param){
		var oLink = document.getElementById('linkGlobal');
		oLink.href = "tela.php?pag=ecomm_produto_detalhe&id_produto=" + id_produto + "&menu_id="+menu_id + "&param="+param +"&id=";
		defineAjax(oLink,'fecha');
	}



function enviaFiltro(oForm, abreFechaMenu)
{
		
		dados = '';
		for( i=0 ; i<oForm.length ; i++ )
		{
			if(oForm.elements[i].type=='checkbox' && !oForm.elements[i].checked )
			{
				dados += oForm.elements[i].name + '=' + '&';
			}
			else
			{
				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] = 'enviaFiltro';
			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);
		}
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4){
				document.getElementById('menuCatalogo').innerHTML = xmlhttp.responseText;
				//ReadyStateCache();
				//replaceSelects();
				//ReadyStateCache = function(){};
			}
		}
	return false;
}

limpaForm = function( oCampo )
{
	elements = oCampo.form.elements;
	for( i=0 ; i<elements.length ; i++ )
	{
		if( 
			elements[i].type!='button' 
				&& 
			elements[i].type!='submit' 
				&& 
			elements[i].type!='reset' 
				&& 
			elements[i].type!='hidden' 
		)
		{
			if(elements[i].type=='select-one')
			{
				elements[i].selectedIndex = 0;
			}
			if(elements[i].type=='text')
			{
				elements[i].value = '';
			}
		}
	}
}



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="45" height="45">'
+ '					<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="45" height="45"></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 var_dump(obj){
	var resposta = new Array();
	var count = 0;
	j=0;
	resposta[j] = '';
	for( i in obj)
	{
		resposta[j] += i + ' = ' + obj[i] + '\n';
		if( ++count%15 == 0 )
		{
			j++;
			resposta[j] = '';
		}
	}
		//alert(resposta.length);
	for( j=1 ; j<=resposta.length ; j++ )
	{
		alert(resposta[j]);
	}
	return;
}

function atualizaConteudo(conteudoHTML){

	document.getElementById('conteudo').innerHTML = conteudoHTML;


	scripts = document.getElementById('conteudo').getElementsByTagName('SCRIPT');
	for( i=0 ; i<scripts.length ; i++ ){
		try{
			eval(scripts[i].innerHTML);
		}catch(e){}	
	}

	
	//função inicializa links
	inicializaLinks();
}

function defineAjaxClick(oLink,abreFechaMenu){
	//alert(xmlhttp.readyState);
	agarrefe = oLink;
	
	if(abreFechaMenu){
		historyIndex++;
		defineHistorico[historyIndex] = new Array();
		defineHistorico[historyIndex][1] = agarrefe;
		defineHistorico[historyIndex][2] = 'defineAjax';
		defineHistorico[historyIndex][3] = abreFechaMenu;
		var oIframe = document.getElementsByName('iframeAjax')[0].contentWindow;
		var url = oIframe.location;
		var hash = url.search.toString();
		url = url.toString();
		url = url.substring(0, ( url.length - hash.length ) ) ;
		oIframe.location = url + '?' + historyIndex;
		//alert(oIframe.location);
		//alert(oIframe.location);
	}
	try{
		var linhas = agarrefe.split('?');
	}catch(eLinhas){
		linhas = new Array(2);
		linhas[0] = '';
		//linhas[1] = agarrefe;
		linhas[1] = '';
	}
	if(linhas.length<2){
		//linhas[1] = linhas[0];
		linhas[1] = '';
		linhas[0] = '';
	}
	partes = linhas[0].split('/');
	var anterior = '';
	linhas[0] = '';
	for( i=0 ; i<partes.length ; i++ ){
		linhas[0] = anterior;
		anterior += '' + partes[i] + '/';
	}
	xmlhttp.open("GET",   linhas[0] + 'tela.php?' + linhas[1] ,true);

	if(defineHistorico[historyIndex][3]=='abre'){
		_abreMenuAnimado();
	}else if(defineHistorico[historyIndex][3]=='fecha'){
		_fechaMenuAnimado();
	}
	
	atualizaConteudo(carregando);
	
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4){
			atualizaConteudo(xmlhttp.responseText);
		}
	}
	xmlhttp.send(null);
	

	return false;
}

function defineAjax(oLink,abreFechaMenu){

	agarrefe = oLink.getAttribute('href');
	
	if(abreFechaMenu){
		historyIndex++;
		defineHistorico[historyIndex] = new Array();
		defineHistorico[historyIndex][1] = agarrefe;
		defineHistorico[historyIndex][2] = 'defineAjax';
		defineHistorico[historyIndex][3] = abreFechaMenu;
		var oIframe = document.getElementsByName('iframeAjax')[0].contentWindow;
		var url = oIframe.location;
		var hash = url.search.toString();
		url = url.toString();
		url = url.substring(0, ( url.length - hash.length ) ) ;
		oIframe.location = url + '?' + historyIndex;
		//alert(oIframe.location);
		//alert(oIframe.location);
	}
	try{
		var linhas = agarrefe.split('?');
	}catch(eLinhas){
		linhas = new Array(2);
		linhas[0] = '';
		//linhas[1] = agarrefe;
		linhas[1] = '';
	}
	if(linhas.length<2)
	{
		//linhas[1] = linhas[0];
		linhas[1] = '';
		linhas[0] = '';
	}
	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();
	}else if(defineHistorico[historyIndex][3]=='fecha'){
		_fechaMenuAnimado();
	}
	
	atualizaConteudo(carregando);
	
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4){
			atualizaConteudo(xmlhttp.responseText);
		}
	}
	//alert( linhas[0] + 'tela.php?' + linhas[1] );
	xmlhttp.send(null);
	return false;
}

function enviaBusca(oForm, abreFechaMenu, quieto)
{
	
	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++ )
	{
		if(!oForm.elements[i].name) continue;
		if( oForm.elements[i].type=='radio' || oForm.elements[i].type=='checkbox' )
		{
			if(!oForm.elements[i].checked) continue;	
		}
		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];
		}
	}
	//alert(dados);
	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 if( typeof(quieto)!='undefined' )
	{
		// ????? não cria 
	}
	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'));
	}
	
	if( typeof(quieto)=='undefined' )
	{
		atualizaConteudo(carregando);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4){
				//alert(xmlhttp.responseText);
				atualizaConteudo(xmlhttp.responseText);
			}
		}
	}
	else
	{
		xmlhttp.onreadystatechange = function() {
			//alert();
		}	
	}
	
	return false;
}

function inicializaLinks()
{
	/*
	osLinks = document.getElementsByTagName('A');
	for( i=0 ; i<osLinks.length ; i++ )
	{
		if(!osLinks[i].onclick && osLinks[i].target!='_blank')
		{
			osLinks[i].onclick = function(){ return defineAjax(this,'fecha'); };
		}
	}
	*/
	osLinks = document.getElementsByTagName('A');
	for( i=0 ; i<osLinks.length ; i++ )
	{
		if(!osLinks[i].onclick && osLinks[i].target != '_blank'){

			var linkConf = osLinks[i].href.split("index.php");
			var linkMail = osLinks[i].href.split("@");
			var linkUrl = osLinks[i].href.split("index.php?");
			if(!linkUrl[1]){
				osLinks[i].href = linkUrl[0];
				osLinks[i].target = "_blank";
			}else if(linkConf[1]){
				//osLinks[i].href = "http://www"+linkConf[1];
				osLinks[i].href = "javascript:void(defineAjaxClick('"+linkConf[1]+"&pag=artigos','fecha'));";
				//osLinks[i].target = "_blank";
			}else if(linkMail[1]){
				osLinks[i].href = linkMail[0]+"@"+linkMail[1];
				osLinks[i].target = "_blank";
			}else{
				linkConf = osLinks[i].href.split("index.php");
				osLinks[i].href = "javascript:void(defineAjaxClick('"+linkConf[1]+"&pag=artigos','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;
		
		// historico do listaProdutos()
		if( typeof(defineHistorico[historyIndex][4])!='undefined' ){
			
			trigger = defineHistorico[historyIndex][4];
			listaProdutos(trigger,'noHistory');
			
		}else if(defineHistorico[historyIndex][2]=='defineAjax'){
			
			var olink = document.getElementsByName('linkGlobal')[0];
			olink.setAttribute('href' , defineHistorico[historyIndex][1] );
			try{
				olink.click();
			}catch(e){
				olink.onclick();
			}	
		}else if(defineHistorico[historyIndex][2]=='enviaBusca'){
			var oform = document.getElementsByName('formGlobal')[0];
			oform.action = defineHistorico[historyIndex][1];
			oform.method = defineHistorico[historyIndex][4];
			try{
				oform.elements[0].click();
			}catch(e){
				oform.elements[0].onclick();
			}
	}
	if(defineHistorico[historyIndex][3]=='abre'){
		_abreMenuAnimado();
	}else if(defineHistorico[historyIndex][3]=='fecha'){
		_fechaMenuAnimado();
	}
}

function _abreMenuAnimado(){
	
	document.getElementById('divConteudo').className = '';
	document.getElementById('divConteudo').parentNode.className = '';
	//document.getElementById('flashDestaque').style.visibility = 'visible';
	document.getElementById('divFlash').className = 'mostraFlash';
}
function _fechaMenuAnimado(){
	document.getElementById('divConteudo').className = 'conteudo';
	document.getElementById('divConteudo').parentNode.className = 'conteudo';
	//document.getElementById('flashDestaque').style.visibility = 'hidden';
	document.getElementById('divFlash').className = 'escondeFlash';
}