(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,C){if(A.isFunction(this.each)){var D=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(D).slice(1))}else{A(this).data("jGrowl.instance").create(B,C)}})}};A.extend(A.fn.jGrowl.prototype,{defaults:{pool:0,header:"",group:"",sticky:false,position:"top-right",glue:"after",theme:"default",corners:"10px",check:250,life:3000,speed:"normal",easing:"swing",closer:true,closeTemplate:"&times;",closerTemplate:"<div>[ close all ]</div>",log:function(D,B,C){},beforeOpen:function(D,B,C){},open:function(D,B,C){},beforeClose:function(D,B,C){},close:function(D,B,C){},animateOpen:{opacity:"show"},animateClose:{opacity:"hide"}},notifications:[],element:null,interval:null,create:function(C,B){var B=A.extend({},this.defaults,B);this.notifications[this.notifications.length]={message:C,options:B};B.log.apply(this.element,[this.element,C,B])},render:function(E){var D=this;var C=E.message;var B=E.options;var E=A('<div class="jGrowl-notification'+((B.group!=undefined&&B.group!="")?" "+B.group:"")+'"><div class="close">'+B.closeTemplate+'</div><div class="header">'+B.header+'</div><div class="message">'+C+"</div></div>").data("jGrowl",B).addClass(B.theme).children("div.close").bind("click.jGrowl",function(){A(this).parent().trigger("jGrowl.close")}).parent();(B.glue=="after")?A("div.jGrowl-notification:last",this.element).after(E):A("div.jGrowl-notification:first",this.element).before(E);A(E).bind("mouseover.jGrowl",function(){A(this).data("jGrowl").pause=true}).bind("mouseout.jGrowl",function(){A(this).data("jGrowl").pause=false}).bind("jGrowl.beforeOpen",function(){B.beforeOpen.apply(D.element,[D.element,C,B])}).bind("jGrowl.open",function(){B.open.apply(D.element,[D.element,C,B])}).bind("jGrowl.beforeClose",function(){B.beforeClose.apply(D.element,[D.element,C,B])}).bind("jGrowl.close",function(){A(this).trigger("jGrowl.beforeClose").animate(B.animateClose,B.speed,B.easing,function(){A(this).remove();B.close.apply(D.element,[D.element,C,B])})}).trigger("jGrowl.beforeOpen").animate(B.animateOpen,B.speed,B.easing,function(){A(this).data("jGrowl").created=new Date()}).trigger("jGrowl.open");if(A.fn.corner!=undefined){A(E).corner(B.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(D.defaults.closer)){D.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).trigger("jGrowl.close")}});if(this.notifications.length>0&&(this.defaults.pool==0||A(this.element).find("div.jGrowl-notification:parent").size()<this.defaults.pool)){this.render(this.notifications.shift())}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);