(function($) {
	$.extend({
		notifier:{
			// variables
			defaults:{
				core:"notifier",
				duration:4000
			},
			notices:{},
			
			// methods
			broadcast:function(properties) {
				
				this.core();
				
				var id = "notice-" + new Date().getTime();
				
				// set notices object
				var notice = this.notices[id] = {id:id};
				for(i in properties){notice[i] = properties[i]}
				
				// box
				$("#" + this.defaults.core).append(this.box(notice));
			},
			
			// core
			core:function() {
				var core	= this.defaults.core;
				return $("#" + core).length == 0 ? $('body').append("<div id=\"" + core + "\"></div>") : $("#" + core);
			},
			
			// box
			box:function(notice) {
				var box	= $("<div id=\"" + notice.id + "\"></div>").addClass(notice.code);
				box.append($("<p></p>").append(notice.msg));
				box.append($("<div></div>").addClass("bg"));
				box.hide().fadeIn();
				this.life(box, notice.id);	
				return box;
			},
			
			// life
			life:function(box, seed) {
				if(!this.notices[seed].duration) {
					this.notices[seed].duration = this.defaults.duration
				}
				this.notices[seed].interval = {};
				this.notices[seed].interval	= setInterval(
					function() {
						//(function(seed) {
							$.notifier.destroy(seed, true);
						//});
						//(seed)
					},this.notices[seed].duration
				);
			},
			
			// destroy
			destroy:function(seed, remove) {
				clearInterval($.notifier.notices[seed].interval);
				delete $.notifier.notices[seed].interval;
				if(remove == true){$("#" + seed).fadeOut(250, function(){$(this).remove()});}
			}
		}
	});
})(jQuery)
