function createXMLHttpRequest() {

    if(window.ActiveXObject) {

      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }

    else if(window.XMLHttpRequest) {

      xmlHttp = new XMLHttpRequest();
      }
    }
					
function handleStateChange_joinNow() {

    if(xmlHttp.readyState == 4) {

      if(xmlHttp.status == 200) {		

        document.getElementById("midden_rechts_form").innerHTML=xmlHttp.responseText;	
        }			
      }		
    }

function handleStateChange_contactVerzenden() {

    if(xmlHttp.readyState == 4) {

      if(xmlHttp.status == 200) {		

        document.getElementById("midden").innerHTML=xmlHttp.responseText;	
        }			
      }		
    }


function joinNow() {
		
    var voornaam = document.getElementById("join_voornaam").value;
    var achternaam = document.getElementById("join_achternaam").value;
    var email = document.getElementById("join_email").value;
    var bedrijf = document.getElementById("join_bedrijf").value;
    var land = document.getElementById("join_land").value;


      if (document.getElementById("join_profiel").checked == true) {
        var profiel = "Distributeur";
        }
      else {
        var profiel = "Producent";
        }


    if (voornaam == "") {
      document.getElementById("join_voornaam").className = "input_home_fout";
      }

    else if (achternaam == "") {
      document.getElementById("join_voornaam").className = "input_home";
      document.getElementById("join_achternaam").className = "input_home_fout";
      }

    else if (email == "") {
      document.getElementById("join_voornaam").className = "input_home";
      document.getElementById("join_achternaam").className = "input_home";
      document.getElementById("join_email").className = "input_home_fout";
      }

    else if (bedrijf == "") {
      document.getElementById("join_voornaam").className = "input_home";
      document.getElementById("join_achternaam").className = "input_home";
      document.getElementById("join_email").className = "input_home";
      document.getElementById("join_bedrijf").className = "input_home_fout";
      }

    else if (land == "") {
      document.getElementById("join_voornaam").className = "input_home";
      document.getElementById("join_achternaam").className = "input_home";
      document.getElementById("join_email").className = "input_home";
      document.getElementById("join_bedrijf").className = "input_home";
      document.getElementById("join_land").className = "input_home_fout";
      }

    else {

      var url_to_open = "/includes/homepage_join.php";
      url_to_open = url_to_open + '?PROFIEL=' + profiel + '&VOORNAAM=' + voornaam + '&ACHTERNAAM=' + achternaam + '&EMAIL=' + email + '&BEDRIJF=' + bedrijf + '&LAND=' + land;

        createXMLHttpRequest();
        xmlHttp.open("POST", url_to_open, true);
        xmlHttp.onreadystatechange = handleStateChange_joinNow;
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        xmlHttp.send(null);
      }
    }


function contactVerzenden() {

    var bedrijf = document.getElementById("contact_bedrijf").value;
    var voornaam = document.getElementById("contact_voornaam").value;
    var achternaam = document.getElementById("contact_achternaam").value;
    var email = document.getElementById("contact_email").value;
    var telefoon = document.getElementById("contact_telefoon").value;
    var land = document.getElementById("contact_land").value;
    var website = document.getElementById("contact_website").value;
    var tekst = document.getElementById("contact_tekst").value;



      if (document.getElementById("contact_contact").checked == true) {
        var contact = "Email";
        }
      else {
        var contact = "Telefoon";
        }



    if (bedrijf == "") {
      document.getElementById("contact_bedrijf").className = "input_home_fout";
      }

    else if (voornaam == "") {
      document.getElementById("contact_bedrijf").className = "input_home";
      document.getElementById("contact_voornaam").className = "input_home_fout";
      }

    else if (achternaam == "") {
      document.getElementById("contact_bedrijf").className = "input_home";
      document.getElementById("contact_voornaam").className = "input_home";
      document.getElementById("contact_achternaam").className = "input_home_fout";
      }

    else if (email == "") {
      document.getElementById("contact_bedrijf").className = "input_home";
      document.getElementById("contact_voornaam").className = "input_home";
      document.getElementById("contact_achternaam").className = "input_home";
      document.getElementById("contact_email").className = "input_home_fout";
      }

    else if (telefoon == "") {
      document.getElementById("contact_bedrijf").className = "input_home";
      document.getElementById("contact_voornaam").className = "input_home";
      document.getElementById("contact_achternaam").className = "input_home";
      document.getElementById("contact_email").className = "input_home";
      document.getElementById("contact_telefoon").className = "input_home_fout";
      }

    else if (land == "") {
      document.getElementById("contact_bedrijf").className = "input_home";
      document.getElementById("contact_voornaam").className = "input_home";
      document.getElementById("contact_achternaam").className = "input_home";
      document.getElementById("contact_email").className = "input_home";
      document.getElementById("contact_telefoon").className = "input_home";
      document.getElementById("contact_land").className = "input_home_fout";
      }

    else if (tekst == "") {
      document.getElementById("contact_bedrijf").className = "input_home";
      document.getElementById("contact_voornaam").className = "input_home";
      document.getElementById("contact_achternaam").className = "input_home";
      document.getElementById("contact_email").className = "input_home";
      document.getElementById("contact_telefoon").className = "input_home";
      document.getElementById("contact_land").className = "input_home";
      document.getElementById("contact_tekst").className = "textarea_contact_fout";
      }

    else {

      var url_to_open = "/includes/contact_verzenden.php";
      url_to_open = url_to_open + '?BEDRIJF=' + bedrijf + '&VOORNAAM=' + voornaam + '&ACHTERNAAM=' + achternaam + '&EMAIL=' + email + '&TELEFOON=' + telefoon + '&LAND=' + land + '&WEBSITE=' + website + '&CONTACT=' + contact + '&TEKST=' + tekst;

        createXMLHttpRequest();
        xmlHttp.open("POST", url_to_open, true);
        xmlHttp.onreadystatechange = handleStateChange_contactVerzenden;
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        xmlHttp.send(null);
      }


    }
