var FeedbackUtil = Class.create({
	initialize: function(options,events){
		this.options = {
			type:"",content:"",feedback:"",cmd:0
		};
		this.events = {
			onInsert:null,onEncoding:null
		}
		Object.extend(this.options, options ||{});
		Object.extend(this.events, events ||{});
	},
	showInsertFeedback: function(){
		initbox("<div id=feedback_" + this.options.type + " style='background-color:#FFFFFF;'><table width='100%' height='250px;'><tr><td align=center>载入中...</td></tr></table></div>", 500, 250, null, false);
		this.initInsertFeedback();
	},
	initInsertFeedback: function(){
		this.options.cmd=1;
		(this.events.onEncoding || Prototype.emptyFunction)();
		var ajax=new Ajax.Request("/ajax/feedback.html",{
			parameters: this.options,
			onSuccess: function(res){
				var value = null;
				eval(res.responseText);
				if (value != "null") {
					ajax.feedback.setFeedbackValue(value);
				}else {
					ajax.feedback.setFeedbackValue("<table width='100%' height='250px;'><tr><td align=center>载入出错...</td></tr></table>");
				};
			}
		})
		ajax.feedback=this;
	},
	setFeedbackValue: function(value){
		$("feedback_" + this.options.type).update(value);
	},
	insertFeedback: function(obj){
		if (gid("feedbackContent").value == "") {
			gid("feedbackMsg").innerHTML = "请填写您要反馈的内容。";
			return false;
		}
		var b=(this.events.onInsert || Prototype.emptyFunction)();
		if(b){
			if(b.length>0){
				gid("feedbackMsg").innerHTML = b;
				return false;
			}
		}
		(this.events.onEncoding || Prototype.emptyFunction)();
		obj.disabled = true;
		this.options.cmd=2;
		this.options.content=encodeURIComponent(gid("feedbackContent").value);
		var ajax=new Ajax.Request("/ajax/feedback.html",{
			parameters: this.options,
			onSuccess: function(res){
				var value = null;
				eval(res.responseText);
				hideLoadbox();
				showmsg(true, "您已成功提交反馈，请耐心等待答复。");
			}
		})
	}
});