$(function() {
 	$(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
	var name = $("input#name").val();
	if (name == "") {
    	$("div#name_error").show();
    	$("input#name").focus();
    	return false;
    }
	var email = $("input#email").val();
		if (email == "") {
    	$("div#email_error").show();
    	$("input#email").focus();
    	return false;
    }
	var country = $("input#country").val();
	if (country == "") {
    	$("div#country_error").show();
    	$("input#country").focus();
    	return false;
    }
	var telephone = $("input#telephone").val();
	if (telephone == "") {
    	$("div#telephone_error").show();
    	$("input#telephone").focus();
    	return false;
    }
	var company = $("input#company").val();
	if (company == "") {
    	$("div#company_error").show();
    	$("input#company").focus();
    	return false;
    }
    var password = $("input#password").val();
		if (password == "") {
    	return false;
    }
	var dataString = 'name='+ name + '&email=' + email + '&company=' + company + '&telephone=' + telephone + '&country=' + country + '&password=' + password;
	$.ajax({
    	type: "POST",
    	url: "/PHPMailer_v5.0.2/process.php",
    	data: dataString,
    	success: function() {
        	$('#emailform').html("<div id='message'></div>");
        	$('#message').html("<h4>Request sent</h4>")
        	.append("<p>You will receive an email with your password shortly.</p>")
        	.hide()
        	.fadeIn(1500);
      	}
    });
    return false;
	});
});

