/** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        **
 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/
function markCheck(sNome) {
	
	var sVar = sNome;
	
	if (sVar.value == "n") {
		sVar.value = "y";
	}
	else {
		sVar.value = "n";
	}
}

function XHConn() {
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
		xmlhttp.open(sMethod, sURL, true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", sVars.length);
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}


function getCadastro(obj) {

	var oConn = new XHConn();
	var poststr = "";
	var poststr = "fNome=" + encodeURI( document.getElementById("fNome").value ) +
                  "&fCpf=" + encodeURI(document.getElementById("fCpf").value) +
                  "&fEnd=" + encodeURI(document.getElementById("fEnd").value) +
                  "&fEndNum=" + encodeURI(document.getElementById("fEndNum").value) +
                  "&fEndComp=" + encodeURI(document.getElementById("fEndComp").value) +
                  "&fBairro=" + encodeURI(document.getElementById("fBairro").value) +
                  "&fCep=" + encodeURI(document.getElementById("fCep").value) +
                  "&fCidade=" + encodeURI(document.getElementById("fCidade").value) +
                  "&fEstado=" + encodeURI(document.getElementById("fEstado").value) +
                  "&fTelDDD=" + encodeURI(document.getElementById("fTelDDD").value) +
                  "&fTel=" + encodeURI(document.getElementById("fTel").value) +
                  "&fEmail=" + encodeURI(document.getElementById("fEmail").value) +
                  "&fEmailSec=" + encodeURI(document.getElementById("fEmailSec").value) +
				  "&fUsuario=" + encodeURI(document.getElementById("fUsuario").value) +
                  "&fDom=" + encodeURI(document.getElementById("fDom").value) +
                  "&fSubDom=" + encodeURI(document.getElementById("fSubDom").value) +
                  "&fSenha=" + encodeURI(document.getElementById("fSenha").value) +
                  "&fPlano=" + encodeURI(document.getElementById("fPlano").value) +
                  "&fTermo=" + encodeURI(document.getElementById("fTermo").value) +
                  "&fOp=" + encodeURI(document.getElementById("fOp").value);

	document.getElementById('principal').innerHTML = '<br><br><img src="img/img-loading.gif" />';
	
	oConn.connect("frameCadastro.php", "POST", poststr, inclusao);
}

function getContato(obj) {

	var oConn = new XHConn();
	var poststr = "";
	var poststr =	"fNome=" + encodeURI( document.getElementById("fNome").value ) +
					"&fEmail=" + encodeURI( document.getElementById("fEmail").value ) +
					"&fSetor=" + encodeURI( document.getElementById("fSetor").value ) +
					"&fAssunto=" + encodeURI( document.getElementById("fAssunto").value ) +
					"&fMsg=" + encodeURI( document.getElementById("fMsg").value ) +
					"&fOp=" + encodeURI(document.getElementById("fOp").value);

	document.getElementById('principal').innerHTML = '<br><br><img src="img/img-loading.gif" />';
	
	oConn.connect("frameContato.php", "POST", poststr, inclusao);
}

function getEnvidaDados(obj) {

	var oConn = new XHConn();
	var poststr = "";
	var poststr =	"fCodigo=" + encodeURI( document.getElementById("fCodigo").value ) +
					"&fOp=" + encodeURI(document.getElementById("fOp").value);
	
	oConn.connect("frameEmailDados.php", "POST", poststr, inclusao);
}

function getMeta(obj) {

	var oConn = new XHConn();
	var poststr = "";
	var poststr =	"fDescPeq=" + encodeURI( document.getElementById("fDescPeq").value ) +
					"&fDesc=" + encodeURI( document.getElementById("fDesc").value ) +
					"&fPalavra=" + encodeURI( document.getElementById("fPalavra").value ) +
					"&fOp=" + encodeURI(document.getElementById("fOp").value);

	oConn.connect("frameGeraMetaTag.php", "POST", poststr, inclusao);
}

function getEnvidaFatura() {
	var oConn = new XHConn();
	var poststr = "";
	var poststr =	"fCodigo=" + encodeURI( document.getElementById("fCodigo").value ) +
					"&fFatura=" + encodeURI( document.getElementById("fFatura").value ) +
					"&fOp=" + encodeURI( document.getElementById("fOp").value );

	oConn.connect("frameEnviaFatura.php", "POST", poststr, inclusao);
}