jQuery.fn.resetDefaultValue = function() {
	function _clearDefaultValue() {
		var _$ = $(this);
		if ( _$.val() == this.defaultValue ) { _$.val(''); }
	};
	function _resetDefaultValue() {
		var _$ = $(this);
		if ( _$.val() == '' ) { _$.val(this.defaultValue); }
	};
	return this.click(_clearDefaultValue).focus(_clearDefaultValue).blur(_resetDefaultValue);
}

$(document).ready(function() {
    
    $('#contacts_send').hide();
    $('#contacts_error').hide();
    $('#loading').hide();
    
    $('input').resetDefaultValue();
    $('textarea').resetDefaultValue();

  $('a#contact').click(function() {
    $('#contacts_form').slideToggle(400);
    $('#contacts_send').hide();
    $('#contacts_error').hide();
    $('#loading').hide();
    return false;
  });
  $('#contacts_submit').click(function() {
    if($("#from").val() == 'Your email')
        $('#contacts_error').show();
    else if($("#from").val() == '')
        $('#contacts_error').show();
    else if($("#body").val() == 'Message')
        $('#contacts_error').show();
    else if($("#body").val() == '')
        $('#contacts_error').show();
    else {
    $('#contacts_error').hide();
    $('#loading').show();
    $.post("send.php",{  
        body: $("#body").val(),  
        from: $("#from").val()  
    }); 
    $('#loading').hide();
	$("#contacts_form").slideUp(400);
    $('#contacts_send').show();
    }
    return false;
  }); 
});