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