PeriodicalExecuter.prototype.stop=function(){if(!this.timer){return}clearInterval(this.timer);this.timer=null};var PortalNotice=Class.create();PortalNotice.prototype={initialize:function(a){this.pExecuterNotice=null;this.setOptions(a);this.cookieOptions=[this.options.cookieExpires,this.options.cookiePath,this.options.cookieDomain,this.options.cookieSecure]},setOptions:function(a){this.options={noticeId:"portal_main_notice",cookieWinMinimizedName:"portal_notice_minimized",cookieWinClosedName:"portal_notice_closed",cookieExpires:"",cookiePath:"/",cookieDomain:"",cookieSecure:"",infoTypeNotice:"info",infoStyleColor:"#000000",infoStyleBackgroundColor:"#f90",errorTypeNotice:"error",errorStyleColor:"#000000",errorStyleBackgroundColor:"#ff0000",noticeUpdaterInterval:10*60,getNoticeUrl:"/application/get_main_notice",closeableNotice:true,};Object.extend(this.options,a||{})},displayNotice:function(b){try{if(b){$(this.options.noticeId).style.display="inline"}else{$(this.options.noticeId).style.display="none"}}catch(a){}},setNoticeStyle:function(){noticeStyle=document.styleSheets[0];length=noticeStyle.cssRules?noticeStyle.cssRules.length:noticeStyle.rules.length;declaration="#"+this.options.noticeId+"{top:0px;position:absolute;margin:0px;z-index:9998;overflow:auto;left:25%;right:25%;font:normal 8pt verdana, arial, helvetica, sans-serif;padding:3px 5px 3px 5px;}";noticeStyle.insertRule(declaration,length);noticeStyle=document.styleSheets[0];length=noticeStyle.cssRules?noticeStyle.cssRules.length:noticeStyle.rules.length;declaration="#"+this.options.noticeId+" a:link, #"+this.options.noticeId+" a:visited{color:#000000;text-decoration:none;}";noticeStyle.insertRule(declaration,length);noticeStyle=document.styleSheets[0];length=noticeStyle.cssRules?noticeStyle.cssRules.length:noticeStyle.rules.length;declaration="#"+this.options.noticeId+" a:hover{color:#000000;text-decoration:underline;}";noticeStyle.insertRule(declaration,length)},setNoticeType:function(a){try{var c=$(this.options.noticeId);switch(a){case this.options.infoTypeNotice:c.style.color=this.options.infoStyleColor;c.style.backgroundColor=this.options.infoStyleBackgroundColor;break;default:c.style.color=this.options.errorStyleColor;c.style.backgroundColor=this.options.errorStyleBackgroundColor;break}}catch(b){}},start:function(){if(this.pExecuterNotice==null){this.getNotice();this.pExecuterNotice=new PeriodicalExecuter(function(){this.getNotice()}.bind(this),this.options.noticeUpdaterInterval)}else{this.stop()}},stop:function(){try{this.pExecuterNotice.stop()}catch(a){}this.pExecuterNotice=null},getCookie:function(c){var b=document.cookie;var e=c+"=";var d=b.indexOf("; "+e);if(d==-1){d=b.indexOf(e);if(d!=0){return null}}else{d+=2}var a=document.cookie.indexOf(";",d);if(a==-1){a=b.length}return unescape(b.substring(d+e.length,a))},setCookie:function(a,c,b){document.cookie=a+"="+escape(c)+((b[0])?"; expires="+b[0].toGMTString():"")+((b[1])?"; path="+b[1]:"")+((b[2])?"; domain="+b[2]:"")+((b[3])?"; secure":"")},doMinimizeableNotice:function(){try{buttonSizeElem=$(this.options.noticeId+"_buttonsize");buttonSizeElem.onmousedown=this.onMouseDownMinimizeNotice.bind(this);buttonSizeElem.setAttribute("title","minimize notice");buttonSizeElem.innerHTML="[-]";$(this.options.noticeId+"_description").style.display="inline"}catch(a){}},doMaximizeableNotice:function(){try{buttonSizeElem=$(this.options.noticeId+"_buttonsize");buttonSizeElem.onmousedown=this.onMouseDownMaximizeNotice.bind(this);buttonSizeElem.setAttribute("title","maximize notice");buttonSizeElem.innerHTML="[+]";$(this.options.noticeId+"_description").style.display="none"}catch(a){}},onMouseDownMinimizeNotice:function(){this.doMaximizeableNotice();this.setCookie(this.options.cookieWinMinimizedName,"1",this.cookieOptions)},onMouseDownMaximizeNotice:function(){this.doMinimizeableNotice();this.setCookie(this.options.cookieWinMinimizedName,"0",this.cookieOptions)},onMouseDownCloseNotice:function(){this.setCookie(this.options.cookieWinClosedName,"1",this.cookieOptions);this.displayNotice(false);this.stop()},initializeWindowButtons:function(){try{if(this.getCookie(this.options.cookieWinMinimizedName)=="1"){this.doMaximizeableNotice()}else{this.doMinimizeableNotice()}buttonCloseElem=$(this.options.noticeId+"_buttonclose");buttonCloseElem.onmousedown=this.onMouseDownCloseNotice.bind(this);buttonCloseElem.style.display=this.options.closeableNotice?"inline":"none"}catch(a){}},createNotice:function(g,c,a){try{var f=$(this.options.noticeId);if(f==undefined||f==null){var f=document.createElement("div");f.setAttribute("id",this.options.noticeId);f.setAttribute("align","center");document.body.appendChild(f);this.setNoticeStyle()}var b="<div style='display:inline;'><div align='center'><b>"+g+"</b></div><div align='right' style='top:2px;right:3px;position:absolute;'><a id='"+this.options.noticeId+"_buttonsize' href='javascript:void(0);'></a>&nbsp;<a id='"+this.options.noticeId+"_buttonclose' href='javascript:void(0);' title='close notice'>[x]</a></div></div><div id='"+this.options.noticeId+"_description' align='justify'>"+c+"</div>";f.innerHTML=b;if(a==undefined||a==null||a==""){a=this.options.errorTypeNotice}this.initializeWindowButtons();this.setNoticeType(a);this.displayNotice(true)}catch(d){}},getNotice:function(){if(this.getCookie(this.options.cookieWinClosedName)=="1"){this.displayNotice(false);this.stop()}else{new Ajax.Request(this.options.getNoticeUrl,{method:"get",onFailure:function(a){}.bind(this),onSuccess:function(a){var d=a.responseText.split("||");var e=d[0];var b=d[1];var f=d[2];var c=d[3];if(e=="true"){this.createNotice(f,c,b)}else{this.displayNotice(false)}}.bind(this)})}}};