﻿//======================================================
// Wait window class
//======================================================
function WaitWindowClass(XML)
{
	var THIS = this;
	
	this.XML = '<Data/>';
	this.XSLT = '/Xslt/WaitWindow.xslt';
	
	this.ShadowOffsetTop = 5;
	this.ShadowOffsetLeft = 5;
	
	//==================================================
	// Open the popup window..
	//==================================================
	this.Open = function Open()
	{
		try
		{
			// Create the lock layer.
			this.LockLayer = document.createElement('DIV');
			this.LockLayer.className = 'LockLayer';
			this.LockLayer.innerHTML = '&nbsp;';
			
			if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version == 6))
				this.LockLayer.style.height = document.documentElement.clientHeight + 'px';
			
			document.body.appendChild(this.LockLayer);
			
			// Check the browser.
			if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 9))
			{
				// Create the shadow.
				this.WaitWindowContainerShadow = document.createElement('DIV');
				this.WaitWindowContainerShadow.innerHTML = '&nbsp;';
				this.WaitWindowContainerShadow.className = 'WaitWindowShadow';
				document.body.appendChild(this.WaitWindowContainerShadow);
			}
			
			// Create and load the wait window main container.
			this.WaitWindowContainer = document.createElement('DIV');
			this.WaitWindowContainer.className = 'WaitWindow';
			
			var objXSLTransform = new XSLTransform();
			objXSLTransform.Transform(this.WaitWindowContainer, this.XSLT, this.XML, this.WaitWindow_Completed);
			delete objXSLTransform;
		}
		catch(exc)
		{
			Functions.DisplayError(this.Name + '.Open()\n\n' + exc);
		}
		return;
	}
	
	//==================================================
	// Wait window XSLT completed handler.
	//==================================================
	this.WaitWindow_Completed = function WaitWindow_Completed()
	{
		try
		{
			// Append the popup window to the document.
			document.body.appendChild(THIS.WaitWindowContainer);
			
			// Check the browser.
			if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 9))
			{
				// Position the shadow.
				THIS.WaitWindowContainerShadow.style.width = THIS.WaitWindowContainer.offsetWidth;
				THIS.WaitWindowContainerShadow.style.height = THIS.WaitWindowContainer.offsetHeight;
				THIS.WaitWindowContainerShadow.style.top = THIS.WaitWindowContainer.offsetTop + THIS.ShadowOffsetTop;
				THIS.WaitWindowContainerShadow.style.left = THIS.WaitWindowContainer.offsetLeft + THIS.ShadowOffsetLeft;
			}
		}
		catch(exc)
		{
			Functions.DisplayError(this.Name + '.WaitWindow_Completed()\n\n' + exc);
		}
		return;
	}

	//==================================================
	// Popup content XSLT completed handler.
	//==================================================
	this.Close = function Close()
	{
		try
		{
			if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 9))
				document.body.removeChild(THIS.WaitWindowContainerShadow);

			document.body.removeChild(THIS.WaitWindowContainer);
			document.body.removeChild(THIS.LockLayer);
			THIS.Dispose();
		}
		catch(exc)
		{
			//Functions.DisplayError(this.Name + '.Close()\n\n' + exc);
		}
		return;
	}
	
	//==================================================
	// Dispose.
	//==================================================
	this.Dispose = function Dispose()
	{
		try
		{
			for (Element in THIS)
			{
				if (typeof (THIS[Element]) != 'function')
				{
					if ((THIS[Element] != undefined) || (THIS[Element] != null))
					{
						if (Element != 'undefined')
						{
							THIS[Element] = null;
							delete THIS[Element];
						}
					}
				}
			}

			delete THIS;
		}
		catch(exc)
		{
			Functions.DisplayError(this.Name + '.Dispose()\n\n' + exc);
		}
		return;
	}	
	return;
}
