var contactForm = 
{
	submit: function()
	{
		$('form_status').hide();
		$('form_error').hide();
		return contactForm.validate();
	},
	validate: function()
	{
		var name = contactForm.trim($F('name'));
		var email = contactForm.trim($F('email'));
		var message = contactForm.trim($F('message'));
		
		if(name.length < 3 || email.length < 6 || message.length < 5)
		{
			contactForm.showError('Musisz poprawnie wypełnić wszystkie pola oznaczone gwiazdką!');
			return false;
		}
		if(contactForm.isEmail(email) == false)
		{
			contactForm.showError('Prosimy o podanie poprawnego adresu email!');
			return false;		
		}
		return true;
	},
	showError: function(errorText)
	{
		$('form_error').innerHTML = errorText;
		$('form_error').show();
		new Effect.Highlight('form_error', {startcolor:'#ffbbbb', endcolor:'#ffffff', duration: 5});	
	},
	trim: function(string)
	{
		return string.replace(/^\s+|\s+$/, '');
	},
	isEmail: function(string)
	{
		return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
	}
}
