/**
 * @author lk
 */
Event.observe(window,'load', function(){
	$('do_advice').observe('click',function(){
		ChkForm();
	});
});

String.prototype.trim = function(){
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}

//鼠标文字显示隐藏
function mouseclick(obj,values){
	if(obj.value==''){
		obj.value = values;
	} else  if(obj.value == values)
		obj.value = '';
}

function ChkForm(){
	var sendContent;
	var sendConnect;
	sendContent = $('sendContent').value;
	sendConnect = $('sendConnect').value;
	
	if(sendContent.trim() == ""){
		$('tips').show();
		$('tips').update('请填写您反馈给我们的信息！');
		return;
	}
	if(sendContent.trim().length < 8){
		$('tips').show();
		$('tips').update('请留下您真诚的建议！');
		return;
	}	
	if((sendConnect.trim() == "") || (sendConnect == '请留下您的QQ、MSN、手机号或E-mail帐号，以便得到回复')){
		$('tips').show();
		$('tips').update('请填写您反馈给我们的联系方式！');
		return;
	}
	$('tips').hide();
	url = "/ajax/advice";
	var pars = "sendContent="+sendContent+'&sendConnect='+encodeURIComponent(sendConnect);
	var searchAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (e) { ajax_show(e); } });	
}

function ajax_show(e){
	var r = e.responseText;
	//eval('r='+r);
	//$('tips').show();
	//$('tips').update(r);
	//return;
	if((e.status == 200) && (r == 1)){
		$('sendMsg').hide();
		$('returnMsg').show();
		return;
	} else if(r == 0){
		$('tips').update('参数丢失');
		return;
	}
}