function createXMLHTTP() 
{
var ajax;

try{
    ajax = new XMLHttpRequest();
	}
catch(ee){
    	  try{
          	  ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
    		  }
		   catch(e){
           			try{
            			ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
        				}
					catch(E){
            				 ajax = false;
        					 }
    					}
					}
			return ajax;
}


function modNewsletter(nomDiv, endereco)
 {
	 document.getElementById(nomDiv).innerHTML = 'Cadastrando Newsletter...';
     var oHTTPRequest = createXMLHTTP(); 
     oHTTPRequest.open("post", "modNewsletter.asp", true); 
	 oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
     oHTTPRequest.onreadystatechange=function()
  	 {
	  	if (oHTTPRequest.readyState==4)
	 	{
       	   document.getElementById(nomDiv).innerHTML = oHTTPRequest.responseText;
		}
	 }

     oHTTPRequest.send("end=" + endereco);
 }

function modContato(nomDiv, nom, tel, email, mens)
 {
	 document.getElementById(nomDiv).innerHTML = 'Enviando mensagem...';
     var oHTTPRequest = createXMLHTTP(); 
     oHTTPRequest.open("post", "modContato.asp", true); 
	 oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
     oHTTPRequest.onreadystatechange=function()
  	 {
	  	if (oHTTPRequest.readyState==4)
	 	{
       	   document.getElementById(nomDiv).innerHTML = oHTTPRequest.responseText;
		}
	 }

     oHTTPRequest.send("nom=" + nom + "&tel=" + tel + "&email=" + email + "&mens=" + mens);
 } 
 
 
function modEmailMascara(nomDiv, destino, assunto, saudacao, mensagem)
 {
	document.getElementById(nomDiv).innerHTML = 'Enviando Email...';
 
     var oHTTPRequest = createXMLHTTP(); 
     oHTTPRequest.open("post", "modEnvioEmailMascaraAcao.asp", true); 
	 oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
     oHTTPRequest.onreadystatechange=function()
  	 {
	  	if (oHTTPRequest.readyState==4)
	 	{
       	   document.getElementById(nomDiv).innerHTML = oHTTPRequest.responseText;
		}
	 }

     oHTTPRequest.send("dest=" + destino + "&assu=" + assunto + "&saud=" + saudacao + "&mens=" + mensagem);
 }
 
 function encoderAJAX(texto) {
    var encodedHtml = escape(texto);
    encodedHtml = encodedHtml.replace(/\//g,"%2F");
    encodedHtml = encodedHtml.replace(/\?/g,"%3F");
    encodedHtml = encodedHtml.replace(/=/g,"%3D");
    encodedHtml = encodedHtml.replace(/&/g,"%26");
    encodedHtml = encodedHtml.replace(/@/g,"%40");
    return encodedHtml;
}

function decoderAJAX(texto){
    var t = unescape(texto);
    t = t.replace (/\+/g, " ");
    return t;
}

