

var LightviewAlert = Class.create(Lightview,{
	end:function($super){
		$super();
		this.options.callback();
		this.clearOptions();
	},
	updateContent:function(){
    	this.dialog_title.update("["+this.options.title+"]");
		this.dialog_body.update(this.options.message);
		this.dialog_foot.update(
			"<input id=\"dialog_alert\" class=\"inputsubmit\" type=\"button\" value=\"请您确认\" />"
		);
		$("dialog_alert").observe("click",this.end.bind(this));
    },
    show: function(title,message,callback){
    	var mycallback=Object.isFunction(callback)?callback:Prototype.emptyFunction;
    	this.setOptions({"title":title,"message":message,"callback":mycallback});
    	this.start();
    }
});
var LightviewConfirm = Class.create(Lightview,{
	ok:function(){
		this.end();
		this.options.callback(true);
		this.clearOptions();
	},
	no:function(){
		this.end();
		this.options.callback(false);
		this.clearOptions();
	},
	updateContent:function(){
    	this.dialog_title.update("["+this.options.title+"]");
		this.dialog_body.update(this.options.message);
		this.dialog_foot.update(
			"<input id=\"dialog_ok\" class=\"inputsubmit\" type=\"button\" value=\"请您确认\" />"
			+"<input id=\"dialog_no\" class=\"inputsubmit\" type=\"button\" value=\"我要取消\" />"
		);
		$("dialog_ok").observe("click",this.ok.bind(this));
		$("dialog_no").observe("click",this.no.bind(this));
    },
    show: function(title,message,callback){
    	var mycallback=Object.isFunction(callback)?callback:Prototype.emptyFunction;
    	this.setOptions({"title":title,"message":message,"callback":mycallback});
    	this.start();
    }
});
var LightviewInput = Class.create(Lightview,{
	ok:function(){
		this.end();
		var input=$("dialog_input").value;
		this.options.callback(input);
		this.clearOptions();
	},
	updateContent:function(){
    	this.dialog_title.update("["+this.options.title+"]");
		this.dialog_body.update(
			this.options.message+"："
			+"<input id='dialog_input' type='text' class='inputtext' value=''>"
		);
		this.dialog_foot.update(
			"<input id=\"dialog_input_ok\" class=\"inputsubmit\" type=\"button\" value=\"填写完成\" />"
		);
		$("dialog_input_ok").observe("click",this.ok.bind(this));
    },
    show: function(title,message,callback){
    	var mycallback=Object.isFunction(callback)?callback:Prototype.emptyFunction;
    	this.setOptions({"title":title,"message":message,"callback":mycallback});
    	this.start();
    }
});
var LightviewPopup={};
Event.observe(window,'load', function () {
	LightviewPopup={
		Alert:new LightviewAlert(),
		Confirm:new LightviewConfirm(),
		Input:new LightviewInput(),
		alert:function(title,message,callback){
			this.Alert.show(title,message,callback);
		},
		confirm:function(title,message,callback){
			this.Confirm.show(title,message,callback);
		},
		input:function(title,message,callback){
			this.Input.show(title,message,callback);
		}
	}
});