/**
 * Contains set of general life-essential functions used across library.
 **/

// Correct inheritance workaround for JS. Base class for all A* objects.
Object.prototype.Inherits = function (parent)
{
	if (arguments.length > 1)
	{
		parent.apply(this, Array.prototype.slice.call(arguments, 1));
	}
	else
	{
		parent.call(this);
	}
}

Function.prototype.Inherits = function (parent)
{
	this.prototype = new parent();
	this.prototype.constructor = this;
}

// Returns an object reference by it's ID.
$ = function (id)
{
    return document.getElementById(id);
}

// Returns reference to event element object (sort of ugly).
$this = function (evt)
{
    evt = (evt) ? evt : ((event) ? event : null);
    if (evt)
    {
        var element = (evt.target) ? evt.target :
                   ((evt.srcElement) ? evt.srcElement : null);
        if (element)
        {
            return element;
        }
    }
}
