$(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="2009/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="2009/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	(f.COMMENTS.value == '')	error.push('服務內容') ;
	if	(f.NAME.value == '')		error.push('姓名') ;
	if	(f.TEL.value == '')			error.push('電話') ;
	if	(f.AUTH_CODE.value == '')	error.push('認證碼') ;
	if	(error.length)	alert(error.join('\n') + '\n--------------------------------------------------------\n' + '請填寫上列欄位，再按「確定送出」即可。') ;
	else				$('#CSI').submit() ;
	return	false ;
}