function createXMLHttpRequest() {

  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}

  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}

  try { return new XMLHttpRequest(); } catch(e) {}

  alert("XMLHttpRequest not supported");

  return null;

}

function ajax_encode(texto)
{
	texto = texto.replace("á","a");
	texto = texto.replace("à","a");
	texto = texto.replace("ã","a");
	texto = texto.replace("â","a");
	texto = texto.replace("ä","a");
	
	texto = texto.toString();

	utftexto = "";

	for (var n = 0; n < texto.length; n++)

	{

		var c = texto.charCodeAt(n);

		if(c >= 128)

			utftexto += "&#"+c+";";

		else

			utftexto += String.fromCharCode(c);

	}

	utftexto = utftexto.replace(/\u2019/,"'");

	utftexto = utftexto.replace(/\u201C/,"\"");

	utftexto = utftexto.replace(/\u201D/,"\"");

	utftexto = encodeURIComponent(utftexto);
	return utftexto;

}
