jQuery(function($) {
	
	// Clear Form on Submit
	$.fn.clearForm = function() {
	  return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
		  return $(':input',this).clearForm();
		if (type == 'text' || tag == 'textarea')
		  this.value = '';
	  });
	};

	
    // Ajax Submit
    $.ajax({
      data: $(this).serialize(),
      url: this.action,
      timeout: 2000,
      error: function() {
        console.log("Failed to submit");
      },
      success: function() {
        $('#thank_you_right').slideDown(500, function() {
          $('#thank_you_right');
        });
        $('#contactForm').clearForm();
      }
    })
    return false;
  })
  // End Contact Form
})

jQuery(document).ready(function($) {
	// Replace Form Values
	$(function() {
		$.fn.clearOnFocus = function(){
			return this.focus(function(){
			  this.value = this.value === this.defaultValue ? '' : this.value;
			}).blur(function(){
			  this.value = this.value === '' || /^\s+$/.test(this.value) ? this.defaultValue : this.value;
			});
		}
		$(function(){
			$('input, textarea').clearOnFocus()
			.each(function(){
				var input = $(this);
				input.parents('form:eq(0)').submit(function(){
				   return input[0].value !== input[0].defaultValue;
				});
			});
		});
	});
});
// End Document Ready
