(function(g){var a,d,f,c;g.extend({pnotify_remove_all:function(){var e=f.data("pnotify");e&&e.length&&g.each(e,function(){this.pnotify_remove&&this.pnotify_remove()})},pnotify_position_all:function(){d&&clearTimeout(d);d=null;var e=f.data("pnotify");if(e&&e.length){g.each(e,function(){var q=this.opts.pnotify_stack;if(q){if(!q.nextpos1){q.nextpos1=q.firstpos1}if(!q.nextpos2){q.nextpos2=q.firstpos2}if(!q.addpos2){q.addpos2=0}if(this.css("display")!="none"){var m,n,o={},k;switch(q.dir1){case"down":k="top";break;case"up":k="bottom";break;case"left":k="right";break;case"right":k="left";break}m=parseInt(this.css(k));if(isNaN(m)){m=0}if(typeof q.firstpos1=="undefined"){q.firstpos1=m;q.nextpos1=q.firstpos1}var p;switch(q.dir2){case"down":p="top";break;case"up":p="bottom";break;case"left":p="right";break;case"right":p="left";break}n=parseInt(this.css(p));if(isNaN(n)){n=0}if(typeof q.firstpos2=="undefined"){q.firstpos2=n;q.nextpos2=q.firstpos2}if(q.dir1=="down"&&q.nextpos1+this.height()>c.height()||q.dir1=="up"&&q.nextpos1+this.height()>c.height()||q.dir1=="left"&&q.nextpos1+this.width()>c.width()||q.dir1=="right"&&q.nextpos1+this.width()>c.width()){q.nextpos1=q.firstpos1;q.nextpos2+=q.addpos2+10;q.addpos2=0}if(q.animation&&q.nextpos2<n){switch(q.dir2){case"down":o.top=q.nextpos2+"px";break;case"up":o.bottom=q.nextpos2+"px";break;case"left":o.right=q.nextpos2+"px";break;case"right":o.left=q.nextpos2+"px";break}}else{this.css(p,q.nextpos2+"px")}switch(q.dir2){case"down":case"up":if(this.outerHeight(true)>q.addpos2){q.addpos2=this.height()}break;case"left":case"right":if(this.outerWidth(true)>q.addpos2){q.addpos2=this.width()}break}if(q.nextpos1){if(q.animation&&(m>q.nextpos1||o.top||o.bottom||o.right||o.left)){switch(q.dir1){case"down":o.top=q.nextpos1+"px";break;case"up":o.bottom=q.nextpos1+"px";break;case"left":o.right=q.nextpos1+"px";break;case"right":o.left=q.nextpos1+"px";break}}else{this.css(k,q.nextpos1+"px")}}if(o.top||o.bottom||o.right||o.left){this.animate(o,{duration:500,queue:false})}switch(q.dir1){case"down":case"up":q.nextpos1+=this.height()+10;break;case"left":case"right":q.nextpos1+=this.width()+10;break}}}});g.each(e,function(){var k=this.opts.pnotify_stack;if(k){k.nextpos1=k.firstpos1;k.nextpos2=k.firstpos2;k.addpos2=0;k.animation=true}})}},pnotify:function(q){f||(f=g("body"));c||(c=g(window));var r,m;if(typeof q!="object"){m=g.extend({},g.pnotify.defaults);m.pnotify_text=q}else{m=g.extend({},g.pnotify.defaults,q)}if(m.pnotify_before_init){if(m.pnotify_before_init(m)===false){return null}}var n,o=function(x,v){e.css("display","none");var w=document.elementFromPoint(x.clientX,x.clientY);e.css("display","block");var u=g(w),t=u.css("cursor");e.css("cursor",t!="auto"?t:"default");if(!n||n.get(0)!=w){if(n){b.call(n.get(0),"mouseleave",x.originalEvent);b.call(n.get(0),"mouseout",x.originalEvent)}b.call(w,"mouseenter",x.originalEvent);b.call(w,"mouseover",x.originalEvent)}b.call(w,v,x.originalEvent);n=u},e=g("<div />",{"class":"ui-pnotify "+m.pnotify_addclass,css:{display:"none"},mouseenter:function(s){m.pnotify_nonblock&&s.stopPropagation();if(m.pnotify_mouse_reset&&r=="out"){e.stop(true);r="in";e.css("height","auto").animate({width:m.pnotify_width,opacity:m.pnotify_nonblock?m.pnotify_nonblock_opacity:m.pnotify_opacity},"fast")}m.pnotify_nonblock&&e.animate({opacity:m.pnotify_nonblock_opacity},"fast");m.pnotify_hide&&m.pnotify_mouse_reset&&e.pnotify_cancel_remove();m.pnotify_closer&&!m.pnotify_nonblock&&e.closer.show()},mouseleave:function(s){m.pnotify_nonblock&&s.stopPropagation();n=null;e.css("cursor","auto");m.pnotify_nonblock&&r!="out"&&e.animate({opacity:m.pnotify_opacity},"fast");m.pnotify_hide&&m.pnotify_mouse_reset&&e.pnotify_queue_remove();e.closer.hide();g.pnotify_position_all()},mouseover:function(s){m.pnotify_nonblock&&s.stopPropagation()},mouseout:function(s){m.pnotify_nonblock&&s.stopPropagation()},mousemove:function(s){if(m.pnotify_nonblock){s.stopPropagation();o(s,"onmousemove")}},mousedown:function(s){if(m.pnotify_nonblock){s.stopPropagation();s.preventDefault();o(s,"onmousedown")}},mouseup:function(s){if(m.pnotify_nonblock){s.stopPropagation();s.preventDefault();o(s,"onmouseup")}},click:function(s){if(m.pnotify_nonblock){s.stopPropagation();o(s,"onclick")}},dblclick:function(s){if(m.pnotify_nonblock){s.stopPropagation();o(s,"ondblclick")}}});e.opts=m;if(m.pnotify_shadow&&!g.browser.msie){e.shadow_container=g("<div />",{"class":"ui-widget-shadow ui-corner-all ui-pnotify-shadow"}).prependTo(e)}e.container=g("<div />",{"class":"ui-widget ui-widget-content ui-corner-all ui-pnotify-container "+(m.pnotify_type=="error"?"ui-state-error":"ui-state-highlight")}).appendTo(e);e.pnotify_version="1.0.1";e.pnotify=function(t){var s=m;if(typeof t=="string"){m.pnotify_text=t}else{m=g.extend({},m,t)}e.opts=m;if(m.pnotify_shadow!=s.pnotify_shadow){if(m.pnotify_shadow&&!g.browser.msie){e.shadow_container=g("<div />",{"class":"ui-widget-shadow ui-pnotify-shadow"}).prependTo(e)}else{e.children(".ui-pnotify-shadow").remove()}}if(m.pnotify_addclass===false){e.removeClass(s.pnotify_addclass)}else{m.pnotify_addclass!==s.pnotify_addclass&&e.removeClass(s.pnotify_addclass).addClass(m.pnotify_addclass)}if(m.pnotify_title===false){e.title_container.hide("fast")}else{m.pnotify_title!==s.pnotify_title&&e.title_container.html(m.pnotify_title).show(200)}if(m.pnotify_text===false){e.text_container.hide("fast")}else{if(m.pnotify_text!==s.pnotify_text){if(m.pnotify_insert_brs){m.pnotify_text=m.pnotify_text.replace(/\n/g,"<br />")}e.text_container.html(m.pnotify_text).show(200)}}e.pnotify_history=m.pnotify_history;m.pnotify_type!=s.pnotify_type&&e.container.toggleClass("ui-state-error ui-state-highlight");if(m.pnotify_notice_icon!=s.pnotify_notice_icon&&m.pnotify_type=="notice"||m.pnotify_error_icon!=s.pnotify_error_icon&&m.pnotify_type=="error"||m.pnotify_type!=s.pnotify_type){e.container.find("div.ui-pnotify-icon").remove();if(m.pnotify_error_icon&&m.pnotify_type=="error"||m.pnotify_notice_icon){g("<div />",{"class":"ui-pnotify-icon"}).append(g("<span />",{"class":m.pnotify_type=="error"?m.pnotify_error_icon:m.pnotify_notice_icon})).prependTo(e.container)}}m.pnotify_width!==s.pnotify_width&&e.animate({width:m.pnotify_width});m.pnotify_min_height!==s.pnotify_min_height&&e.container.animate({minHeight:m.pnotify_min_height});m.pnotify_opacity!==s.pnotify_opacity&&e.fadeTo(m.pnotify_animate_speed,m.pnotify_opacity);if(m.pnotify_hide){s.pnotify_hide||e.pnotify_queue_remove()}else{e.pnotify_cancel_remove()}e.pnotify_queue_position();return e};e.pnotify_queue_position=function(){d&&clearTimeout(d);d=setTimeout(g.pnotify_position_all,10)};e.pnotify_display=function(){e.parent().length||e.appendTo(f);if(m.pnotify_before_open){if(m.pnotify_before_open(e)===false){return}}e.pnotify_queue_position();if(m.pnotify_animation=="fade"||m.pnotify_animation.effect_in=="fade"){e.show().fadeTo(0,0).hide()}else{m.pnotify_opacity!=1&&e.show().fadeTo(0,m.pnotify_opacity).hide()}e.animate_in(function(){m.pnotify_after_open&&m.pnotify_after_open(e);e.pnotify_queue_position();m.pnotify_hide&&e.pnotify_queue_remove()})};e.pnotify_remove=function(){if(e.timer){window.clearTimeout(e.timer);e.timer=null}if(m.pnotify_before_close){if(m.pnotify_before_close(e)===false){return}}e.animate_out(function(){if(m.pnotify_after_close){if(m.pnotify_after_close(e)===false){return}}e.pnotify_queue_position();m.pnotify_remove&&e.detach()})};e.animate_in=function(t){r="in";var s;s=typeof m.pnotify_animation.effect_in!="undefined"?m.pnotify_animation.effect_in:m.pnotify_animation;if(s=="none"){e.show();t()}else{if(s=="show"){e.show(m.pnotify_animate_speed,t)}else{if(s=="fade"){e.show().fadeTo(m.pnotify_animate_speed,m.pnotify_opacity,t)}else{if(s=="slide"){e.slideDown(m.pnotify_animate_speed,t)}else{if(typeof s=="function"){s("in",t,e)}else{e.effect&&e.effect(s,{},m.pnotify_animate_speed,t)}}}}}};e.animate_out=function(t){r="out";var s;s=typeof m.pnotify_animation.effect_out!="undefined"?m.pnotify_animation.effect_out:m.pnotify_animation;if(s=="none"){e.hide();t()}else{if(s=="show"){e.hide(m.pnotify_animate_speed,t)}else{if(s=="fade"){e.fadeOut(m.pnotify_animate_speed,t)}else{if(s=="slide"){e.slideUp(m.pnotify_animate_speed,t)}else{if(typeof s=="function"){s("out",t,e)}else{e.effect&&e.effect(s,{},m.pnotify_animate_speed,t)}}}}}};e.pnotify_cancel_remove=function(){e.timer&&window.clearTimeout(e.timer)};e.pnotify_queue_remove=function(){e.pnotify_cancel_remove();e.timer=window.setTimeout(function(){e.pnotify_remove()},isNaN(m.pnotify_delay)?0:m.pnotify_delay)};e.closer=g("<div />",{"class":"ui-pnotify-closer",css:{cursor:"pointer",display:"none"},click:function(){e.pnotify_remove();e.closer.hide()}}).append(g("<span />",{"class":"ui-icon ui-icon-circle-close"})).appendTo(e.container);if(m.pnotify_error_icon&&m.pnotify_type=="error"||m.pnotify_notice_icon){g("<div />",{"class":"ui-pnotify-icon"}).append(g("<span />",{"class":m.pnotify_type=="error"?m.pnotify_error_icon:m.pnotify_notice_icon})).appendTo(e.container)}e.title_container=g("<div />",{"class":"ui-pnotify-title",html:m.pnotify_title}).appendTo(e.container);m.pnotify_title===false&&e.title_container.hide();if(m.pnotify_insert_brs&&typeof m.pnotify_text=="string"){m.pnotify_text=m.pnotify_text.replace(/\n/g,"<br />")}e.text_container=g("<div />",{"class":"ui-pnotify-text",html:m.pnotify_text}).appendTo(e.container);m.pnotify_text===false&&e.text_container.hide();typeof m.pnotify_width=="string"&&e.css("width",m.pnotify_width);typeof m.pnotify_min_height=="string"&&e.container.css("min-height",m.pnotify_min_height);e.pnotify_history=m.pnotify_history;var p=f.data("pnotify");if(p==null||typeof p!="object"){p=[]}p=m.pnotify_stack.push=="top"?g.merge([e],p):g.merge(p,[e]);f.data("pnotify",p);m.pnotify_after_init&&m.pnotify_after_init(e);if(m.pnotify_history){var k=f.data("pnotify_history");if(typeof k=="undefined"){k=g("<div />",{"class":"ui-pnotify-history-container ui-state-default ui-corner-bottom",mouseleave:function(){k.animate({top:"-"+a+"px"},{duration:100,queue:false})}}).append(g("<div />",{"class":"ui-pnotify-history-header",text:"Redisplay"})).append(g("<button />",{"class":"ui-pnotify-history-all ui-state-default ui-corner-all",text:"All",mouseenter:function(){g(this).addClass("ui-state-hover")},mouseleave:function(){g(this).removeClass("ui-state-hover")},click:function(){g.each(p,function(){this.pnotify_history&&this.pnotify_display&&this.pnotify_display()});return false}})).append(g("<button />",{"class":"ui-pnotify-history-last ui-state-default ui-corner-all",text:"Last",mouseenter:function(){g(this).addClass("ui-state-hover")},mouseleave:function(){g(this).removeClass("ui-state-hover")},click:function(){for(var s=1;!p[p.length-s]||!p[p.length-s].pnotify_history||p[p.length-s].is(":visible");){if(p.length-s===0){return false}s++}s=p[p.length-s];s.pnotify_display&&s.pnotify_display();return false}})).appendTo(f);a=g("<span />",{"class":"ui-pnotify-history-pulldown ui-icon ui-icon-grip-dotted-horizontal",mouseenter:function(){k.animate({top:"0"},{duration:100,queue:false})}}).appendTo(k).offset().top+2;k.css({top:"-"+a+"px"});f.data("pnotify_history",k)}}m.pnotify_stack.animation=false;e.pnotify_display();return e}});var l=/^on/,j=/^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/,i=/^(focus|blur|select|change|reset)$|^key(press|down|up)$/,h=/^(scroll|resize|(un)?load|abort|error)$/,b=function(k,m){var e;k=k.toLowerCase();if(document.createEvent&&this.dispatchEvent){k=k.replace(l,"");if(k.match(j)){g(this).offset();e=document.createEvent("MouseEvents");e.initMouseEvent(k,m.bubbles,m.cancelable,m.view,m.detail,m.screenX,m.screenY,m.clientX,m.clientY,m.ctrlKey,m.altKey,m.shiftKey,m.metaKey,m.button,m.relatedTarget)}else{if(k.match(i)){e=document.createEvent("UIEvents");e.initUIEvent(k,m.bubbles,m.cancelable,m.view,m.detail)}else{if(k.match(h)){e=document.createEvent("HTMLEvents");e.initEvent(k,m.bubbles,m.cancelable)}}}e&&this.dispatchEvent(e)}else{k.match(l)||(k="on"+k);e=document.createEventObject(m);this.fireEvent(k,e)}};g.pnotify.defaults={pnotify_title:false,pnotify_text:false,pnotify_addclass:"",pnotify_nonblock:false,pnotify_nonblock_opacity:0.2,pnotify_history:true,pnotify_width:"300px",pnotify_min_height:"16px",pnotify_type:"notice",pnotify_notice_icon:"ui-icon ui-icon-info",pnotify_error_icon:"ui-icon ui-icon-alert",pnotify_animation:"fade",pnotify_animate_speed:"slow",pnotify_opacity:1,pnotify_shadow:false,pnotify_closer:true,pnotify_hide:true,pnotify_delay:8000,pnotify_mouse_reset:true,pnotify_remove:true,pnotify_insert_brs:true,pnotify_stack:{dir1:"down",dir2:"left",push:"bottom"}}})(jQuery);
