function _(id){
  return document.getElementById(id);
}

function submitForm(){
  _("contact-submit").disabled = true;
  _("status").innerHTML = 'Envoi en cours ...';
  var formdata = new FormData();
  formdata.append("name", _("name").value);
  formdata.append("email", _("email").value);
  formdata.append("subject", _("subject").value);
  formdata.append("message", _("message").value);
/*
    $.ajax({
        url: "/contact",
        data: formdata,
        success: function(data){
           console.log('Mail ! ');
           console.log(data);
        }
    });*/

  var ajax = new XMLHttpRequest();
  ajax.open("POST", "/contact");

  ajax.onreadystatechange = function(){
    if(ajax.readyState == 4 && ajax.status == 200){
      if(ajax.responseText == "success"){
        _("contact-form").innerHTML = '<h2>Merci ' + _("name").value + ', votre message à bien été envoyé.</h2>';
      }else{
          alert(ajax.status);
          alert(ajax.responseText);
        _("status").innerHTML = ajax.responseText;
        _("contact-submit").disabled = false;
      }
    }
  }

  ajax.send(formdata);

}
