function Overlay( sSource, sTarget, aIgnoreClass, nHeight, nWidth )
{
	window[ this.self = "$Overlay" ] = this;

	this._height  = nHeight || false;
	this._width   = nWidth || false;

	this._source  = "div." + sSource;
	this._target  = "div#" + sTarget;

	this._regex   = new RegExp( "\s?(" + aIgnoreClass.join( "|" ) + ")", "g" );

	this._button  = [];
	this._overlay = null;

	this.init();
};

Overlay.prototype.init = function()
{
	$( this._source ).each( function() {
		$Overlay.appendButton( this );
	} );
	$( this._target ).each( function() {
		this._parent = $Overlay;
		this._parent._overlay = this;
		this.onmouseout = this._parent.mouseout;
	} );
};

Overlay.prototype.appendButton = function( oElement )
{
	var oDiv = document.createElement( "div" );
	this._button.push( oDiv );
/*
	oDiv.setAttribute( "style", "width: "  + ( this._width  ? this._width  : oElement.offsetWidth  ) + "px;" + 
								"height: " + ( this._height ? this._height : oElement.offsetHeight ) + "px;" + 
								"position: absolute;" + 
								"left: 0; top: 0;" );
*/
	oDiv.style.width = ( this._width  ? this._width  : oElement.offsetWidth  ) + "px";
	oDiv.style.height = ( this._height ? this._height : oElement.offsetHeight ) + "px";
	oDiv.style.position = "absolute";
	oDiv.style.left = 0;
	oDiv.style.top = 0;
	oDiv.style.backgroundColor = '#000';
	oDiv.style.opacity = 0;
	oDiv.style.filter = "alpha(opacity=0)";

	oDiv.className = oElement.className.replace( this._regex, "" );

	oElement.appendChild( oDiv );

	oDiv._parent = this;
	var aPos = this.getOffset( oDiv );
	if( typeof this._element == "undefined" )
		this._element = oElement

	oDiv.onmouseover = this.mouseover;
};

Overlay.prototype.mouseover = function()
{
	var aPos = this._parent.getOffset( this );
	this._parent._overlay.className  = this.className;

	this._parent._overlay.style.left = ( aPos[ 0 ] - this._parent.getLeft() ) - ( ( this._parent._overlay.offsetWidth  - this.offsetWidth  ) / 2 ) + "px";
	this._parent._overlay.style.top  = ( this._parent.getTop()  ) - ( ( this._parent._overlay.offsetHeight - this.offsetHeight ) / 2 ) + "px";
};

Overlay.prototype.getLeft = function()
{
	var aPos = this.getOffset( this._element );
	return aPos[ 0 ];
};

Overlay.prototype.getTop = function()
{
	var aPos = this.getOffset( this._element );
	return aPos[ 1 ];
};

Overlay.prototype.mouseout = function()
{
	if( !this.className.match( "\s*hide" ) )
		this.className += " hide";
};

Overlay.prototype.getOffset = function( oElement )
{
	var aPos = [ 0, 0 ];
	var oPos = $( oElement ).offset();
	aPos[ 0 ] = oPos.left;
	aPos[ 1 ] = oPos.top;
	/*
	if( oElement.offsetParent )
		do {
			alert( oElement.id + "\n" + $( oElement ).css( "padding-top" ) );
			aPos[ 0 ] += oElement.offsetLeft;
			aPos[ 1 ] += oElement.offsetTop;
		} while ( oElement = oElement.offsetParent );
	*/

	return aPos;
};
