
(function($){$.growl=function(m,o){if($('#growl').size()==0)$('<div id="growl"></div>').addClass($.growl.defaults.position).appendTo('body');$('#growl').growl(m,o);};$.fn.growl=function(m,o){if($.isFunction(this.each)){var args=arguments;return this.each(function(){var self=this;if($(this).data('growl.instance')==undefined){$(this).data('growl.instance',new $.fn.growl());$(this).data('growl.instance').startup(this);}
if($.isFunction($(this).data('growl.instance')[m])){$(this).data('growl.instance')[m].apply($(this).data('growl.instance'),$.makeArray(args).slice(1));}else{$(this).data('growl.instance').create(m,o);}});};};$.extend($.fn.growl.prototype,{defaults:{pool:0,header:'',group:'',sticky:false,position:'center',glue:'after',theme:'default',corners:'10px',check:250,life:6000,speed:'normal',easing:'swing',closer:true,closeTemplate:'&times;',closerTemplate:'<div>[ close all ]</div>',log:function(e,m,o){},beforeOpen:function(e,m,o){},open:function(e,m,o){},beforeClose:function(e,m,o){},close:function(e,m,o){},animateOpen:{opacity:'show'},animateClose:{opacity:'hide'}},notifications:[],element:null,interval:null,create:function(message,o){var o=$.extend({},this.defaults,o);this.notifications[this.notifications.length]={message:message,options:o};o.log.apply(this.element,[this.element,message,o]);},render:function(notification){var self=this;var message=notification.message;var o=notification.options;var notification=$('<div class="growl-notification'+((o.group!=undefined&&o.group!='')?' '+o.group:'')+'"><div class="close">'+o.closeTemplate+'</div><div class="header">'+o.header+'</div><div class="message">'+message+'</div></div>').data("growl",o).addClass(o.theme).children('div.close').bind("click.growl",function(){$(this).parent().trigger('growl.close');}).parent();(o.glue=='after')?$('div.growl-notification:last',this.element).after(notification):$('div.growl-notification:first',this.element).before(notification);$(notification).bind("mouseover.growl",function(){$(this).data("growl").pause=true;}).bind("mouseout.growl",function(){$(this).data("growl").pause=false;}).bind('growl.beforeOpen',function(){o.beforeOpen.apply(self.element,[self.element,message,o]);}).bind('growl.open',function(){o.open.apply(self.element,[self.element,message,o]);}).bind('growl.beforeClose',function(){o.beforeClose.apply(self.element,[self.element,message,o]);}).bind('growl.close',function(){$(this).trigger('growl.beforeClose').animate(o.animateClose,o.speed,o.easing,function(){$(this).remove();o.close.apply(self.element,[self.element,message,o]);});}).trigger('growl.beforeOpen').animate(o.animateOpen,o.speed,o.easing,function(){$(this).data("growl").created=new Date();}).trigger('growl.open');if($.fn.corner!=undefined)$(notification).corner(o.corners);if($('div.growl-notification:parent',this.element).size()>1&&$('div.growl-closer',this.element).size()==0&&this.defaults.closer!=false){$(this.defaults.closerTemplate).addClass('growl-closer').addClass(this.defaults.theme).appendTo(this.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).bind("click.growl",function(){$(this).siblings().children('div.close').trigger("click.growl");if($.isFunction(self.defaults.closer))self.defaults.closer.apply($(this).parent()[0],[$(this).parent()[0]]);});};},update:function(){$(this.element).find('div.growl-notification:parent').each(function(){if($(this).data("growl")!=undefined&&$(this).data("growl").created!=undefined&&($(this).data("growl").created.getTime()+$(this).data("growl").life)<(new Date()).getTime()&&$(this).data("growl").sticky!=true&&($(this).data("growl").pause==undefined||$(this).data("growl").pause!=true)){$(this).trigger('growl.close');}});if(this.notifications.length>0&&(this.defaults.pool==0||$(this.element).find('div.growl-notification:parent').size()<this.defaults.pool)){this.render(this.notifications.shift());}
if($(this.element).find('div.growl-notification:parent').size()<2){$(this.element).find('div.growl-closer').animate(this.defaults.animateClose,this.defaults.speed,this.defaults.easing,function(){$(this).remove();});};},startup:function(e){this.element=$(e).addClass('growl').append('<div class="growl-notification"></div>');this.interval=setInterval(function(){jQuery(e).data('growl.instance').update();},this.defaults.check);if($.browser.msie&&parseInt($.browser.version)<7&&!window["XMLHttpRequest"])$(this.element).addClass('ie6');},shutdown:function(){$(this.element).removeClass('growl').find('div.growl-notification').remove();clearInterval(this.interval);}});$.growl.defaults=$.fn.growl.prototype.defaults;})(jQuery);