$(document).ready(function() {
	$('#contact form').attr('action', 'contact');
	$('#contact form').submit(function(){
		if($('#response')) $('#response').remove();
		$('#contact form button').attr('disabled', 'disabled');
		$.post(
			$('#contact form').attr('action'),
		    $('#contact form').serialize(), 
		    function(res){
				$('#contact form button').removeAttr('disabled');
				$('#contact form').prepend('<div id="response"></div>');
				$('#response').hide().html(res).slideDown('fast');
		    })
		return false;
	});
	$.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' || type == 'password' || tag == 'textarea')
				this.value = '';
			else if (type == 'checkbox' || type == 'radio')
				this.checked = false;
			else if (tag == 'select')
				this.selectedIndex = -1;
		});
	};
	$.localScroll();
});
