
function httpRequestRaiz(strUrl, strFnc)
{
	objReq = null;
	if (window.XMLHttpRequest) {
		objReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		objReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	objReq.open("GET", strUrl, true);
	objReq.send(null);
	if (strFnc != "") {
		objReq.onreadystatechange = function() 
		{			
			if (objReq.readyState == 4)
			{
				eval(strFnc + '(objReq.responseText)');
			}
		};
	}
}
function busca(str){
	location.href=raiz+'produtos/busca/1,'+ replaceSpecialChars(str) +',busca.html';
	
}
function verificaCaptcha(captcha){	
	httpRequest(raiz+'verifica-captcha.php?captcha='+captcha, 'respostaCaptcha');
}
function respostaCaptcha(resposta){
	if(resposta=="true"){
			document.frmComentario.submit()
	}else{
			alert('Código de segurança inválido!');
	}
}
function carregaCategoriaSugestao(cat){
	location.href=raiz+'sugestao-de-ambientes/'+cat;
}
function buscaBlog(str){
	location.href=raiz+'blog/busca/1,'+ replaceSpecialChars(str) +',busca.html';
	
}
function validaNomeNoivos(nome){
	if(nome==''){
		alert('Preencha o campo nome dos noivos');
	}else{	
		httpRequest(raiz+'ajaxValidaNoivos.php?nome='+nome, 'resposta');
	}
}
function resposta(resposta){
	nomecampo('tdRetorno').innerHTML = resposta;	
	if(nomecampo('codLista').value==''){			
		alert('O nome inserido não consta em nossa lista!\nVerifique o nome e tente novamente.');
	}else{
		location.href=raiz+'lista-de-casamento/noivos,'+nomecampo('codLista').value+','+nomecampo('nomeNoivos').value+'.html';	
	}
}
function controlaMenu(nivel,area,pai,escreve){
	for(i=nivel;i<=3;i++){			
		document.getElementById("nivel-0"+i).innerHTML = '';
	}
	document.getElementById("nivel-0"+nivel).innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="100%" align="center"><img src="'+raiz+'img/working.gif" /></td></tr></table>';	
	httpRequestRaiz(raiz+'ajaxMenu.php?nivel='+nivel+'&area='+area+'&pai='+pai,escreve);
}
function  escreveMenuNivel01(str){		
	document.getElementById('nivel-01').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="100%" align="center"><img src="'+raiz+'img/working.gif" /></td></tr></table>';
	document.getElementById('nivel-01').innerHTML = str;
}
function escreveMenuNivel02(str){
	document.getElementById('nivel-02').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="100%" align="center"><img src="'+raiz+'img/working.gif" /></td></tr></table>';
	document.getElementById('nivel-02').innerHTML = str;
}
function escreveMenuNivel03(str){
	document.getElementById('nivel-03').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="100%" align="center"><img src="'+raiz+'img/working.gif" /></td></tr></table>';
	document.getElementById('nivel-03').innerHTML = str;
}


function carregaCidadesRodape(estado){	
	document.getElementById('tdCidades').innerHTML = 'Carregando...';
	httpRequest(raiz+'ajaxCidadesLojasRodape.php?estado='+estado, 'escreveCidadesRodape');
}
function escreveCidadesRodape(str){
	document.getElementById('tdCidades').innerHTML = 'Carregando...';
	document.getElementById('tdCidades').innerHTML = str;	
}



function carregaCidades(estado){	
	document.getElementById('tdCidades').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td  align="center"><img src="'+raiz+'img/workingLojas.gif" /></td></tr></table>';
	httpRequest(raiz+'ajaxCidadesLojas.php?estado='+estado, 'escreveLojas');
}

function escreveLojas(str){
	document.getElementById('tdCidades').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td  align="center"><img src="'+raiz+'img/workingLojas2.gif" /></td></tr></table>';
	document.getElementById('tdCidades').innerHTML = str;
}
function carregaCidadesInicio(estado,municipio){
	
	document.getElementById('tdCidades').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td  align="center"><img src="'+raiz+'mg/workingLojas.gif" /></td></tr></table>';
	if(municipio==''){
		httpRequest(raiz+'ajaxCidadesLojas.php?estado='+estado+'&municipio='+municipio, 'escreveLojasInicio');
	}else{	
		httpRequest2(raiz+'ajaxCidadesLojas.php?estado='+estado+'&municipio='+municipio, 'escreveLojasInicio',municipio);
	}
}
function escreveLojasInicio(str,municipio){
	document.getElementById('tdCidades').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td  align="center"><img src="'+raiz+'img/workingLojas2.gif" /></td></tr></table>';
	document.getElementById('tdCidades').innerHTML = str;
	carregaConteudoLojas(municipio);
}

function carregaConteudoLojas(cidade){	
	document.getElementById('tdNossasLojas').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td  align="center"><img src="'+raiz+'img/workingLojas2.gif" /></td></tr></table>';
	httpRequest(raiz+'ajaxNossasLojas.php?cidade='+cidade, 'escreveConteudoLojas');
}
function escreveConteudoLojas(str){

	document.getElementById('tdNossasLojas').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td  align="center"><img src="'+raiz+'img/workingLojas2.gif" /></td></tr></table>';
	document.getElementById('tdNossasLojas').innerHTML = str;	
}
function carregaCidadesPreco(estado){
	document.getElementById('tdCidade').innerHTML = '<samp class="texto-13-cinza">Carregando...</spam>';
	httpRequestRaiz(raiz+'ajaxCidadesConsultarPreco.php?est='+estado, 'escreveCidadePreco');
}
function escreveCidadePreco(str){
	document.getElementById('tdCidade').innerHTML = str;
}

function mantemMenuAberto(area,pai){	// para nivel 01

	nivel=1;
	for(i=nivel;i<=3;i++){			
		document.getElementById("nivel-0"+i).innerHTML = '';
	}
	document.getElementById("nivel-0"+nivel).innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="100%" align="center"><img src="'+raiz+'img/working.gif" /></td></tr></table>';	
	httpRequest3(raiz+'ajaxMenu.php?nivel=1&area='+area+'&pai=','escreveMenuAberto',pai);
}
function escreveMenuAberto(str,pai){	

	document.getElementById('nivel-01').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="100%" align="center"><img src="'+raiz+'img/working.gif" /></td></tr></table>';
	document.getElementById('nivel-01').innerHTML = str;
	controlaMenu('2','',pai,'escreveMenuNivel02');
	
}
