function $(element)
{
	if (typeof element == 'string')
	{
		element = document.getElementById(element);
	}
	return element;
}

Function.prototype.bindAsEventListener = function(object)
{
    var __method = this;
    return function(event)
    {
        return __method.call(object, event || window.event);
    }
}

function ImageHover(linkId, overImg)
{
    this.el = $(linkId);
    var images = this.el.getElementsByTagName('IMG');
    this.image = images[0];
    this.overImg = overImg;
    this.offImg = this.image.src;
    this.preloadImages();
    this.setupEvents();
}

ImageHover.prototype = {
    el: null,
    image: null,
    overImg: null,
    offImg: null,

    preloadImages: function()
    {
        var preload = new Image();
        preload.src = this.overImg;
    },

    setupEvents: function()
    {
        this.el.onmouseover = this.mouseOver.bindAsEventListener(this);
        this.el.onmouseout = this.mouseOut.bindAsEventListener(this);
    },

    mouseOver: function()
    {
        this.image.src = this.overImg;
    },

    mouseOut: function()
    {
        this.image.src = this.offImg;
    }
};
