$(document).ready(function() {
	$("#mainform").submit(function() {
		var firstnameval = $("#firstname").val();
		var lastnameval = $("#lastname").val();
		var emailval = $("#email").val();
		if(emailval == 'i.e. bob@execcouncil.org'){ return false; }
		$.post("../backend.php", { firstname: firstnameval, 
		lastname: lastnameval, email: emailval }, function(data) {
			split = data.split('|');
			
			if(split[0]=='firstname')
			{
				$("label#firstname_label").css({ 'color' : '#ff0000' });
				$("input#firstname").val('');
			}
			if(split[0]=='lastname' || split[1]=='lastname')
			{
				$("label#lastname_label").css({ 'color' : '#ff0000' });
				$("input#lastname").val('');
			}
			if(split[0]=='email' || split[1]=='email' || split[2]=='email')
			{
				$("label#email_label").css({ 'color' : '#ff0000' });
				$("input#email").val('');
			}
			if(data=='Thanks for signing up!')
			{
				$('#contentmain_newsletter').html('<h2>ExecCouncil Newsletter SignUp</h2><p><strong>' + data + '</strong></p>');
			}
			else
			{
				//alert(data);
			}
		});
		return false;
	});
});