
function UA(sInstance,sGrp,oTypes){this.instanceName=sInstance;this.group=sGrp;this.types=oTypes;this.module={'def':'http://ua.helizet.com/','help':'http://helizet.com'};this.pTimerForObs=0;this.pTimerForDisp=0;this.nReqInterval=5000;this.nDispInterval=3000;this.nDispIdx=0;this.actlist=[];this.loglist=[];this.SCRIPT_LOG='_NS_UA_LOG';this.SCRIPT_REQ='_NS_UA_REQ';this.DISP_CONT='_NS_UA_DISP';this.DISP_CONT_CLS='observedisp';this.DISP_TOP_MARGIN=30;}
UA.prototype.setGroupKey=function(s){this.group=s;}
UA.prototype.log=function(sT){if(!sT){return false;}
for(var i=0,imax=this.loglist.length;i<imax;i++){if(this.loglist[i]==sT){return;}}
this.loglist.push(sT);this._load(this.SCRIPT_LOG,this._makeUrlForLogging(sT));}
UA.prototype.observe=function(){if(this.pTimerForObs){clearInterval(this.pTimerForObs);this.pTimerForObs=0;}
this.pTimerForObs=setInterval(this.request.bind(this),this.nReqInterval);}
UA.prototype.show=function(){if(jQuery('#'+this.DISP_CONT).is(':visible')){jQuery('#'+this.DISP_CONT).hide();}
if(this.actlist.length<=this.nDispIdx){clearTimeout(this.pTimerForDisp);this.pTimerForDisp=0;this.nDispIdx=this.actlist.length;return;}
this._displayLog(this.actlist[this.nDispIdx].DispName,this.types[this.actlist[this.nDispIdx].TypeKey]);this.nDispIdx++;this.pTimerForDisp=setTimeout(this.show.bind(this),this.nDispInterval);}
UA.prototype.callback=function(res){if(res.error){return;}
for(var i=0,imax=res.actlist.length;i<imax;i++){if(!this._isDuplicated(res.actlist[i])){this.actlist.push(res.actlist[i]);}}
if(!this.pTimerForDisp){this.show();}}
UA.prototype.request=function(){if(this.actlist.length<=this.nDispIdx){this._load(this.SCRIPT_REQ,this._makeUrlForRequest());}}
UA.prototype._isDuplicated=function(o){for(var j=0,jmax=this.actlist.length;j<jmax;j++){if(this.actlist[j].DispName==o.DispName&&this.actlist[j].TypeKey==o.TypeKey){return true;}}
return false;}
UA.prototype._displayLog=function(sN,sDesc){var oDisp=jQuery('#'+this.DISP_CONT);if(!oDisp.length){var css={'right':'5px','position':'absolute','border':'1px solid #DCEAF3','background':'#F1F9FC','color':'#277BB7','letter-spacing':'-0.1em','font-size':'12px','padding':'5px 5px 4px 5px'}
oDisp=jQuery(document.createElement('div'));oDisp.css(css);oDisp.attr('id',this.DISP_CONT).attr('class',this.DISP_CONT_CLS).appendTo('body');}
oDisp.css('top',(jQuery(window).height()+jQuery(document).scrollTop()-30)+'px');oDisp.html('<strong>'+sN+'</strong>님께서 '+sDesc+' <a href="'+this.module.help+'" target="_blank"><strong>?</strong></a>');oDisp.hide();oDisp.show();jQuery(document).scroll(function(){oDisp.css('top',(jQuery(window).height()+jQuery(document).scrollTop()-30)+'px');});}
UA.prototype._makeUrlForRequest=function(){return this.module.def+'OBSERVE'+'/'+[this.group,this.instanceName].join('/');}
UA.prototype._makeUrlForLogging=function(sT){return this.module.def+'LOG'+'/'+[this.group,sT].join('/');}
UA.prototype._load=function(sTypeID,s){if(jQuery('#'+sTypeID).length){jQuery('#'+sTypeID).remove();}
var ele=jQuery(document.createElement('script'));ele.attr('id',sTypeID).attr('src',s+'?'+(new Date()).getTime()).attr('type','text/javascript').ready(function(){ele.remove();}).appendTo('head');}