function cursorwait (layerId)
{
	if (layerId == undefined || !layerId)
		layerId = false;
		
	this.layerId  = layerId;

	if (this.layerId) {
		this.cX       = 0;
		this.cY       = 0;
		this.dX       = 8;
		this.dY       = 8;
		this.enabled  = false;
		this.layerObj = document.getElementById(this.layerId);
	} else {
		this.bodyObj  = document.getElementsByTagName("body")[0];
	}

	this.debug    = false;
	this.debugObj = document.getElementById("debug");

	var  _this    = this;

	if (this.layerId)
	{
		this.AssignPosition = function () {
			this.layerObj.style.left = (this.cX + this.dX) + "px";
			this.layerObj.style.top  = (this.cY + this.dY) + "px";
			if (this.cX < 0 || this.cY < 0)	{
				this.layerObj.style.visibility = "hidden";
			} else {
				if (this.enabled)
					this.layerObj.style.visibility = "visible";
				else
					this.layerObj.style.visibility = "hidden";
			}
			if (this.debug)
				this.debugObj.innerHTML = this.enabled;
		};

		this.UpdateCursorPosition = function (e) {
			_this.cX = e.pageX;
			_this.cY = e.pageY;
			_this.AssignPosition();
		};

		this.UpdateCursorPositionDocAll = function (e) {
			e = e?e:window.event;
			_this.cX = e.clientX;
			_this.cY = e.clientY;
			_this.AssignPosition();
		};
	}

	this.display = function (boolMode)
	{
		if (boolMode) {
			if (this.layerId) {
				if(document.all) { document.onmousemove = this.UpdateCursorPositionDocAll; }
				else             { document.onmousemove = this.UpdateCursorPosition; }
				this.enabled = true;
				this.layerObj.style.visibility = "visible";
			} else {
				this.bodyObj.style.cursor = 'wait';
			}
		} else {
			if (this.layerId) {
				//document.onmousemove = null;
				this.enabled = false;
				this.layerObj.style.visibility = "hidden";
			} else {
				this.bodyObj.style.cursor = 'default';
			}
		}
	}

	if (document.all && this.layerId) { document.onmousemove = this.UpdateCursorPositionDocAll; }
	else if (this.layerId) { document.onmousemove = this.UpdateCursorPosition; }
}