jQuery(function($) {
	
	$('#first-name').before('<label for="first-name" id="first-name-label">Please leave the be human field blank. It is here to help stop the comment junk.</label>');
	
	$('#add-vote-form').submit(function(){

		var votername = $('#votername').val();
		var voteremail = $('#voteremail').val();
		var votemessage = $('#votemessage').val();
		var behuman = $('#first-name').val();
		//cl(votemessage);
		
		
		if (votername.length<1){
			$('#howdoyouvoteheader').text("Please fill in all fields.").addClass("error");
		}
		
		var inputs = $('#add-vote-form').serialize();

		if(behuman == ""){
			$.ajax({
			  type: "POST",
			  url: "vote-process.php",
			  data: inputs,
			  success: function(msg){
				if(msg == "empty"){
					$('#howdoyouvoteheader').text("Please fill in all fields.").addClass("error");
					$(window).scrollTo('#addavote', {duration:500});	
				}
				if(msg == "1" || msg == "bot"){
					$('.votes').prepend("<dt class='name'>"+ votername +"</dt>");
					$('.votes').prepend("<dd>"+ votemessage +"</dd>");
					$(window).scrollTo('#votesheading', {duration:1500});
				
					//reset the form too
					$('#votemessage, #votername').val("");
					$('#howdoyouvoteheader').text("How do you vote with your wallet?").removeClass("error");
				
				
				}
			  },
			  error: function(msg){
				alert(msg);
			}	
			});
		}
		return false;
		
/*
		$.post("vote-process.php", { votername: votername, voteremail: voteremail, votemessage: votemessage },
		  function(data){
		    alert("Data Loaded: " + data);
		  });
		
		return false;*/

	});

	
	
});//jQuery ready
