
/*
	Engine for Web Applications: Monitor Service
	Composite file "engineMonitor.js" release: 1.8.4
	Copyright 2002, 2003, 2004, 2005. All Rights Reserved.
	See http://www.imnmotion.com/projects/engine/ for more information.
	Author: Stephen W. Cote
	Email: sw.cote@gmail.com
*/

var $EPS=[],$EPI=[],$EPV="1.8.4";var D={S:"string",O:"object",F:"function",U:"undefined",N:"number"};var data_undefined;D.X=(typeof XMLHttpRequest!=D.U?XMLHttpRequest:data_undefined);D.A=(typeof ActiveXObject!=D.U?ActiveXObject:data_undefined);function $EP(c){var a,i=0,s,w=window,o,l;o=w;if(typeof c==D.S){if(!$EPI[c]){l=$EPS.length;$EPI[c]=l;$EPS[l]=c;}a=c.split(".");for(;i<a.length;){s=a[i++];if(typeof o[s]!=D.O)o[s]={};o=o[s];}}}
function GetPackage(c){return ValidatePackage(c,1);}
function ValidatePackage(c,b){var a,i=0,s,w=window,o,l;o=w;if(typeof c==D.S){a=c.split(".");l=a.length;if(l==0)return 0;for(;i<l;){s=a[i++];if(typeof o[s]!=D.O)return 0;o=o[s];}}else{return 0;}if(b)return o;return 1;}
function Package(c){$EP(c);}
$EP("$E");$E={ci:{},gc:0,v:"1.8.4",h:
function(s){var i=c=0;for(;s&&i<s.length;++i){c=(c+s.charCodeAt(i)*(i+1))&0xFFFFFFFF;}return c.toString(16);},gnbid:
function(){var d=new String(parseInt(Math.random()*9999)).toString();for(i=d.length;i<4;i++)d="0"+d;return d;},guid:
function(){var _j=$E;var i=_j.gnbid()+"-"+_j.gnbid();var d=_j.h(new String(new Date().getTime()).toString())+"-"+_j.h(location.href)+"-"+i;return d;}};$E.GG=function(){var d=new Date(),t,i=4,r,l,x=0;t=new String(d.getTime());r=new String(parseInt(Math.random()*(1000*i)));l=r.length;for(;x<i-l;x++)r="0"+r;return("swc-"+(++$E.gc)+"-"+t+"-"+r);};$E.newObject=function(n,v,r){var o={};$E.prepareObject(n,v,r,o);return o;};$E.prepareObject=function(n,v,r,o){if(!o)o={};if(!o.o)o.o={};if(!o.o.p)o.o.p={};if(!o.o.s)o.o.s={};if(!n)n="custom_object";if(!v)v="1.0";$E.IM(o,"base_object",n,v);if(r)$E.registry.ObjectRegistry.addObject(o);};$E.IM=function(o,s){var _js=$E,v,a=arguments,i;var n_a=[];for(i=1;i<a.length;i++)n_a[n_a.length]=a[i];v=_js.FN.apply(this.caller,n_a);if(typeof o==D.O&&typeof v==D.O){for(i in v)o[i]=v[i];}};$E.FN=function(s){var _js=$E,v,a=arguments;if(typeof _js.ci[s]==D.S){eval("v="+_js.ci[s]);return v;}switch(s){case "base_object":return{i:$E.GG(),t:a[1],v:a[2],r:0};break;case "basic_message":return{entry:a[1],index:-1,data:a[2],time:new Date(),id:_js.GG()};break;case "basic_message_subscription":return{object:a[1],subscription_name:a[2],handler:a[3],target:a[4]};break;default:break;}return null;};$EP("$E.error");$E.error.traceRoute=function(v){var r="",a=[],i=0,n,q,g,t;if(v!=null){while(v&&v!=null){n=$E.error.G(v.toString());if(n==null){v=null;break;}n+="(";g=v.arguments[i];for(i=0;i<g.length;i++){if(i>0)n+=",";q="";t=typeof g[i];if(t==D.S)q="\"";n+=q+(t==D.O?"obj":v)+q+"{as "+t+"}";}n+=")";a.push(n);v=v.caller;}r=a.reverse().join("->");}else{r="null";}return r;};$E.error.G=function(s){var a=s.match(/function\s([A-Za-z0-9_]*)\(/gi),r=null;if(s==r)return r;if(a!=null&&a.length){s=a[0];s=s.replace(/^function\s+/,"");s=s.replace(/^\s*/,"");s=s.replace(/\s*$/,"");s=s.replace(/\($/,"");return s;}return r;};
$EP("$E.dom");$E.dom.event={v:"1.8.4",_gevt:
function(o){return(typeof event==D.O)?event:o;},_gevt_cancel:
function(o){(typeof o.preventDefault!=D.F)?(o.returnValue=false):o.preventDefault();},_gevt_dest:
function(e){return(e.relatedTarget)?e.relatedTarget:e.toElement;},_gevt_org:
function(e){return(e.relatedTarget)?e.relatedTarget:e.fromElement;},_gevt_src:
function(o){var s=$E.dom.event._gevt(o);if(s==null){$E.message.MessageService.S("Bad event reference","515.3",1);return o;}return(s.target)?s.target:s.srcElement;}, addEventBuffer:
function(o){var e="createHandler";try{o[e]=function(s,r,x,l){var b=(typeof r==D.O&&r!=null?1:0),t=this,e,h,f;r=(b)?r:t;e="_prehandle_"+s;b=(l?1:0);h="f=function(){\n"+"try{\n"+"var o="+(b?'$E.registry.ObjectRegistry.getObject(\"'+r.i+'\")':"this")+";\n"+"if(typeof o!=\"object\"||o==null){alert('Object is invalid');return;}\nreturn o._handle_"+s+".apply(o,arguments);"+"}\ncatch(e){alert(r.i+\"::\"+s+\"::\"+(e.description?e.description:e.message)+\"\\n\"+$E.error.traceRoute(f.caller));}\n"+"}";eval(h);if(!x)t[e]=f;return f;};}catch(e){alert("Error:"+e.description);}}, addEventListener:
function(o,e,f,b){if(typeof o.addEventListener!=D.U){o.addEventListener(e,f,b);}else if(typeof o.attachEvent!=D.U){o.attachEvent("on"+e,f);}},removeEventListener:
function(o,e,f,b){if(typeof o.removeEventListener!=D.U){o.removeEventListener(e,f,b);}else if(typeof o.detachEvent!=D.U){o.detachEvent("on"+e,f);}},getAbsoluteTop:
function(o){return $E.dom.event.getAbsolutePosition(o,1);},getAbsoluteLeft:
function(o){return $E.dom.event.getAbsolutePosition(o,0);},getAbsolutePosition:
function(o,b){var c=o,i=0;while(c!=null&&c.nodeName&&!c.nodeName.match(/body/i)){i+=(b?(c.offsetTop?c.offsetTop:0):(c.offsetLeft?c.offsetLeft:0));c=c.offsetParent;}return i;}}
$EP("$E.registry");$E.registry={ObjectRegistry:null,ObjectRegistryImpl:
function(){var t=this;t.o={s:{rt:0},p:{o:[],om:[]}};t.canRegister=function(o){if(typeof o!=D.O||(typeof o.i!=D.S||typeof o.t!=D.S||typeof o.v!=D.S||typeof o.r!=D.N)){return 0;}return 1;};t.addObject=function(o){var i,m,p;if(!t.canRegister(o)){if(ValidatePackage("$E.message")&&$E.message.MessageService!=null){$E.message.MessageService.S("Invalid Object Structure","540.4",1);}else{alert("Invalid Object Structure");}return 0;}if(t.isRegistered(o)){$E.message.MessageService.S("Object '"+o.i+"' is already registered","540.4");return 0;}p=t.o.p;i=o.i;if(typeof p.om[i]!=D.N){m=p.o.length;p.o[m]=o;p.om[i]=m;if(t.o.s.rt&&ValidatePackage("$E.transaction")&&$E.transaction.TransactionService!=null){$E.transaction.TransactionService.register(o);}return 1;}return 0;};t.removeObject=function(o,b){var i=o.i,m,p;p=t.o.p;if(typeof p.om[i]==D.N){m=p.om[i];p.o[m]=0;p.om[i]=null;if(!b)$E.message.MessageService.publish("onremoveobject",i);return 1;}return 0;};t.getObjects=function(){return t.o.p.o;};t.getObjectsMap=function(){return t.o.p.om;};t.getObject=function(i){var p=t.o.p;if(typeof p.om[i]==D.N&&typeof p.o[p.om[i]]==D.O){return p.o[p.om[i]];}return null;};t.isRegistered=function(i){if(typeof i==D.O){if(typeof i.i==D.U)return 0;i=i.i;}if(typeof t.o.p.om[i]==D.N){return 1;}return 0;};t.sendSigterm=function(){var o,i,p=t.o.p;for(i=p.o.length-1;i>=0;){o=p.o[i--];if(o!=null&&o.r==4&&typeof o.sigterm==D.F){o.sigterm();}}for(i=0;i<p.o.length;){o=p.o[i++];if(t.isRegistered(o))t.removeObject(o,1);}};t.sendDestroyTo=function(o){if(t.isRegistered(o)&&typeof o.destroy==D.F){o.destroy();return 1;}return 0;};$E.IM(t,"base_object","object_registry","1.8.4");t.addObject(t);}}
$E.registry.ObjectRegistry=new $E.registry.ObjectRegistryImpl();
$EP("$E.monitor");$E.monitor={MonitorService:null,MonitorServiceImpl:
function(){var t=this;t.t="MonitorService";t.v="1.8.4";t.i="monitor_service_1";t.r=0;t.o={p:{monitors:[],context_object:0},cookies:{},s:{ci:0,delay:1000,session_name:"MONITOR_SESSION_ID",document_rendered:0,hashed_cookies:0,window_interval:0,can_interval:1,window_state:0,application_id:0,dataset_id:0,last_image_index:0}};t.getContextObject=function(){return t.o.p.context_object;};t.getDatasetId=function(){return t.o.s.dataset_id;};t.getDocumentRendered=function(){return t.o.s.document_rendered;};t.getWindowState=function(){return t.o.s.window_state;};t.getSessionId=function(){return t.o.cookies[t.o.s.session_name];};t.getApplicationId=function(){return t.o.s.application_id;};t.getContextId=function(){return t.o.s.ci;};t.hashCookie=function(n,b,s){var c=t.o.s,k=t.o.cookies;if(!c.hashed_cookies++||s)t.hashValue(document.cookie,";","=",k);if(b&&typeof k[n]==D.S)t.hashValue(k[n],"&",":",k);};t.hashValue=function(c,d,s,k){if(c){var j=0,l,a=c.split(d),f=eval("/\\s*([^\\s"+s+"]+)"+s+"(.+)\\s*/");for(;a&&j<a.length;){l=a[j++].match(f);if(l)k[l[1]]=l[2].match(/^\d+$/)?parseInt(l[2]):l[2];}}};t.absorb=function(a,b){var i=0,l=a.length;for(;i<l;)b[b.length]=a[i++];};t.G=function(n){return t.o.p.context_object.getElementsByTagName(n);};t.doInterval=function(){var m=t.o.p.monitors,c=t.o.s,i=0,l,o,z;l=m.length;for(;i<l;){o=m[i++];z=o.o.s;if(typeof o.doInterval==D.F&&z.can_interval){if(z.interval_offset<=0)z.interval_offset=1;z.interval_offset--;if(z.interval_offset<=0)o.doInterval();}}c.window_interval=window.setTimeout(t.handle_window_interval,c.delay);return 1;};t.handle_window_interval=function(){var c=t.o.s;if(c.window_state>3){window.clearTimeout(c.window_interval);c.window_interval=0;return;}if(!c.can_interval)return;if(c.can_interval)if(!t.doInterval()){window.clearTimeout(c.window_interval);c.window_interval=0;c.can_interval=0;}};t.handle_window_load=function(e){var c=t.o.s;if(c.window_state>=3)return;t.BE();c.window_state=3;c.document_rendered=1;t.DE("window_load",e);};t.handle_window_beforeunload=function(e){t.DE("window_beforeunload",e);t.o.s.window_state=4;};t.handle_window_unload=function(e){var c=t.o.s;if(typeof $EP!="function")return;if(t.r==4){t.r=4.5;c.window_state=5;t.DE("window_unload",e);c.document_rendered=0;}t.r=5;};t.DE=function(s,e,p2,p3){var m=t.o.p.monitors,i=0,l,o,n;n="handle_"+s;l=m.length;for(;i<l;){o=m[i++];if(typeof o[n]=="function")o[n](e,p2,p3);}};t.IService=function(){if(t.r)return 0;var _a=$E.dom.event.addEventListener,d=document,w=window,f=false,c=t.o.s,o=t.o.cookies,p=t.o.p;t.r=2;c.application_id=(typeof APPLICATION_ID!=D.U)?APPLICATION_ID:"Global";c.dataset_id=(typeof DATASET_ID!=D.U?DATASET_ID:"public");p.context_object=(typeof CONTEXT_OBJECT!=D.U?CONTEXT_OBJECT:document);t.hashCookie();c.ci=$E.guid();if(!o[c.session_name]){o[c.session_name]=c.ci;document.cookie=c.session_name+"="+o[c.session_name]+";";}_a(w,"load",t.handle_window_load,f);_a(w,"unload",t.handle_window_unload,f);_a(w,"beforeunload",t.handle_window_beforeunload,f);o=p.context_object;if(o==d)o=d.documentElement;_a(o,"contextmenu",t.handle_context_menu,f);_a(o,"mousemove",t.handle_mouse_move,f);_a(o,"click",t.handle_mouse_click,f);_a(o,"scroll",t.handle_document_scroll,f);_a(w,"focus",t.handle_window_focus,f);_a(w,"blur",t.handle_window_blur,f);_a(w,"keydown",t.handle_window_keydown,f);_a(w,"resize",t.handle_window_resize,f);if(w.onerror)w.ph_error=w.onerror;w.onerror=t.handle_window_error;t.ImageProbe();t.r=4;t.doInterval();};t.handle_context_menu=function(e){t.DE("context_menu",e);};t.handle_window_error=function(m,u,l){t.DE("window_error",m,u,l);if(typeof window.ph_error==D.F)return window.ph_error.apply(window,arguments);};t.handle_mouse_click=function(e){t.DE("mouse_click",e);};t.handle_mouse_move=function(e){t.DE("mouse_move",e);};t.handle_document_scroll=function(e){t.DE("document_scroll",e);};t.handle_window_focus=function(e){t.DE("window_focus",e);};t.handle_window_blur=function(e){t.DE("window_blur",e);};t.handle_input_focus=function(e){t.DE("input_focus",e);};t.handle_input_blur=function(e){t.DE("input_blur",e);};t.handle_window_keydown=function(e){t.DE("window_keydown",e);};t.handle_window_resize=function(e){t.DE("window_resize",e);};t.handle_form_submit=function(e){t.DE("form_submit",e);var oF=$E.dom.event._gevt_src(e);if(oF&&oF.nodeType==1&&typeof oF.ph_submit==D.F)return oF.ph_submit.apply(oF,arguments);};t.handle_form_reset=function(e){t.DE("form_reset",e);var oF=$E.dom.event._gevt_src(e);if(oF&&oF.nodeType==1&&typeof oF.ph_reset==D.F)return oF.ph_reset.apply(oF,arguments);};t.handle_select_change=function(e){t.DE("select_change",e);};t.BE=function(){var a=[],i,o,f=$E.dom.event.addEventListener,mc=t.handle_mouse_click,hs=t.handle_form_submit,hr=t.handle_form_reset,hc=t.handle_select_change,uf=t.handle_input_focus,ub=t.handle_input_blur;t.absorb(t.G("form"),a);t.absorb(t.G("a"),a);t.absorb(t.G("input"),a);t.absorb(t.G("area"),a);t.absorb(t.G("select"),a);t.absorb(t.G("textarea"),a);for(i=0;i<a.length;i++){o=a[i];if(!o.nodeName.match(/select/i)){f(o,"click",mc);f(o,"focus",uf);f(o,"blur",ub);f(o,"keydown",ub);}if(o.nodeName.match(/form/i)){if(o.onsubmit)o.ph_submit=o.onsubmit;o.onsubmit=hs;if(o.onreset)o.ph_onreset=o.onreset;o.onreset=hr;}else if(o.nodeName.match(/select/i)){f(o,"click",hc);f(o,"change",hc);f(o,"focus",hc);f(o,"blur",hc);f(o,"keydown",hc);}}};t.addMonitor=function(o,c){var m=t.o.p.monitors,r=$E.registry.ObjectRegistry;if(typeof o!=D.O||o==null||r.isRegistered(o)==false||typeof o.I!=D.F)return 0;if(!o.o.config_keys)o.o.config_keys={};if(typeof o.o.config_keys==D.O&&typeof c==D.S)t.hashValue(c,"&",":",o.o.config_keys);o.getConfigKeys=function(){return o.o.config_keys};o.getConfigKey=function(n){return o.o.config_keys[n];};o.getMonitorService=function(){return t;};o.o.s.can_interval=1;o.o.s.interval_offset=0;if(o.I()){m[m.length]=o;return 1;}return 0;};t.handle_image_load=function(e){t.DE("image_load",e);};t.handle_image_abort=function(e){t.DE("image_abort",e);};t.handle_image_error=function(e){t.DE("image_error",e);};t.ImageProbe=function(){var _a=$E.dom.event.addEventListener,_s=t.o.s,i,_i=document.images,l;if(t.r>4||!_i)return;l=_i.length;for(i=_s.last_image_index;i<l;i++){_i[i].onload=t.handle_image_load;_i[i].onabort=t.handle_image_abort;_i[i].onerror=t.handle_image_error;_i[i]._ix=i;}_s.last_image_index=l;if(!_s.document_rendered)window.setTimeout(t.ImageProbe,10);};$E.IM(t,"base_object","monitor_service","1.8.4");$E.registry.ObjectRegistry.addObject(t);$E.dom.event.addEventBuffer(t);t.IService();}};$E.monitor.MonitorService=new $E.monitor.MonitorServiceImpl();
$EP("org.cote.js");
org.cote.js = $E;

