function contactForm(){
    
	var sForm = "#contactForm";
	var hasError = false;
	var oForm;
	var self = this;
	
	function clearErrors(){
		$('form li').removeClass('error');
		$('form li span').remove();
		$('.error-msg').remove();
	}
		
	function clearFields(){$('form input').val('');$('form textarea').val('');$('#submit').val('SEND IT');}
	function validateForm(){
							
		var hasError = false;
		
		$('.requiredField').each(function() {
			if($.trim($(this).val()) == $.trim(this.defaultValue)) {
				
				hasError = true;
				
				if (!$(this).parent().hasClass('error')){
					$(this).parent().append('<span class="error">This field is required.</span>');
					$(this).parent().addClass('error');
				}
				
				
				//$j('#contactForm #loading').remove();
			} 
			else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test($.trim($(this).val()))) {
					
					$(this).parent().addClass('error');
					hasError = true;
					if (!$(this).parent().hasClass('error')){
						$(this).parent().append('<span class="error">This field is required.</span>');
						$(this).parent().addClass('error');
					}
				}
			}
			
				
		});
		if(!hasError) {
			
			var formInput = oForm.serialize();
			
			$.post(oForm.attr('action'),formInput, function(data){
								   
					
				$('#contact').fadeOut('slow', function(){
				
						
						$(this).remove();
						$('#page').append("<article id='contact'><header><h1>Thank You</h1></header><p>We&rsquo;ve received your message and will respond as soon as we can.</p></div>");
					
				});
				$('#closeme').click(function(e){
						e.preventDefault();
						$('#success-msg').remove();
						clearErrors();
						clearFields(); 
				});
				
				
				clearErrors();
				clearFields();
				
			});
		}
		else{
			$('#contactForm').before("<h3 class='error-msg'>There were some errors with the information you provided. Please fix the errors below.</h3>");
		}
	}
	
	function submitForm(){validateForm();return false;}
	this.initSubmit=function(){oForm.submit(submitForm);}
	this.init =function(){oForm = $(sForm);self.initSubmit();}
	this.init();
}

