(function($) {
$.widget("ui.floatingmsgbox", {
		 init: function() {
			 var current = this.element;
			 this.message = current.html();
			 current.html('');
			 current.attr('class', '');
			 current.addClass(this.options.type);
			 current.css("display","none");
			 
			 if(this.options.close_button) {
			 	current.append('<div id="msgbox_close"></div>');
			 	var closeD = current.find("div").filter(function () {return $(this).attr("id") == "msgbox_close";});
			 
				closeD.addClass('closeDiv');
			 	closeD.click(
						  function () { 
      						current.fadeOut("slow");//, 0.33); 
    					  }
			 	);
		 	 }
			 current.append('<div id="msgbox_content"></div>');
			 var contentD = current.find("div").filter(function () {return $(this).attr("id") == "msgbox_content";});
			 contentD.addClass('contentDiv');
			 contentD.html(this.message);
			 //current.slideDown("slow");
			 current.show("slow");
			 if(this.options.auto_close)
			 	setTimeout('$("div#' + current.attr("id") + '").fadeOut("slow")', this.options.timeout);
		 },
		 destroy: function() {
			 var current = this.element;
			 alert(current.attr("id"));
			 current.css("display","none");
		 }
});

$.extend($.ui.floatingmsgbox, {
	defaults: {
		type: 'success',
		close_button: true,
		auto_close: false,
		timeout: 2000
	}
});
})(jQuery);
