

	function post_form(){

		if(document.getElementById("rsvp_email").value){
			ajaxFunction();
		}
		else{
			document.getElementById("rsvp_email_txt").innerHTML = '<font style="color:red">Email Address: *</font>';
		}
	}

	function display_form(){
		document.getElementById('rsvpBoxError').style.display = 'none';
		document.getElementById('rsvpBoxSuccess').style.display = 'none';
		document.getElementById('rsvpBox').style.display = 'block';
		document.getElementById("rsvp_email_txt").innerHTML = 'Email Address:';
	}

function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				return false;
			}
		}
	}

	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){

			var status = ajaxRequest.responseText;
			if(status == 1){
				document.getElementById('rsvpBox').style.display = 'none';
				document.getElementById('rsvpBoxSuccess').style.display = 'block';
			}
			else{
				document.getElementById('rsvpBox').style.display = 'none';
				document.getElementById('rsvpBoxError').style.display = 'block';
			}
		}
	}

	ajaxRequest.open("POST", "/cs-rsvp-events.php", true);

	var rsvp_first_name = encodeURIComponent(document.getElementById("rsvp_first_name").value);
	var rsvp_last_name = encodeURIComponent(document.getElementById("rsvp_last_name").value);
	var rsvp_email = encodeURIComponent(document.getElementById("rsvp_email").value);
	var rsvp_phone = encodeURIComponent(document.getElementById("rsvp_phone").value);
	var rsvp_zip = encodeURIComponent(document.getElementById("rsvp_zip").value);
	var rsvp_tag = encodeURIComponent(document.getElementById("rsvp_tag").value);
	var rsvp_address_1 = encodeURIComponent(document.getElementById("rsvp_address_1").value);
	var rsvp_address_2 = encodeURIComponent(document.getElementById("rsvp_address_2").value);
	var rsvp_city = encodeURIComponent(document.getElementById("rsvp_city").value);
	var rsvp_state = encodeURIComponent(document.getElementById("rsvp_state").value);
	var rsvp_number_attending = encodeURIComponent(document.getElementById("rsvp_number_attending").value);

	var parameters = '';

	parameters += "first_name=" + rsvp_first_name + "&";
	parameters += "last_name=" + rsvp_last_name + "&";
	parameters += "email=" + rsvp_email + "&";
	parameters += "phone=" + rsvp_phone + "&";
	parameters += "zip=" + rsvp_zip + "&";
	parameters += "address_1=" + rsvp_address_1 + "&";
	parameters += "address_2=" + rsvp_address_2 + "&";
	parameters += "city=" + rsvp_city + "&";
	parameters += "state=" + rsvp_state + "&";
	parameters += "number_attending=" + rsvp_number_attending + "&";
	parameters += "tag=" + rsvp_tag + "&";
	parameters += "x_full_post=1";

	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.send(parameters);

}
