var smsEvent={maxVisibleMessages:10,errorMessageFadeOutTimeoutMs:2E3,errorMessageFadeOutTimer:null,lastMessageId:0,getMessagesIntervalMs:2E3,normalizeText:function(a){return a.replace("<","&lt;").replace(">","&gt;")}};jQuery.support.cors=!0;
smsEvent.refresh=function(a){if(void 0!=a)for($(a).find("GetSMSListResult").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(smsEvent.normalizeText((c||"[server]")+":")).appendTo(b);$("<span>").addClass("message-text").addClass(a?
"":"message-text-server").html(smsEvent.normalizeText(a)).appendTo(b);smsEvent.lastMessageId=Math.max(smsEvent.lastMessageId,d)+1});$("#mml").children().length>smsEvent.maxVisibleMessages;)$("#mml div:first-child").remove()};
smsEvent.getMessages=function(a){$.ajax({type:"POST",dataType:"xml",contentType:"text/xml; charset=utf-8",url:"/soap/GetSMSList",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><GetSMSList nSMSID="'+smsEvent.lastMessageId+'"></GetAlarmList></soap:Body></soap:Envelope>',success:smsEvent.refresh,error:function(){}});a&&window.setTimeout("smsEvent.getMessages(true)",
smsEvent.getMessagesIntervalMs)};smsEvent.showError=function(a){$("#error").html(a).fadeIn("fast");window.clearTimeout(smsEvent.errorMessageFadeOutTimer);smsEvent.errorMessageFadeOutTimer=window.setTimeout(function(){$("#error").fadeOut("slow")},smsEvent.errorMessageFadeOutTimeoutMs)};$(document).ready(function(){smsEvent.getMessages(!0)});
