/**
 * @author yc 2009-12-03
 */
Event.observe(window, 'load', initPage);

function initPage(){
	$('btnSubmit').observe('click', function(){
		if ($('name').value.length == 0) {
			tips('请填写您的姓名')
	    	$('name').focus();
	    	return;
	    }
		if ($('title').value.length == 0) {
			tips('请填写标题')
			$('title').focus();
	        return;
	    }
		if ($('content').value.length == 0) {
			tips('请填写具体内容')
			$('content').focus();
	        return;
	    }
	    $('msg').request({
	        onSuccess: function(rsp){
	            var ref = parseInt(rsp.responseText);
	            if(ref==-1){
	            	tips('留言失败')
	            	return;
	            }else if(ref==-2){
	            	tips('提交的参数不完整')
	            	return;
				}else{
					tips('提交留言成功')
					$('msg').reset();
				}
	        },
	        onFailure: function(){
	        	tips('网络故障!请稍候再试...')
	        	return;
	        }
	    });
	 })
}

function tips(msg){
	var obj = $('err_tip');
	if (obj){
			obj.update(msg);
			obj.show();
			setTimeout("h('"+obj.id+"');", 3000);
	}	
}