// JavaScript Document

  $(function() {
    $('.error').hide();
    $(".buttonSignup").click(function() {
      // validate and process form here
	  
	  //alert("contact.js reached");
      
      $('.error').hide();
  	  var name = $("input#name").val();
  		if (name == "") {
        $("label#name_error").show();
        $("input#name").focus();
        return false;
      }
  		var email = $("input#email").val();
  		if (email == "") {
        $("label#email_error").show();
        $("input#email").focus();
        return false;
      }
  		var companyName = $("input#companyName").val();
  		if (companyName == "") {
        $("label#msg_error").show();
        $("input#msg").focus();
        return false;
      }
	  
	  var dataString = 'name='+ name + '&email=' + email + '&msg=' + companyName;
	  //alert (dataString);return false;
	  $.ajax({
		type: "POST",
		url: "mailForm.php",
		data: dataString,
		success: function() {
		  $('#contact_form').html("<div id='message'></div>");
		  $('#message').html("<h2>Contact Form Submitted!</h2>")
		  .append("<p>Thank you for your query. You will be contacted in the next 24 hours to schedule a demonstration of MeaningMine. Should you need to contact someone in the meantime please call our office on +353 1 6725847</p>")
		  .hide()
		  .fadeIn(1500, function() {
			$('#message').append("<img id='checkmark' src='images/check.png' />");
		  });
		}
	  });
	  return false;
      
    });
  });
  
