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