$(document).ready(function(){
	$('input#popsubmit').click(function(){
		var name = $('input#popname').val();
		var email = $('input#popemail').val();
		var address = $('input#popaddress').val();
		var city = $('input#popcity').val();
		var state = $('input#popstate').val();
		var phone = $('input#popphone').val();
		var errormsg = "";
		
		if ( (name=="") || (name==null) ) errormsg = errormsg + "Name is required.\n";
		if ( (email=="") || (email==null) ) errormsg = errormsg + "Email is required.\n";
		if ( (city=="") || (city==null) ) errormsg = errormsg + "City is required.\n";
		if ( (state=="") || (state==null) ) errormsg = errormsg + "State is required.\n";

		if (errormsg) {
			//alert("There was an error with your submission.\n\n"+errormsg);
			alert("name="+ name +"&email="+ email+"&address="+ address+"&city="+ city+"&state="+ state+"&phone="+ phone);
			return false;
		}
		
		$.ajax({
			type: "POST",
			url: "includes/ajax.php",
			data: "name="+ name +"&email="+ email+"&address="+ address+"&city="+ city+"&state="+ state+"&phone="+ phone,
			success: function(msg){
				if (msg!=1) {
					alert(msg);
				}
				else {
					$('#signupback input').val('');
					$('#confirmation').fadeIn();
				}
			}
		});

		return false;
	});
});
