window.onresize = fnReposition;

function fnReposition()
{
	if (gdlgCurrent != null)
	{
		bgOn();
		dlgOn(gdlgCurrent.id);
	}
}

function bgOn()
{
	var ctlBackground = byId("ctlBackground");
	gStyle.toggleScroll(false);
	gStyle.setTopLeft(gStyle.scrollOffsetOf(document.body), ctlBackground);
	gStyle.setWidthHeight(gStyle.sizeOf(document.body), ctlBackground);
	gStyle.show(ctlBackground);
	ctlBackground.style.zIndex = 1;
	var selectCollection = document.getElementsByTagName("select");
	for (var index = 0; index < selectCollection.length; index ++)
	{
		selectCollection[index].style.visibility = "hidden";
	}
}

function bgOff()
{
	var ctlBackground = document.getElementById("ctlBackground");
	gStyle.hide(ctlBackground);
	ctlBackground.style.zIndex = 0;
	gStyle.toggleScroll(true);
	var selectCollection = document.getElementsByTagName("select");
	for (var index = 0; index < selectCollection.length; index ++)
	{
		selectCollection[index].style.visibility = "visible";
	}
}

function dlgOff()
{
	bgOff();
	if (gdlgCurrent != null)
	{
		gdlgCurrent.style.zIndex = 0;
		gdlgCurrent.style.visibility = "hidden";
	}
	gdlgCurrent = null;
}

function dlgOn(dialogId)
{
	bgOn();
	var ctlDialog = byId(dialogId);
	var position = gStyle.sizeOf(document.body).center(gStyle.sizeOf(ctlDialog)).add(gStyle.scrollOffsetOf(document.body));
	gStyle.setTopLeft(position, ctlDialog);
	gStyle.show(ctlDialog);
	ctlDialog.style.zIndex = 2;
	gdlgCurrent = ctlDialog;
}