// alias para ID
function ID(id){
    return document.getElementById(id);
}

//crea un objeto del tipo XMLHttpRequest según el navegador
function XML(){ //no quitar los comentarios condicionales
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}

function enviarConsulta(){
  if ( ID('nombre').value == "" || ID('consulta').value == "" ||
     ( ID('email').value == "" && ID('telefono').value == "")){
      alert('Por favor, indicame tu: Nombre, consulta y \nun método de contacto ( teléfono o email ).');
      ID('nombre').focus();
      return false;
  }
  url = '?nombre='+ID('nombre').value+'&telefono='+ID('telefono').value+'&email='+ID('email').value+'&observaciones='+ID('consulta').value+'';
  xmlhttp=new XML();
  if (xmlhttp){
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        ID('resultadoFormularioContacto').innerHTML=xmlhttp.responseText;
		alert(xmlhttp.responseText);
		ID('nombre').value = "";
		ID('consulta').value = "";
        ID('email').value = "";
		ID('telefono').value = "";
      }
    }
    xmlhttp.open("GET", "/solicitarInformacion.php"+url,true);
    xmlhttp.send(null);
    return false;
  }
}
