// CONTACT FORM VALIDATION


$(function() {
    // These first three lines of code compensate for Javascript being turned on and off. 
    // It simply changes the submit input field from a type of "submit" to a type of "button".

    var paraTag = $('input#submit').parent('p');
    $(paraTag).children('input').remove();
    $(paraTag).append('<input type="button" name="submit" id="submit" value="Send" />');

    $('#contactForm input#submit').click(function() {

        var name = $('input#name').val();
        var email = $('input#emailadres').val();
        var message = $('textarea#bericht').val();
		
		if(name ==""){
			 $('#name').css("border","solid 1px red").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn();
		}
		
		if(email ==""){
			 $('#emailadres').css("border","solid 1px red").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn();
		}		

		if(message ==""){
			 $('#bericht').css("border","solid 1px red").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn();
		}
		
		if(name !="" && email !="" && message !=""){
			$.ajax({
            type: 'post',
            url: '/emailform/processcontact.php',
            data: 'name=' + name + '&email=' + email + '&message=' + message,

            success: function(results) {
                $('#contactForm form').html("&nbsp;").append("<p style='font-size:12px;'>Bedankt voor je reactie! Je bericht is met succes ontvangen. Binnen 24 uur ontvang je een reactie. Kun je niet zo lang wachten, neem dan contact op via het telefoonnummer: 085 23 032 02</p>").fadeIn();
                $('ul#response').html(results);
            }
        }); // end ajax
		
		}
    
    	return false;
    });
});

















