http = getHTTPObject();
 
function getHTTPObject(){
  var xmlhttp;
 
  /*@cc_on
 
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
      try{
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(E){
      xmlhttp = false;
    }
  }
  @else
    xmlhttp = false;
  @end @*/
 
  if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    try {
      xmlhttp = new XMLHttpRequest();
    }catch(e){
      xmlhttp = false;
    }
  }
 
  return xmlhttp;
}

function enviarcons(){

enviar(document.getElementById("nombre").value,document.getElementById("telfmail").value,document.getElementById("consulta").value,"");
}

function enviarxcons(){

enviar(document.getElementById("nombre").value,document.getElementById("telfmail").value,document.getElementById("consulta").value,"x");
}

function enviar(nombre,tel,consulta,origen){
document.getElementById("botonenvio").innerHTML="Enviando ...";
document.getElementById("botonenvio").href="#";
var url="http://www.cobertec.com/consultaweb.aspx?nombre=" + nombre + "&telfmail=" + tel + "&consulta=" + consulta + "&origen=" + origen;
  http.open("GET", url, true);
  http.send(null);
  http.onreadystatechange = handleHttpResponse;
}

function handleHttpResponse(){
    document.getElementById("botonenvio").innerHTML=document.getElementById("botonenvio").innerHTML + " " + http.readyState;
  if(http.readyState == 4){
	  document.getElementById("botonenvio").innerHTML="Enviar";
document.getElementById("botonenvio").href="javascript:enviarcons();";
  	alert(http.responseText);
   // document.getElementById('answer').innerHTML = http.responseText;
  }
}
