  $(function() {
    $('.error2').hide();
    $(".button2").click(function() {
      // validate and process form here
      
      $('.error2').hide();
	  var dir = $("input#dir").val();
	  var contactCompany = $("input#contactCompany").val();
	  var contactCompanyemail = $("input#contactCompanyemail").val();
	  var contactWebsite = $("input#contactWebsite").val();
  	  var name = $("input#name2").val();
  		if (name == "") {
        $("label#name2_error").show();
        $("input#name2").focus();
        return false;
      }
  		var email = $("input#email2").val();
  		if (email == "") {
        $("label#email2_error").show();
        $("input#email2").focus();
        return false;    

	}else{

		if (email.indexOf('@') == -1) {
			alert('Je hebt geen geldig mailadres opgegeven.'); 
			$("label#email2_error").show();
			$("input#email2").focus();			
			return false;
		}else if (email.indexOf('.') == -1) {
			alert('Je hebt geen geldig mailadres opgegeven.'); 	
			$("label#email2_error").show();
			$("input#email2").focus();			
			return false;
		}    

	}	

	    /*var website = $("input#website2").val();
  		//if (website == "") {
        //$("label#website2_error").show();
        //$("input#website2").focus();
        //return false;
      //}
	    var subject = $("input#subject2").val();
  		if (subject == "") {
        $("label#subject2_error").show();
        $("input#subject2").focus();
        return false;
      }*/
  		var message = $("textarea#message2").val();
  		if (message == "") {
        $("label#message2_error").show();
        $("textarea#message2").focus();
        return false;
      }
	  	var verify = $("input#verify2").val();
		if ((verify != "five" && verify != "5") || verify == "") {
		$("label#verify2_error").show();
		$("input#verify2").focus();
		return false;
	  }
	  
	  var dataString = 'name='+ name + '&email=' + email + '&message=' + message + '&contactCompany=' + contactCompany + '&contactCompanyemail=' + contactCompanyemail + '&contactWebsite=' + contactWebsite;
	  //alert (dataString);return false;
	  $.ajax({
		type: "POST",
		url: dir+"/functions/contact.php",
		data: dataString,
		success: function() {
		  $('#contact').html("<div id='contact_message'></div>");
		  $('#contact_message').html("<h1>Reactie verzonden!</h1>")
		  .append("<p>Bedankt! Over een korte tijd zul je een bericht terug ontvangen van één van onze vrijwilligers.</p><img id='check' src='"+dir+"/images/email_accept.png' />")
		  .hide()
		  .fadeIn(1000, function() {
			// good!
		  });
		}
	  });
	  return false;  
      
    });
  });
  

