//declaring the class
// Eventwatcher keeps track of mouseover and mouseoutevent
// records the target id's for the event
// compares them (to fix firebox bug: 
// triggering the mouseout and mouseover event even when still at the same location
var EventWatcher = Class.create();

//defining the rest of the class implementation
EventWatcher.prototype = {
  initialize: function() {
    this.over = ""; //id of the element under the mouse on mouseover
	this.out = ""; //id of the element under the mouse on mouseout
	this.eq = "";
    this.Window = window;
	//assigning our method to the event
    this.Window.onmouseover = this.mouseoverEvent.bindAsEventListener(this);
    this.Window.onmouseout = this.mouseoutEvent.bindAsEventListener(this);
  },
  mouseoverEvent: function(evt) {
	  // Internet Explorer
	  if (evt.srcElement)
	  { e = evt.srcElement;
		this.over = evt.srcElement.id;
	 	this.eq = (evt.target.id == this.out);}
	  // Netscape and Firefox
	  else if (evt.target)
	  {	 e = evt.target;
		 this.over = evt.target.id;
		 this.eq = (evt.target.id == this.out); }
  	},
  mouseoutEvent: function(evt) {
	if (evt.srcElement)
	  { this.out = evt.srcElement.id;}
	else if (evt.target)
	  { this.out = evt.target.id; }
	}
}
// start the watcher
eventwatcher = new EventWatcher();

