/* IE6 background image flicker bug solution */

Hasbro.IE6Flicker = new Class({

	initialize : function () {

		try {document.execCommand("BackgroundImageCache", false, true);} 

		catch(err) {}

	}

});



/* kill default behavior of anchor tags with href="#" */

Hasbro.NullAnchor = new Class({

	initialize : function (id) {

		this.container = id;

		this.nullAnchors = this.container.getElementsBySelector('a.hsb_null_link').merge(this.container.getElements('a[href=#]'));

		

		this.nullAnchors.each(function(anchor) {

			anchor.onclick = function (event) {

				var evt = new Event(event);

				evt.preventDefault();

			}

		});

	}

});



/* image preloader fires 'onImgsLoaded' on completion */

Hasbro.ImgPreload = new Class({

	initialize : function (el) {

		this.container = el;

		this.imgs = this.container.getElements('img').getProperty('src');

		if (this.imgs.length > 0) {

			new Asset.images(this.imgs, {onComplete: this._doImgsLoaded.bind(this)});	

		}

	},

	_doImgsLoaded : function () {

		this.fireEvent('onImgsLoaded');

	}

});

Hasbro.ImgPreload.implement(new Events);



Hasbro.Timer = new Class({

	msecs: 1000,

	onExpire : Class.empty,

	isRunning: false,

	initialize : function(msecs) {

		($defined(msecs))? this.msecs = msecs: null;

	},

	start : function () {

		var ref = this;

		this.isRunning = true;

		this.interval = setTimeout(function() {ref.fireExpire();}, this.msecs );

		return true;

	},

	stop : function () {

		this.isRunning = false;

		clearTimeout(this.interval);

		return true;	

	}, 

	restart : function () {

		this.stop();

		this.start();

		return true;

	}, 

	fireExpire : function () {

		this.stop();

		this.fireEvent('onExpire');

		return true;

	}

});

Hasbro.Timer.implement(new Events);