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