function contact_submit()
{
	if(contact_valid() == false)
	{
		contact_get_error();
	}
	else
	{
		var p = 'id=kontakt&'+$('form-contact').serialize();
		var a = new Ajax.Request('ajax.php',{
					method: 'post',
					parameters: p,
					onComplete: function()
					{
						contact_get_success();
						contact_del_fields();
					}
				});
	}
	
	return false;
}

function contact_get_success()
{
	if($('contact-success').style.display == 'none')
	{
		if($('contact-error').style.display == 'none')
		{
			$('contact-success').appear({ duration: 0.8 });			
		}
		else
		{
			$('contact-error').fade({ duration: 0.1, afterFinish: function(){ $('contact-success').appear({ duration: 0.7 }); } });	
		}
	}
}

function contact_get_error()
{
	if($('contact-error').style.display == 'none')
	{
		if($('contact-success').style.display == 'none')
		{
			$('contact-error').appear({ duration: 0.8 });			
		}
		else
		{
			$('contact-success').fade({ duration: 0.1, afterFinish: function(){ $('contact-error').appear({ duration: 0.7 }); } });
		}
	}
}

function contact_valid()
{
	if($F('topic')=='') 	
		return false;
	
	if($F('email')=='') 	
		return false;
	
	if($F('message')=='') 
		return false;
	
	return true;
}

function contact_del_fields()
{
	$('topic').value = '';
	$('email').value = '';
	$('message').value = '';
}
