(function(b){function a(e){var f=b("."+e.containerClass+"."+e.position),d={"top-left":{left:0,top:0},"top-right":{right:0,top:0},"bottom-right":{right:0,bottom:0},"bottom-left":{left:0,bottom:0},center:{top:0,width:"50%",left:"25%"},"bottom-center":{bottom:0,width:"50%",left:"25%"},"top-center":{top:0,width:"50%",left:"25%"}};if(f.length===0){f=b("<div></div>").addClass(e.containerClass).addClass(e.position).css(b.extend({position:e.fixed?"fixed":"absolute",padding:"10px",zIndex:9999},d[e.position])).appendTo("body")}if(e.position=="center"){f.center(true)}return f}function c(d){if(d&&d.length>0){return"notice_"+d}return"notice_"+parseInt(new Date().getTime()+Math.random(),10)}b.fn.center=function(d){return this.each(function(){var e=b(this);e.css({position:d?"absolute":"fixed",left:"50%",top:"50%",zIndex:"99"}).css({marginLeft:"-"+(e.outerWidth()/2)+"px",marginTop:"-"+(e.outerHeight()/2)+"px"});if(d){e.css({marginTop:parseInt(e.css("marginTop"),10)+b(window).scrollTop(),marginLeft:parseInt(e.css("marginLeft"),10)+b(window).scrollLeft()})}})};b.extend({noticeAdd:function(g){g=typeof(g)=="string"?{text:g}:g;g=b.extend(true,{inEffect:{opacity:"show"},showReply:true,messageId:-1,onClose:null,inEffectDuration:600,duration:10000,text:"",title:"",stay:false,type:"notice",position:"top-right",containerClass:"ui-n-container",template:"standard",fixed:false},g);var d=g.showReply;var f="<div class='ui-n-actions'><button class='showReplyButton mybutton black'>Reply</button></div>";if(!d){f=""}var j=null;if(g.onClose){j=g.onClose}var i,k=b(b.noticeAdd.templates[g.template]),h=b.trim(g.text);var e="";if(g.messageId!="new"){(g.messageId&&g.messageId>0)?e=c(g.messageId):e=c()}else{e="notice_new"}k.attr("id",e);k.data("messageId",g.messageId);b.noticeAdd.notices=b.noticeAdd.notices.add(k);i=a(g);b(".ui-n-title",k).append(g.title);b(".ui-n-content",k).append(h[0]=="<"?h+f:"<p>"+h+"</p>"+f);k.hide().addClass(g.type).appendTo(i).animate(g.inEffect,g.inEffectDuration);b(".ui-n-close",k).click(function(l){l.preventDefault();b.noticeRemove(k,j)});if(d){b(".showReplyButton",k).click(function(l){b(this).slideUp();b(".ui-n-content",k).after("<textarea class='ReplyMsg' columns='30' rows='5'></textarea>\n<button class='SendReplyBtn mybutton black'>Send</button>");b("textarea.ReplyMsg",k).bind("mouseup keyup change",function(m){if(b(this).val().length>2048){b(this).val(b(this).val().substring(0,2048));return false}})})}if(!g.stay){setTimeout(function(){b.noticeRemove(k,j)},g.duration)}return k},noticeRemove:function(d,e){if(d){d=typeof(d)=="string"?b(d):d;d.animate({opacity:"0"},600,function(){d.animate({height:"0px"},300,function(){b.noticeAdd.notices.splice(b.noticeAdd.notices.index(d),1);d.siblings().length<=0?d.parent().remove():d.remove()})})}else{b.noticeAdd.notices.fadeOut(function(){b(this).parent().remove();b.noticeAdd.notices=b([])})}if(e){e(d.data("messageId"))}if(b.noticeAdd.notices.length<1){if(e){e(null)}}}});b.noticeAdd.templates={standard:"<div class='ui-n'><div class='ow'><div class='iw'><div class='ui-n-titlebar'><span class='ui-n-title'></span><a class='ui-n-close' href='#'>X</a></div> <div class='ui-n-content'> </div></div></div></div>"};b.noticeAdd.notices=b([])})(jQuery);
