//Javascript Class For Email Form
/**
Ê* @constructor
Ê*/

function EmailForm (){

	var objSelf = this;

	this.subsForm 	= $("#emailForm");
	this.submitBtn 	= $("#submit");

	// initialize hidden elements, css changes and page body
	$('#success').hide();

	//get a set of references to all the form pages
	this.DOMReferences = {
			EMAIL:this.subsForm.find("input[name='email']")
	};

	// function for next button on page 1
	$("#emailForm").validate({
		rules:{
			EMAIL:{
				required: true,
				email: true
    			}
		},
		submitHandler: function(form) {
			var postData = (
				'email=' + $('#email').val()
				);
			$.ajax({
				type: "POST",
				url: "emailSubmit.cfc?method=submitEmail&returnformat=plain",
				data: postData,
				success: function(){
					$('#emailForm').hide();
					$('#success').show();
				}
			});
		}
	});

}


// ------------------------------------------------------------------- //
// When the document is ready, init contact form. It is important
// that we wait for the DOM loaded event to that we have access to
// the DOM elements.

$(function() {
	var objEmailForm = new EmailForm();
});
