function showMailForm() {
	$('mailform').show().focusFirstElement();
}

function hideMailForm() {
	$('mailform').hide();
}

function refreshTuringTest() {
	$('turingtestimage').src = 'turingtest.asp?r=' + Math.random();
}

function checkMailForm(event) {
	if ($F('fromwho').length == 0) {
		alert('寄件人未填！');
		$('fromwho').activate();
		event.stop();
	}
	else if ($F('fromwhere').length == 0) {
		alert('寄件地址未填！');
		$('fromwhere').activate();
		event.stop();
	}
	else if ($F('subject').length == 0) {
		alert('主旨未填！');
		$('subject').activate();
		event.stop();
	}
	else if ($F('body').length == 0) {
		alert('內容未填！');
		$('body').activate();
		event.stop();
	}
	else if ($F('turingtest').length == 0) {
		alert('驗證碼未填！');
		$('turingtest').activate();
		event.stop();
	}
}

Event.observe(window, 'load', function() {
	$('contactus').observe('click', showMailForm);
	$('reset').observe('click', hideMailForm);
	$('refreshturingtest').observe('click', refreshTuringTest);
	$('mailform').observe('submit', checkMailForm);
});
