1var DetectActivity = Class.create();
2DetectActivity.prototype = {
3  initialize: function(subject)
4  {
5    this.onunactivate = function() {};
6    this.onactivate   = function() {};
7    this.subject = subject;
8    this.isactive = true;
9    Event.observe(subject, 'mousemove', this._OnFocus.bindAsEventListener(this), false);
10    Event.observe(subject, 'mouseout', this._OnBlur.bindAsEventListener(this), false);
11  },
12  _OnFocus: function(e)
13  {
14    this.isactive = true;
15    if (this.onactivate) this.onactivate();
16  },
17  _OnBlur: function(e)
18  {
19    this.isactive = false;
20    if (this.onunactivate) this.onunactivate();
21  },
22  isActive: function()
23  {
24    return this.isactive;
25  }
26}
27
28
29
30/*
31// Unused code, by usefull for further auto idle features
32
33  _launchTimeout: function(myself)
34  {
35var oldisactive =  this.isactive;
36    if (this.oldposx == this.posx &&
37        this.oldposy == this.posy)
38      this.isactive = false;
39    else
40      this.isactive = true;
41this.oldposx = this.posx;
42this.oldposy = this.posy;
43if (oldisactive != this.isactive) alert("switch");
44    setTimeout(function() { myself._launchTimeout(myself); }, 1000);
45  },
46
47  _OnMouseMove: function(e)
48  {
49        var posx = 0;
50	var posy = 0;
51        if (!e) var e = window.event;
52	if (e.pageX || e.pageY)
53 	{
54		posx = e.pageX;
55		posy = e.pageY;
56	}
57	else if (e.clientX || e.clientY)
58        {
59		posx = e.clientX + document.body.scrollLeft
60			+ document.documentElement.scrollLeft;
61		posy = e.clientY + document.body.scrollTop
62			+ document.documentElement.scrollTop;
63	}
64        this.posx = posx;
65        this.posy = posy;
66  },
67*/
68