

jQuery(document).ready(function(){



$.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;

  });

};



	$('#contactform').submit(function(){

	

		var action = $(this).attr('action');

		

		$('#submit')

			.before('<img src="ajax-loader.gif" class="loader" />')

			.attr('disabled','disabled');

		

		$.post(action, { 

			fio: $('#fio').val(),

			phone: $('#phone').val(),

			email: $('#email').val(),

			message: $('#message').val()

		},

			function(data){

				$('#contactform #submit').attr('disabled','');

				$('.response').remove();

				$('#contactform').before('<span class="response">'+data+'</span>');

				$('.response').slideDown();

				$('#contactform img.loader').fadeOut(500,function(){$(this).remove()});

				if(data=='send') $('#contactform').slideUp();

			}

		);

		        $('#contactform').clearForm()

		return false;

	

	});

	

});




