$(document).ready(function(){
	document.CSI.reset() ;
	$('#CSI').ajaxForm({
		target		:	'#contact_output',
		beforeSend	:	function(){
			$(':button[name=CMDsubmit]').attr('disabled',true).html('<SPAN CLASS="loading"><IMG SRC="2008/pages/images/loading.gif" ALIGN="absmiddle">傳送中...</SPAN>') ;
		} ,
		success			:	function(data) {
			try	{
				data	=	($('#contact_output > PRE').size())
						?	eval('('+ $('#contact_output > PRE').html() + ')')
						:	eval('('+ $('#contact_output').html() + ')') ;
				$(':button[name=CMDsubmit]').attr('disabled',false).html('<IMG SRC="2008/pages/images/email-contact-blue.gif" ALIGN="absmiddle">確認送出') ;
				alert(data['message']) ;
				if	(data['opcode'])	top.location.href	=	location.href ;
			} catch(e) {
				$('#contact_output').css('display','inline') ;
			}
		}
	}); 
});

function	form_submit() {
	var	f		=	document.CSI ;
	var	error	=	new	Array() ;
	if	($('#CSI input[type=radio][name=TYPE]:checked').size() == 0)	error.push('類型') ;
	if	(f.NAME.value == '')	error.push('姓名') ;
	if	(f.TEL.value == '')	error.push('聯絡電話') ;
	if	(f.EMAIL.value == '')	error.push('電子信箱') ;
	if	(f.AUTH_CODE.value == '')	error.push('認證碼') ;
	if	(error.length)	alert(error.join('\n') + '\n--------------------------------------------------------\n' + '請輸入上列資訊，謝謝！') ;
	else				$('#CSI').submit() ;
	return	false ;
}
