//namespace definition
var Lsi = Lsi || {};

/**
 * LsiAlert use jQueryUI Dialogs to show alerts.
 */
Lsi.Alert = function(config) {
	//declaration and attributes
	var defaults = {
		
		content     : '',
		wrapClass   : '',
		duration    : 0,
		options     : {
			zIndex      : 5000,
			minHeight : 110,
			hide      : 'fade'
			
		}
		
	};

	$.extend(this, defaults, config);
	
	this.content = '<div class="' + this.wrapClass + '">' + this.content + '</div>';
	
};

Lsi.Alert.prototype = {
	//methods
	
	/*
	 * display a simple dialog box
	 *
	 * this.options is directly sent to jQueryUI Dialog as argument
	 */
	show : function() {
		var me = this;
		this.instance = $(this.content).dialog(this.options);
		
		if (this.duration > 0) {
			
			setTimeout(function(){
				me.hide();
			}, this.duration);
			
		}
	},
	

	
	/**
	 * Hide the dialog box
	 */
	hide : function() {
		
		this.instance.dialog('close');
		
	}
		
};

Lsi.Alert.show = function(msg, options) {
	
	options = options || {};
	
	options.content = msg;
	
	var alert = new Lsi.Alert(options);
	alert.show();
	
};
