var chat={maxVisibleMessages:10,errorMessageFadeOutTimeoutMs:2E3,errorMessageFadeOutTimer:null,lastMessageId:0,getMessagesIntervalMs:2E3,normalizeText:function(a){return a.replace("<","&lt;").replace(">","&gt;")}};jQuery.support.cors=!0;
chat.refresh=function(a){if(void 0!=a)for($(a).find("GetAlarmListResult").find("Items").each(function(){var a=$(this),b=$("<div>").addClass("message-row").appendTo("#mml"),d=a.attr("ActorID"),e=a.attr("ActiveTime"),c=a.attr("Source"),a=a.attr("Message");$("<span>").addClass("message-timestamp").html("["+e+"]").prependTo(b);$("<span>").addClass("message-user").addClass(c?"":"message-user-server").html(chat.normalizeText((c||"[server]")+":")).appendTo(b);$("<span>").addClass("message-text").addClass(a?
"":"message-text-server").html(chat.normalizeText(a)).appendTo(b);chat.lastMessageId=Math.max(chat.lastMessageId,d)+1});$("#mml").children().length>chat.maxVisibleMessages;)$("#mml div:first-child").remove()};
chat.getMessages=function(a){$.ajax({type:"POST",dataType:"xml",contentType:"text/xml; charset=utf-8",url:"/soap/GetAlarmList",data:'<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetAlarmList nAlarmID="'+chat.lastMessageId+'"></GetAlarmList></soap:Body></soap:Envelope>',success:chat.refresh,error:function(){}});a&&window.setTimeout("chat.getMessages(true)",
chat.getMessagesIntervalMs)};chat.showError=function(a){$("#error").html(a).fadeIn("fast");window.clearTimeout(chat.errorMessageFadeOutTimer);chat.errorMessageFadeOutTimer=window.setTimeout(function(){$("#error").fadeOut("slow")},chat.errorMessageFadeOutTimeoutMs)};$(document).ready(function(){chat.getMessages(!0)});
