function ajaxInit() {
var req;

try {
 req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
 try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(ex) {
  try {
   req = new XMLHttpRequest();
  } catch(exc) {
   alert("Esse browser não tem recursos para uso do Ajax");
   req = null;
  }
 }
}

return req;
}

function RetornaValores(form)
{
	var vals = "";
	for(i=0;i<form.length;i++)
	{
		var nVal = "";
		nVal = url_encode(form.elements[i].value);
		for(k=0;k<nVal.length;k++)
		{
			nVal = nVal.replace('\n','<br>');
		}
		var tipo = form.elements[i].type.toLowerCase();
		if(tipo != "checkbox" && tipo != "radio")
		{
			vals += form.elements[i].name+"="+nVal+"&";
        }
		else
		{
            if(form.elements[i].checked)
			{
				vals += form.elements[i].name+"="+nVal+"&";
            }
        }
	}
	return vals;
}

// url_encode version 1.0
function url_encode(str) {
    var hex_chars = "0123456789ABCDEF";
    var noEncode = /^([a-zA-Z0-9\_\-\.])$/;
    var n, strCode, hex1, hex2, strEncode = "";

    for(n = 0; n < str.length; n++) {
        if (noEncode.test(str.charAt(n))) {
            strEncode += str.charAt(n);
        } else {
            strCode = str.charCodeAt(n);
            hex1 = hex_chars.charAt(Math.floor(strCode / 16));
            hex2 = hex_chars.charAt(strCode % 16);
            strEncode += "%" + (hex1 + hex2);
        }
    }
    return strEncode;
}

// url_decode version 1.0
function url_decode(str) {
    var n, strCode, strDecode = "";

    for (n = 0; n < str.length; n++) {
        if (str.charAt(n) == "%") {
            strCode = str.charAt(n + 1) + str.charAt(n + 2);
            strDecode += String.fromCharCode(parseInt(strCode, 16));
            n += 2;
        } else {
            strDecode += str.charAt(n);
        }
    }

    return strDecode;
}