function NotificationManager(){
}
NotificationManager.prototype.getNumNotifications=function(){
AjaxProxy.getNumNotifications(this.getNumNotificationsCallback.bind(this));
};
NotificationManager.prototype.getNumNotificationsCallback=function(_1){
var _2=_1.numUnread;
var _3=_1.numRead;
if(_2>0){
$("notification_indicator_div").style.display="none";
$("unread_notification_indicator_div").style.display="";
var _4=$("unread_notifications_count_div");
_4.innerHTML=_2;
if(_2<10){
_4.style.right="13px";
}else{
if(_2<100){
_4.style.right="10px";
}else{
_4.innerHTML="99+";
_4.style.right="5px";
}
}
}else{
if(_3>0){
$("unread_notification_indicator_div").style.display="none";
$("notification_indicator_div").style.display="";
var _4=$("read_notifications_count_div");
_4.innerHTML=_3;
if(_3<10){
_4.style.right="13px";
}else{
if(_3<100){
_4.style.right="10px";
}else{
_4.innerHTML="99+";
_4.style.right="5px";
}
}
}else{
$("unread_notification_indicator_div").style.display="none";
$("notification_indicator_div").style.display="";
}
}
if(_1.maintWarningMsg!=null){
$("overall_alert_div").innerHTML=_1.maintWarningMsg;
new Effect.Appear($("overall_alert_div"),{duration:0.6});
}else{
$("overall_alert_div").style.display="none";
}
if(!_1.stopChecking){
this.setCheckTimer();
}
};
NotificationManager.prototype.loadNotifications=function(){
AjaxProxy.getNotificationsForUser(this.loadNotificationsCallback.bind(this));
};
NotificationManager.prototype.loadNotificationsCallback=function(_5){
var _6=$("notifications_container");
_6.innerHTML="";
if(_5==null||_5.length==0){
_6.innerHTML="<div style='width:100%;text-align:center;padding-top:20px;color:white'>You have no messages</div>";
return;
}
if(_5.length>5){
_6.style.height=18+(65*5)+"px";
}else{
_6.style.height=18+(65*_5.length)+"px";
}
var sb=[];
sb.push("<div onclick='g_NotificationManager.deleteAll()' style='cursor:pointer;padding:2px;border-bottom:1px solid #444444;font-size:10px;color:#dcdcdc;text-align:right'>remove all</div>");
for(var _8=0;_8<_5.length;_8++){
var _9=_5[_8];
sb.push("<table cellpadding='0' cellspacing='0' width='100%'><tr><td style='border-bottom:1px solid #444444'>");
sb.push("<div class='notification_message ");
if(!_9.read){
sb.push("notification_message_unread");
}
sb.push("'>");
sb.push(_9.text);
sb.push("<div class='notification_date'>");
sb.push(_9.dateString);
sb.push("</div>");
sb.push("</div>");
sb.push("</td><td style='border-bottom:1px solid #444444' valign='top'><img onclick='g_NotificationManager.deleteMessage("+_9.id+")' style='cursor:pointer;padding:4px;' src='images/notification_message_close.png'></td></tr></table>");
}
_6.innerHTML=sb.join("");
};
NotificationManager.createNotificationManager=function(){
g_NotificationManager=new NotificationManager();
g_NotificationManager.getNumNotifications();
};
NotificationManager.prototype.setCheckTimer=function(){
window.setTimeout(this.getNumNotifications.bind(this),10000);
};
NotificationManager.prototype.deleteAll=function(){
AjaxProxy.deleteAllNotificationMessages(this.deleteAllCallback.bind(this));
};
NotificationManager.prototype.deleteAllCallback=function(){
this.loadNotifications();
};
NotificationManager.prototype.deleteMessage=function(_a){
AjaxProxy.deleteNotificationMessage(_a,this.deleteMessageCallback.bind(this));
};
NotificationManager.prototype.deleteMessageCallback=function(){
this.loadNotifications();
};
NotificationManager.prototype.toggleNotifications=function(){
var _b=$("notifications_container");
if(_b.style.display=="none"){
_b.innerHTML="<div width='100%' style='padding-top:15px;text-align:center'><img src='images/ajax-loader2.gif'></div>";
_b.style.height="60px";
new Effect.Appear(_b,{from:0,to:0.9,duration:0.6,afterFinish:this.loadNotifications.bind(this)});
$("notifications_overlay").style.display="";
}else{
new Effect.Fade(_b,{duration:0.6});
$("notifications_overlay").style.display="none";
}
};
Event.observe(window,"load",NotificationManager.createNotificationManager);
