//complexo ajax
var vAjax=false;

////////////////////////////////////////////////////////
//ajax objects
function fAjaxRequest(){
	vAjax=false;
	if(window.XMLHttpRequest){          //mozilla
		vAjax=new XMLHttpRequest();
	}else if(window.ActiveXObject){     //ie
		try{
			vAjax=new ActiveXObject("Msxm12.XMLHTTP");
		}catch (e){
			try{
				vAjax=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){}
			
		}
	}
}//function

function fEnviarMuralAjax(){
	fAjaxRequest();
	var oForm=document.getElementById("mural_form");
	var oImgLoad=document.getElementById("img_load");
	
	var oNome=document.getElementById("campoNome");
	var oCidade=document.getElementById("campoCidade");
	var oEmail=document.getElementById("campoEmail");
	var oMsg=document.getElementById("campoMensagem");
	
	oForm.style.display="none";
//	oImgLoad.style.visibility="visible";
	
		vAjax.onreadystatechange=fprocessaRespostaMural;
		//chama gif load
//			fExibeLoad();
		vAjax.open("POST", "processa_mural.php?pNome="+oNome.value+"&pCidade="+oCidade.value+"&pEmail="+oEmail.value+"&pMsg="+oMsg.value, true);
	vAjax.send(null);
}

function fExibirEnviarMural(){
	var oForm=document.getElementById("formMural");
	var oResCont=document.getElementById("box_result_mural");
	oResCont.style.display="none";
	oForm.reset();
}

function fprocessaRespostaMural(){
	var oImgLoad=document.getElementById("img_load");
	var oResCont=document.getElementById("box_result_mural");
	//verifica se o estado do ajax esta concluido
	if (vAjax.readyState==4){
		//exibe a resposta caso ele tenha encontrado a pagina solicitada
		if(vAjax.status==200){
			//esconde o load
//			oImgLoad.style.visibility="hidden";
			oResCont.style.display="block";
			
			//exibe o resultado
			var oboxResult=document.getElementById('box_result_mural');
				oboxResult.style.visibility="visible";			
				oboxResult.innerHTML=vAjax.responseText;
			//some com a janela			
			setTimeout('fExibirEnviarMural();', 4000);
		}		
	}
}
