(function(B){B.jGrowl=function(D,A){if(B("#jGrowl").size()==0){B('<div id="jGrowl"></div>').addClass(B.jGrowl.defaults.position).appendTo("body")}B("#jGrowl").jGrowl(D,A)};B.fn.jGrowl=function(F,A){if(B.isFunction(this.each)){var E=arguments;return this.each(function(){var C=this;if(B(this).data("jGrowl.instance")==undefined){B(this).data("jGrowl.instance",new B.fn.jGrowl());B(this).data("jGrowl.instance").startup(this)}if(B.isFunction(B(this).data("jGrowl.instance")[F])){B(this).data("jGrowl.instance")[F].apply(B(this).data("jGrowl.instance"),B.makeArray(E).slice(1))}else{B(this).data("jGrowl.instance").notification(F,A)}})}};B.extend(B.fn.jGrowl.prototype,{defaults:{header:"",sticky:false,position:"center",glue:"after",theme:"default",corners:"10px",check:500,life:2500,speed:"fast",easing:"swing",closer:true,closeTemplate:"&times;",closerTemplate:"<div>[ закрыть все ]</div>",log:function(E,F,A){},beforeOpen:function(E,F,A){},open:function(E,F,A){},beforeClose:function(E,F,A){},close:function(E,F,A){},animateOpen:{opacity:"show"},animateClose:{opacity:"hide"}},element:null,interval:null,notification:function(G,A){var H=this;var A=B.extend({},this.defaults,A);A.log.apply(this.element,[this.element,G,A]);var F=B('<div class="jGrowl-notification"><div class="close">'+A.closeTemplate+'</div><div class="header">'+A.header+'</div><div class="message">'+G+"</div></div>").data("jGrowl",A).addClass(A.theme).children("div.close").bind("click.jGrowl",function(){B(this).unbind("click.jGrowl").parent().trigger("jGrowl.beforeClose").animate(A.animateClose,A.speed,A.easing,function(){B(this).trigger("jGrowl.close").remove()})}).parent();(A.glue=="after")?B("div.jGrowl-notification:last",this.element).after(F):B("div.jGrowl-notification:first",this.element).before(F);B(F).bind("mouseover.jGrowl",function(){B(this).data("jGrowl").pause=true}).bind("mouseout.jGrowl",function(){B(this).data("jGrowl").pause=false}).bind("jGrowl.beforeOpen",function(){A.beforeOpen.apply(H.element,[H.element,G,A])}).bind("jGrowl.open",function(){A.open.apply(H.element,[H.element,G,A])}).bind("jGrowl.beforeClose",function(){A.beforeClose.apply(H.element,[H.element,G,A])}).bind("jGrowl.close",function(){A.close.apply(H.element,[H.element,G,A])}).trigger("jGrowl.beforeOpen").animate(A.animateOpen,A.speed,A.easing,function(){B(this).data("jGrowl").created=new Date()}).trigger("jGrowl.open");if(B.fn.corner!=undefined){B(F).corner(A.corners)}if(B("div.jGrowl-notification:parent",this.element).size()>1&&B("div.jGrowl-closer",this.element).size()==0&&this.defaults.closer!=false){B(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(){B(this).siblings().children("div.close").trigger("click.jGrowl");if(B.isFunction(H.defaults.closer)){H.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).children("div.close").trigger("click.jGrowl")}});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(){jQuery(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)}});B.jGrowl.defaults=B.fn.jGrowl.prototype.defaults})(jQuery);
