var isNav = (navigator.appName == "Netscape");
if (typeof(getTopLevelWnd().modalWnd) == "undefined")
{
getTopLevelWnd().modalWnd = null;
}
function beginModal()
{
if (isModal() == false)
{
getTopLevelWnd().modalWnd = window;
visitFrames("disableWindowCallback", getTopLevelWnd());
window.onresize = onModalResize;
window.focus();
}
}
function endModal()
{
if (isModal() && getTopLevelWnd().modalWnd == window)
{
getTopLevelWnd().modalWnd = null;
}
}
function isModal()
{
if (getTopLevelWnd().modalWnd != null && doesWindowExist(getTopLevelWnd().modalWnd))
{
return true;
}
getTopLevelWnd().modalWnd = null;
return false;
}
function doesWindowExist(wnd)
{
return _doesWindowExist(getTopLevelWnd(), wnd);
}
function _doesWindowExist(parentWnd, wnd)
{
for (var i = 0; i < parentWnd.frames.length; i++)
{
var childWnd = parentWnd.frames[i];
if (childWnd == wnd || _doesWindowExist(childWnd, wnd) == true)
{
return true;
}
}
return false;
}
function visitFrames(funct, wnd)
{
if (isDispatchableWindow(wnd))
{
if ( (typeof(eval("wnd." + funct)) != "undefined") &&
(wnd != window) && (wnd.frames.length == 0) )
{
wnd.setTimeout(funct + "()", 1);
}
for (var i = 0; i < wnd.frames.length; i++)
{
visitFrames(funct, wnd.frames[i]);
}
}
}
function onModalResize(event)
{
visitFrames("refreshWindowCallback", getTopLevelWnd());
}
function disableWindowCallback()
{
if (typeof(window.document) != "undefined" &&
typeof(window.document.body) != "undefined" &&
typeof(window.ignoreModal) == "undefined")
{
if (isNav == false)
{
window.oldScroll = window.document.body.scroll;
window.oldScrollLeft = window.document.body.scrollLeft;
window.oldScrollTop = window.document.body.scrollTop;
if (window.document.body.scroll != "no")
{
window.document.body.scroll = "no";
}
if (window.document.body.scrollLeft != 0 || window.document.body.scrollTop != 0)
{
window.scrollTo(0,0);
}
}
var urlRoot = window.location.protocol + "//" + window.location.host + g_virtualRoot;
var div = window.document.createElement("DIV");
div.id = "fade_modal";
div.innerHTML = "<table background='" + urlRoot + "/wdk/modalFade.gif' border=0 width=100% " +
"cellspacing=0 cellpadding=0><tr><td height=" + screen.height + "></td></tr></table>";
with (div.style)
{
position = "absolute";
visibility = "visible";
zIndex = "9";
overflow = "hidden";
if (isNav)
{
left = window.pageXOffset;
top = window.pageYOffset;
width = window.innerWidth;
height = window.innerHeight;
}
else
{
left = 0;
top = 0;
width = window.document.body.clientWidth;
height = window.document.body.clientHeight;
}
}
window.document.body.appendChild(div);
window.oldOnfocusEventHandler = window.onfocus;
window.onfocus = onIgnoreFocus;
if (window.document.forms.length > 0)
{
for (j = 0; j < window.document.forms.length; j++)
{
var form = window.document.forms[j];
for (i = 0; i < form.elements.length; i++)
{
var element = form.elements[i];
if (element.type.indexOf("select") == 0 && element.disabled == false)
{
if (typeof(window.disabledSelectCtrls) == "undefined")
{
window.disabledSelectCtrls = [];
}
window.disabledSelectCtrls[window.disabledSelectCtrls.length] = element;
element.disabled = true;
}
}
}
}
window.setTimeout("enableWindowCallback()", 250);
}
}
function enableWindowCallback()
{
if (typeof(window.document) != "undefined" && typeof(window.document.body) != "undefined")
{
if (isModal())
{
window.setTimeout("enableWindowCallback()", 250);
return;
}
var div = window.document.getElementById("fade_modal");
if (div != null)
{
window.document.body.removeChild(div);
if (isNav == false)
{
if (window.oldScroll != "no")
{
window.document.body.scroll = window.oldScroll;
}
if (window.oldScrollLeft != 0 || window.oldScrollTop != 0)
{
window.scrollTo(window.oldScrollLeft, window.oldScrollTop);
}
}
}
window.onfocus = window.oldOnfocusEventHandler;
if (typeof(window.disabledSelectCtrls) != "undefined")
{
for (i = 0; i < window.disabledSelectCtrls.length; i++)
{
var element = window.disabledSelectCtrls[i];
element.disabled = false;
}
window.disabledSelectCtrls = [];
}
}
}
function refreshWindowCallback()
{
if (typeof(window.document) != "undefined" && typeof(window.document.body) != "undefined")
{
var div = window.document.getElementById("fade_modal");
if (div != null)
{
with (div.style)
{
if (isNav)
{
left = window.pageXOffset;
top = window.pageYOffset;
width = window.innerWidth;
height = window.innerHeight;
}
else
{
left = 0;
top = 0;
width = window.document.body.clientWidth;
height = window.document.body.clientHeight;
}
}
}
}
}
function onIgnoreFocus(event)
{
if (getTopLevelWnd().modalWnd != null)
{
getTopLevelWnd().modalWnd.focus();
}
}
