function clearFormValues() {
 $$('input[type="text"], textarea').each(function(s, index) {
 	Event.observe(s, 'focus', function(event) {
 		if (this.value == this.defaultValue) {
 			Field.clear( this );
 		}
 	});
 	Event.observe(s, 'blur', function(event) {
 		if (this.value == "") {
 			this.value = this.defaultValue;
 		}
 	});
 });
}

function sendEmail(e)
{
		var url = 'kontakt.php';
		var pars = Form.serialize('wyslijWiadomosc');
		var myAjax = new Ajax.Request( url, {
			method: 'post', 
			parameters: pars,  
			onComplete: showResponse 
		});
		e.stop();
}

function showResponse()
{
	new Insertion.After('wyslijWiadomosc', '<p>Wiadomość została wysłana.</p>')
	$('wyslijWiadomosc').reset();
} 

document.observe("dom:loaded", function() {
	clearFormValues();
	Event.observe('submit', 'click', sendEmail, false);
});
