if (typeof window.NGSControlsNamespace == "undefined")
{
	window.NGSControlsNamespace = {};
}

if (
	typeof(window.NGSControlsNamespace.Overlay) == "undefined" ||
	typeof(window.NGSControlsNamespace.Overlay.Version) == null ||
	window.NGSControlsNamespace.Overlay.Version < 1.1
	)
{	
	window.NGSControlsNamespace.Overlay = function (element)
	{
		
		if (!this.SupportsOverlay())
		{
			return;
		}

		this.Element = element;

		this.Shim = document.createElement("IFRAME");
		this.Shim.src="javascript:'';";
		this.Element.parentNode.insertBefore(this.Shim, this.Element);

		if (element.style.zIndex > 0)
		{
			this.Shim.style.zIndex = element.style.zIndex - 1;
		}
		this.Shim.style.position = "absolute";	
		this.Shim.style.border = "0px";	
		this.Shim.frameBorder = 0;
		this.Shim.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
		this.Shim.disabled = "disabled";
	}

	window.NGSControlsNamespace.Overlay.Version = 1.1;// update in the header IF also

	NGSControlsNamespace.Overlay.prototype.SupportsOverlay = function()
	{
		return NGSControlsNamespace.Browser.IsIE || (NGSControlsNamespace.Browser.IsMozilla && NGSControlsNamespace.Browser.IsMac);
	}

	NGSControlsNamespace.Overlay.prototype.Update = function ()
	{
		if (!this.SupportsOverlay())
		{
			return;
		}
		
		this.Shim.style.top = this.ToUnit(this.Element.style.top);
		this.Shim.style.left = this.ToUnit(this.Element.style.left);
		this.Shim.style.width = this.Element.offsetWidth + "px";
		this.Shim.style.height = this.Element.offsetHeight + "px";	
		
	//	this.Shim.style.border = "0px solid red";
	}

	NGSControlsNamespace.Overlay.prototype.ToUnit = function (value)
	{
		if (!value) return "0px";
		return parseInt(value) + "px";
	}

	NGSControlsNamespace.Overlay.prototype.Dispose = function ()
	{
		if (!this.SupportsOverlay())
		{
			return;
		}
				
		if (this.Shim.parentNode)
		{
			this.Shim.parentNode.removeChild(this.Shim);
		}
		
		this.Element = null;
		this.Shim = null;
		
	}
}

