/* Inspired by David Walsh's ElementSpy */
fx.LocationSpy = new Class({

  Implements: [Options, Events],
  Binds: ['worker'],
  
	options: {
		interval: 100
	},
  
	initialize: function(options) {
		this.setOptions(options);
		this.val = location.href;
    this.interval;
	},
  
  worker: function()
  {
    var value = location.href;
    this.fireEvent('check',[this.val,value]);
    if(value != this.val) {
      this.fireEvent('change',[this.val,value]); //old,new
      this.val = value;
    }
    else {
      this.fireEvent('stagnate',[value]); //current
    }
  },
  
	start: function() {
		this.interval = this.worker.periodical(this.options.interval);
		this.fireEvent('start');
		return this;
	},
  
	stop: function() {
		$clear(this.interval);
		this.fireEvent('stop');
		return this;
	},
});
