$(document).ready(function(){ 

    $('#continue').click(function() {
		var pickup_zip = $('input[name=pickup_zip]');
		if (pickup_zip.val().length != 5) {
			alert('Your pickup zipcode does not appear to be valid.');
	        return false;
		}
		var delivery_zip = $('input[name=delivery_zip]');
		if (delivery_zip.val().length != 5) {
			alert('Your delivery zipcode does not appear to be valid.');
	        return false;
		}
		var moving_date = $('input[name=moving_date]');
		if (moving_date.val().length == 0) {
			alert('You must enter a move date.');
	        return false;
		}

		var size = $('select[name=size]');
		var data = 'pickup_zip='+pickup_zip.val()+'&delivery_zip='+delivery_zip.val()+'&moving_date='+moving_date.val()+'&size='+size.val();

	   $.ajax({
	        type: "GET",
	        url: 'functions/checkzip.php',
	        dataType: "text",
	        data: data,
		    error: function(){ alert('Sorry, an error occurred.  Please try again.'); },
	        success: function(a) {
	        	if (a.match('ERROR')) {
					alert(a);
	        	} else {
					window.location.href = 'form.php?'+data;
	        	}
	        }
	    });

        return false;
    });
});


