var gMsgBoxWidth = 400;
var gMsgBoxHeight = 400;
var blnMsgBoxShown = false;


function getMsgBox()	{
	var objDiv = document.createElement("div");
	var objStyle = objDiv.style;
	var objChildDiv = document.createElement("div");
	var objCStyle = objChildDiv.style;
	var objBottomDiv = document.createElement("div");
	var objButton = document.createElement("input");
	
	if (!blnMsgBoxShown)	{
		objDiv.id = "divMsgBox";
		if (((document.documentElement.clientHeight / 2) + document.documentElement.scrollTop) - (gMsgBoxHeight / 2) > 0)	{
			objStyle.top = (((document.documentElement.clientHeight / 2) + document.documentElement.scrollTop) - (gMsgBoxHeight / 2)) + "px";
		}
		else	{
			objStyle.top = "0px";
		}
		if (((document.documentElement.clientWidth / 2) + document.documentElement.scrollLeft) - (gMsgBoxWidth / 2) > 0)	{
			objStyle.left = (((document.documentElement.clientWidth / 2) + document.documentElement.scrollLeft) - (gMsgBoxWidth / 2)) + "px";
		}
		else	{
			objStyle.left = "0px";
		}
		
		objChildDiv.id = "divMsg";
		objCStyle.width = (gMsgBoxWidth - 40) + "px";
		objCStyle.height = (gMsgBoxHeight - 70) + "px";
		objDiv.appendChild(objChildDiv);
		
		objButton.id = "btnMsg";
		objButton.type = "button";
		objButton.className = "btnClose";
		addEvent(objButton, 'click', onButtonClicked);
		
		objBottomDiv.align = "center";
		objBottomDiv.appendChild(objButton);
		objDiv.appendChild(objBottomDiv);
		blnMsgBoxShown = true;
		return objDiv;
	}
	else	{
		return null;
	}
}

function getMsgBoxIEpatch(top, left, height, width)	{
	// for the message box display properly over form elements in IE
	var objIframe = document.createElement("Iframe");
	var objIStyle = objIframe.style;

	objIframe.id = "ifrMsgBox";
	objIStyle.zIndex = "0";
	objIStyle.position = "absolute";
	objIStyle.top = top;
	objIStyle.left = left;
	objIStyle.height = height + "px";
	objIStyle.width = width + "px";
	
	return objIframe;
}

function onButtonClicked()	{
	var objDiv = MM_findObj("divMsgBox");
	var objFram = MM_findObj("ifrMsgBox");
	
	if (objDiv)	{
		objDiv.parentNode.removeChild(objDiv);
	}
	if (objFram)	{
		objFram.parentNode.removeChild(objFram);
	}
	blnMsgBoxShown = false;
}


function TestError()	{
	var strError;
	
	objMsgBox = getMsgBox();
	if (objMsgBox)	{
		document.body.appendChild(objMsgBox);
		objFrame = getMsgBoxIEpatch(objMsgBox.style.top, objMsgBox.style.left, objMsgBox.clientHeight, objMsgBox.clientWidth);
		document.body.appendChild(objFrame);
		objMsg = MM_findObj("divMsg");
		strError = "<div class='divError'>Details;</div><div class='divErrorMsg'>Hello</div>";
		strError += "<div class='divSupport'>Support</div><div class='divSupportMsg'>Hi</div>";
		
		objMsg.innerHTML = strError;
	}
}
