$(function() {

//$('.error').hide();
$(".button").click(function() {
// validate and process form here
var dataString = "";

var name = $("input#name").val();
if (name != "") {
//$("label#name_error").show();
//$("input#Name").focus();
//return false;
dataString += 'name=' + name;
}

var profession = $("select#Profession").val();
if (profession != "" && profession != undefined && profession != null) {
//$("label#phone_error").show();
//$("input#phone").focus();
//return false;
dataString += '&profession=' + profession;
}

var ContactNumber = $("input#ContactNumber").val();
if (ContactNumber != "") {
//$("label#email_error").show();
//$("input#Cmail").focus();
//return false;
dataString += '&ContactNumber=' + ContactNumber;
}

var email = $("input#email").val();
if (email != "") {
//$("label#email_error").show();
//$("input#Email").focus();
//return false;
dataString += '&email=' + email;
}

var MailingAddress = $("textarea#MailingAddress").val();
if (MailingAddress != "") {
//$("label#phone_error").show();
//$("input#phone").focus();
//return false;
dataString += '&MailingAddress=' + MailingAddress;
}

var ClassLocation = $("input#ClassLocation").val();
if (ClassLocation != "") {
//$("label#phone_error").show();
//$("input#phone").focus();
//return false;
dataString += '&ClassLocation=' + ClassLocation;
}

var ReferredFrom = $("input#ReferredFrom").val();
if (ReferredFrom != "") {
//$("label#phone_error").show();
//$("input#phone").focus();
//return false;
dataString += '&ReferredFrom=' + ReferredFrom;
}

var ClassLocation = $("input#ClassLocation").val();
if (ClassLocation != "") {
//$("label#phone_error").show();
//$("input#phone").focus();
//return false;
dataString += '&ClassLocation=' + ClassLocation;
}

var Comments = $("textarea#message").val();
if (Comments != "") {
//$("label#phone_error").show();
//$("input#phone").focus();
//return false;
dataString += '&Comments=' + Comments;
}

//alert (dataString);return false;


  $.ajax({
    type: "POST",
    url: "Scripts/formProcessor.php",
    data: dataString,
	dataType:"html",
    success: function(dataString) {
      $('#formHolder').html("<div id='message'></div>");
      $('#message').html("<h2>Contact Form Submitted!</h2>"+dataString)
      .append("<p>Thank you for your interest.<br>We will be in touch soon.</p>")
      .hide()
      .fadeIn(1500, function() {
        $('#message').append("<img id='checkmark' src='images/check.png' />");
      } )},
	failure: function(){
		alert('failure');
	  }


	 

  });
  return false;
  

});
});

