function UrlParser(strUrl, bDecodePlusChar)
{
this.strUrl = strUrl;
this.base = null;
this.queryString = null;
this.parameterMap = new Object();
this.bDecodePlusChar = (bDecodePlusChar) ? true : false;
this._unescape = function(str)
{
var unEscStr = (str) ? str : "";
if (this.bDecodePlusChar)
{
// Javascript unescape doesn't replace '+' with ' ', but does decode %2B into '+' so if the strURL
// came from an encoder which replaces ' ' with '+' need to decode them before sending to unescape
unEscStr = unEscStr.replace(/\+/g," ");
}
unEscStr = unescape(unEscStr);
return unEscStr;
}
if (this.strUrl != null)
{
var i = this.strUrl.indexOf("?");
if (i == -1)
{
this.base = this.strUrl;
this.queryString = null;
}
else
{
this.base = this.strUrl.substring(0, i);
this.queryString = this.strUrl.substring(i + 1);
}
if (this.queryString)
{
var parameters = this.queryString.split("&");
if (parameters && parameters.length > 0)
{
for (var i = 0; i < parameters.length; i++)
{
var namevalue = parameters[i].split("=");
var name = this._unescape(namevalue[0]);
var value = this._unescape(namevalue[1]);
if(!this.parameterMap[name])
{
this.parameterMap[name] = new Array();
}
this.parameterMap[name].push(value);
}
}
}
}
}
UrlParser.prototype.getBase = function()
{
return this.base;
}
UrlParser.prototype.getQueryString = function()
{
return this.queryString;
}
UrlParser.prototype.getParameterMap = function()
{
return this.parameterMap;
}
UrlParser.prototype.toString = function()
{
var s = "BASE='" + this.base  + "', PARAMETERS=";
for (var name in this.parameterMap)
{
s += ("[" + name + "=" + this.parameterMap[name] + "]");
}
s += "', QUERY='" + this.queryString;
return s;
}
function navigateToURL(strUrl, formName, win)
{
if (strUrl.length < 2048)
{
if (g_clientInfo.isBrowser(ClientInfo.MSIE))
{
if ((!!(win.dialogArguments)) && (!!(win.dialogArguments.m_isWDKModalPopup)))
{
win.open(strUrl, win.name);
}
else
{
win.location.replace(strUrl);
}
}
else
{
win.location.replace(strUrl);
}
}
else
{
var formHtml = generateFormHTML(formName, strUrl, win.name);
var targetDocument = win.document;
targetDocument.open();
targetDocument.write("<html><head></head><body>" + formHtml + "</body></html>");
targetDocument.close();
targetDocument.forms[formName].submit();
}
}
function generateFormHTML (formName, strUrl, strTarget)
{
var urlParser = new UrlParser(strUrl, true);
// decode +'s since our URL comes from java.net.URLEncoder
var base = urlParser.getBase();
var parameters = urlParser.getParameterMap();
var strFormElems = "";
for (var name in parameters)
{
var values = parameters[name];
for (var i = 0; i < values.length; i++)
{
strFormElems += "<input type='hidden' name='" + name + "' value='" + values[i] + "' />";
}
}
var formElem = "<form name='" + formName + "' action='" + base + "' method='POST'";
if ((typeof strTarget != "undefined") && (strTarget!= null) && (strTarget.length > 0))
{
formElem += " target='" + strTarget + "'";
}
formElem += ">" + strFormElems + "</form>";
return formElem;
}
function getBrowserId()
{
var topWin = getTopLevelWnd();
if (getWindowOpener() != null)
{
topWin = getTopLevelWndForApplication();
}
if (topWin.name == null || topWin.name == "")
{
topWin.name = (new Date()).getTime();
}
return topWin.name;
}
function addBrowserIdToURL(strUrl)
{
if (strUrl == "")
{
strUrl = "/";
}
if (strUrl.indexOf("__dmfClientId") == -1)
{
strUrl += ((strUrl.indexOf("?") == -1) ? "?" : "&");
strUrl += "__dmfClientId=" + getBrowserId();
}
return strUrl;
}
var topLevelWnd = null;
function getTopLevelWnd()
{
if (topLevelWnd == null)
{
topLevelWnd = this;
while (topLevelWnd.parent != topLevelWnd && isDispatchableWindow(topLevelWnd.parent))
{
topLevelWnd = topLevelWnd.parent;
}
}
if ((typeof(topLevelWnd) != "undefined") && (!!(topLevelWnd.dialogArguments)) &&
(!!(topLevelWnd.dialogArguments.m_popupWindowName)))
{
if (topLevelWnd.name != topLevelWnd.dialogArguments.m_popupWindowName)
{
topLevelWnd.name = topLevelWnd.dialogArguments.m_popupWindowName;
}
}
return topLevelWnd;
}
function getTopLevelWndForApplication()
{
return getTopMostWindowOpener().getTopLevelWnd();
}
getTopLevelWnd._scope = window;
var g_popupWin=null;
function registerPopupWnd(win)
{
if (getTopLevelWnd().g_popupWin == undefined ||  getTopLevelWnd().g_popupWin == null)
{
getTopLevelWnd().g_popupWin = win;
}
}
function unregisterPopupWnd()
{
getTopLevelWnd().g_popupWin=null;
}
function focusPopupWnd()
{
if (getTopLevelWnd().g_popupWin != undefined && getTopLevelWnd().g_popupWin != null && getTopLevelWnd().g_popupWin.closed == false )
{
getTopLevelWnd().g_popupWin.focus();
}
}
function getPopupWnd()
{
if (getTopLevelWnd().g_popupWin != undefined && getTopLevelWnd().g_popupWin != null)
{
return getTopLevelWnd().g_popupWin;
}
else
{
return null;
}
}
function getAbsoluteFramePath(frameName)
{
var absolutePath = null;
var framePath = getRelativeFramePath(getTopLevelWnd(), frameName);
if (framePath != null)
{
absolutePath = "getTopLevelWnd()." + framePath;
}
return absolutePath;
}
function getRelativeFramePath(containerFrame, frameName)
{
var framePath = null;
for (var iChildFrame = 0; iChildFrame < containerFrame.frames.length; iChildFrame++)
{
var objChildFrame = containerFrame.frames[iChildFrame];
if (isAccessibleWindow(objChildFrame) && objChildFrame.name == frameName)
{
framePath = "frames[" + iChildFrame + "]";
break;
}
}
if (framePath == null)
{
for (var iChildFrame = 0; iChildFrame < containerFrame.frames.length; iChildFrame++)
{
var childFramePath = getRelativeFramePath(containerFrame.frames[iChildFrame], frameName);
if (childFramePath != null)
{
framePath = "frames[" + iChildFrame + "]." + childFramePath;
break;
}
}
}
return framePath;
}
function getFrameNamePath(wnd)
{
// recurively build parent's frame path
if (wnd == getTopLevelWnd())
{
return "";
}
var parent = wnd.parent;
if (parent != null)
{
for (var i = 0; i < parent.frames.length; i++)
{
var frameWnd = parent.frames[i];
if (frameWnd == wnd)
{
var parentFrameNamePath = getFrameNamePath(parent);
if (parentFrameNamePath != null)
{
return parentFrameNamePath + '/' + frameWnd.name;
}
}
}
}
return null;
}
function isValidFrameNamePath(frameNamePath)
{
return _isValidFrameNamePath(getTopLevelWnd(), frameNamePath.substring(1));
}
function _isValidFrameNamePath(wnd, frameNamePath)
{
var slash = frameNamePath.indexOf("/");
if (slash != -1)
{
var frameName = frameNamePath.substring(0, slash);
for (var i = 0; i < wnd.frames.length; i++)
{
if (wnd.frames[i].name == frameName)
{
return _isValidFrameNamePath(wnd.frames[i], frameNamePath.substring(slash+1))
}
}
return false;
}
else
{
return true;
}
}
function walkDownFrameSet(strFramePath)
{
var strResult = strFramePath;
if ((strResult != null) && (typeof strResult != "undefined"))
{
var oFrame = eval(strResult);
while (oFrame && oFrame.isNest && oFrame.isNest._scope == oFrame)
{
strResult += ".frames[0]";
oFrame = eval(strResult);
}
}
return strResult;
}
function isDispatchableWindow(wnd)
{
var bIsDispatchable = false;
if (isAccessibleWindow(wnd))
{
if (typeof(wnd.getTopLevelWnd) != "undefined" && wnd.getTopLevelWnd._scope == wnd)
{
bIsDispatchable = true;
}
}
return bIsDispatchable;
}
function isAccessibleWindow(wnd)
{
var bIsAccessible = false;
try
{
if ("x" + wnd.location + "x" != "xx")
{
if (typeof(wnd.document) == "object")
{
bIsAccessible = true;
}
}
}
catch(e)
{
// If we hit errors here, we can only assume it's because of something very
// Whatever the reason, if we can't get to something as basic as wnd.document and
// wnd.location, WDK can't do anything with the wnd anyway. Hence return false.
bIsAccessible = false;
}
return bIsAccessible;
}
function isWindowInitialised(wnd)
{
var bWindowInitialised = false;
if (isDispatchableWindow(wnd) == true)
{
bWindowInitialised = _isWindowInitialised(wnd);
}
return bWindowInitialised;
}
function _isWindowInitialised(wnd)
{
var bWindowInitialised = false;
if (typeof(wnd.g_bWindowInitialised) != "undefined")
{
bWindowInitialised = wnd.g_bWindowInitialised;
}
else
{
bWindowInitialised = true;
}
if ( bWindowInitialised == true && g_clientInfo.isBrowser(ClientInfo.SAFARI) )
{
bWindowInitialised = (wnd.document.readyState == 'complete');
}
return bWindowInitialised;
}
function isValidWindow(path)
{
var bValid = true;
var wnd = eval(path);
if ( wnd && isAccessibleWindow(wnd) )
{
if ( isDispatchableWindow(wnd) )
{
bValid = _isWindowInitialised(wnd);
}
else
{
// Currently due to the frame javascript scope bug with Safari there's no way to differentiate this case
bValid = true;
}
}
else
{
bValid = false;
}
return bValid;
}
function allWindowsInitialised(wnd)
{
var initialised = true;
var currentWindowInitialised = isWindowInitialised(wnd);
if ( currentWindowInitialised == true )
{
if (wnd.frames.length > 0)
{
for (var j=0; j < wnd.frames.length; j++)
{
initialised = allWindowsInitialised(wnd.frames[j]);
if ( initialised == false )
{
break;
}
}
}
}
else
{
initialised = false;
}
return initialised;
}
function createTestHook(contextPath)
{
var element = window.document.createElement("IMG");
element.id = "wdk_window_initialised";
element.src = contextPath + "/wdk/modalFade.gif";
with (element.style)
{
top = 1;
left = 1;
width = 1;
height = 1;
alt = "";
overflow = "hidden";
position = "absolute";
visibility = "visible";
}
window.document.body.appendChild(element);
}
function setFocusOnFrame(strFrameName)
{
var strFramePath = getAbsoluteFramePath(strFrameName);
var frameWindow = eval(getAbsoluteFramePath(strFrameName));
frameWindow.focus();
}
function setFocusOnFirstElementInFrame(strFrameName)
{
var strFramePath = getAbsoluteFramePath(strFrameName);
var frameElement = document.getElementById(strFrameName);
var frameWindow = eval(getAbsoluteFramePath(strFrameName));
for(var i=0;i<frameWindow.document.forms[0].elements.length;i++)
{
var element =frameWindow.document.forms[0].elements[i] ;
try
{
element.focus();
break;
}
catch(er)
{
}
}
}
function setFocusOnWorkAreaLinkInTitleFrame()
{
var frameWindow = eval(getAbsoluteFramePath("titlebar"));
try
{
var elemName = frameWindow.document.getElementById("workarealink");
elemName.focus();
}
catch(er)
{
}
}
function getAbsoluteLeft(objectId)
{
var o = document.getElementById(objectId)
oLeft = o.offsetLeft
while(o.offsetParent!=null)
{
oParent = o.offsetParent
oLeft += oParent.offsetLeft
o = oParent
}
return oLeft
}
function getAbsoluteTop(objectId)
{
var o = document.getElementById(objectId)
oTop = o.offsetTop
while(o.offsetParent!=null)
{
oParent = o.offsetParent
oTop += oParent.offsetTop
o = oParent
}
return oTop
}
function getAbsoluteRight(objectId)
{
return getAbsoluteLeft(objectId) + document.getElementById(objectId).offsetWidth;
}
function getAbsoluteBottom(objectId)
{
return getAbsoluteTop(objectId) + document.getElementById(objectId).offsetHeight;
}
function ClientInfo() {
this.m_browserInfo = new Array();
this.m_platformInfo = new Array();
this.m_browserVersion      = "";
this.m_browserVersionMajor = "";
this.m_browserVersionMinor = "";
this.m_initialized = false;
this.init();
};
ClientInfo.prototype.isBrowser = function(oBrowser)
{
return (typeof this.m_browserInfo[oBrowser.getId()] != 'undefined');
};
ClientInfo.prototype.isPlatform = function(oPlatform)
{
return (typeof this.m_platformInfo[oPlatform.getId()] != 'undefined');
};
ClientInfo.prototype.getBrowserVersion = function()
{
return this.m_browserVersion;
};
ClientInfo.prototype.getBrowserVersionMajor = function()
{
return this.m_browserVersionMajor;
};
ClientInfo.prototype.getBrowserVersionMinor = function()
{
return this.m_browserVersionMinor;
};
ClientInfo.prototype.isBrowserVersionSupported = function(strSupportedList)
{
var bIsSupported = false;
if (strSupportedList)
{
var verarr = strSupportedList.split(",");
var majorMinor = this.getBrowserVersionMajor() + "." + this.getBrowserVersionMinor().split(".")[0];
for (i=0; i<verarr.length; i++)
{
if (verarr[i].indexOf(majorMinor, 0) != -1)
{
bIsSupported = true;
break;
}
}
if (!bIsSupported)
{
bIsSupported = (strSupportedList.indexOf(this.getBrowserVersion()) != -1);
}
}
return bIsSupported;
};
ClientInfo.prototype.isJavaEnabled = function()
{
return navigator.javaEnabled();
};
ClientInfo.prototype.toString = function()
{
var buf = "Browsers=[";
var browsers = "";
for (var i in this.m_browserInfo)
{
if (browsers != "") browsers += ",";
browsers += this.m_browserInfo[i].getId();
}
buf += browsers + "];";
buf += "Platforms=[";
var platforms = "";
for (var j in this.m_platformInfo)
{
if (platforms != "") platforms += ",";
platforms += this.m_platformInfo[j].getId();
}
buf += platforms + "];";
buf += "BrowserVersions(Full,Maj,Min)=" + this.m_browserVersion + "," + this.m_browserVersionMajor + "," + this.m_browserVersionMinor +";";
buf += "Initialized=" + this.m_initialized;
return buf;
};
function Platform(strId) {
this.strId = strId;
};
Platform.prototype.getId = function() {
return this.strId;
};
function Browser(strId) {
this.strId = strId;
};
Browser.prototype.getId = function() {
return this.strId;
};
ClientInfo.MOZILLA    = new Browser("MOZILLA");
ClientInfo.MSIE       = new Browser("MSIE");
ClientInfo.NETSCAPE   = new Browser("NETSCAPE");
ClientInfo.SAFARI     = new Browser("SAFARI");
ClientInfo.FIREFOX    = new Browser("FIREFOX");
ClientInfo.MACOS      = new Platform("MACOS");
ClientInfo.MACOS_9    = new Platform("MACOS_9");
ClientInfo.MACOS_X    = new Platform("MACOS_X");
ClientInfo.SUNOS      = new Platform("SUNOS");
ClientInfo.LINUX      = new Platform("LINUX");
ClientInfo.UNIX       = new Platform("UNIX");
ClientInfo.WIN2K      = new Platform("WIN2K");
ClientInfo.WINNT      = new Platform("WINNT");
ClientInfo.WINXP      = new Platform("WINXP");
ClientInfo.WIN        = new Platform("WIN");
ClientInfo.UNKNOWN_BROWSER = new Browser("UNKNOWN_BROWSER");
ClientInfo.UNKNOWN_PLATFORM = new Platform("UNKNOWN_PLATFORM");
ClientInfo.prototype.isInitialized = function()
{
return this.m_initialized;
};
ClientInfo.prototype.init = function()
{
if (this.isInitialized() == false)
{
var userAgent = navigator.userAgent.toLowerCase();
var is_ie = ((userAgent.indexOf("msie") != -1) && (userAgent.indexOf("opera") == -1));
var is_safari = ((userAgent.indexOf("safari") != -1));
if (is_ie)
{
this.setClientBrowser(ClientInfo.MSIE);
}
else if (is_safari)
{
this.setClientBrowser(ClientInfo.SAFARI);
}
else
{
var is_moz = ((userAgent.indexOf("mozilla") != -1) && (userAgent.indexOf("spoofer") == -1)
&& (userAgent.indexOf("compatible") == -1) && (userAgent.indexOf("opera") == -1)
&& (userAgent.indexOf("webtv") == -1) && (userAgent.indexOf("hotjava") == -1));
var is_netscape = is_moz && (userAgent.indexOf("netscape") != -1);
if (is_moz)
{
this.setClientBrowser(ClientInfo.MOZILLA);
if (userAgent.indexOf("firefox") != -1)
{
this.setClientBrowser(ClientInfo.FIREFOX);
}
}
if (is_netscape)
{
this.setClientBrowser(ClientInfo.NETSCAPE);
}
}
if ((this.isClientBrowserKnown()) == false)
{
this.setClientBrowser(ClientInfo.UNKNOWN_BROWSER);
}
var is_win = ((userAgent.indexOf("windows") != -1) || (userAgent.indexOf("16bit") != -1));
var is_mac = (userAgent.indexOf("mac") != -1);
var is_maxosx = (is_mac && userAgent.indexOf("mac os x") != -1);
var is_linux = (userAgent.indexOf("linux") != -1);
var is_sunos = (userAgent.indexOf("sunos") != -1);
var is_unix = !is_win &&
(is_maxosx || is_linux || is_sunos
|| (userAgent.indexOf("x11") != -1)
|| (userAgent.indexOf("irix") != -1)
|| (userAgent.indexOf("hp-ux") != -1)
|| ((userAgent.indexOf("sco") != -1) || (userAgent.indexOf("unix_sv") != -1))
|| (userAgent.indexOf("unix_system_v") != -1)
|| (userAgent.indexOf("ncr") != -1)
|| (userAgent.indexOf("reliantunix") != -1)
|| ((userAgent.indexOf("dec") != -1) || (userAgent.indexOf("osf1") != -1) ||
(userAgent.indexOf("dec_alpha") != -1) || (userAgent.indexOf("alphaserver") != -1) ||
(userAgent.indexOf("ultrix") != -1) || (userAgent.indexOf("alphastation") != -1))
|| (userAgent.indexOf("sinix") != -1)
|| (userAgent.indexOf("aix") != -1)
|| (userAgent.indexOf("inux") != -1)
|| (userAgent.indexOf("bsd") != -1)
|| (userAgent.indexOf("freebsd") != -1));
if (is_win)
{
this.setClientPlatform(ClientInfo.WIN);
if (is_win && ((userAgent.indexOf("windows nt 5.1") != -1)))
{
this.setClientPlatform(ClientInfo.WINXP);
}
else if (is_win && ((userAgent.indexOf("windows nt 5.0") != -1)))
{
this.setClientPlatform(ClientInfo.WIN2K);
}
else if (is_win && ((userAgent.indexOf("windows nt 4.0") != -1)))
{
this.setClientPlatform(ClientInfo.WINNT);
}
}
else if (is_mac)
{
this.setClientPlatform(ClientInfo.MACOS);
if (is_maxosx)
{
this.setClientPlatform(ClientInfo.MACOS_X);
}
else
{
var is_macos9 = (is_mac && !is_maxosx);
if (is_macos9)
{
this.setClientPlatform(ClientInfo.MACOS_9);
}
}
}
else if (is_linux)
{
this.setClientPlatform(ClientInfo.LINUX);
}
if (is_unix)
{
this.setClientPlatform(ClientInfo.UNIX);
}
if ((this.isClientPlatformKnown()) == false)
{
this.setClientPlatform(ClientInfo.UNKNOWN_PLATFORM);
}
this.initBrowserVersion(userAgent);
this.m_initialized = true;
}
};
ClientInfo.prototype.initBrowserVersion = function(userAgent)
{
var recognizedAgent = false;
if (userAgent)
{
var startIndex = -1;
var endIndex = -1;
if (this.isBrowser(ClientInfo.NETSCAPE) || this.isBrowser(ClientInfo.FIREFOX))
{
startIndex = userAgent.lastIndexOf("/");
if (startIndex != -1)
{
startIndex = startIndex + 1;
endIndex = userAgent.indexOf(" ", startIndex);
if (endIndex == -1)
{
endIndex = userAgent.length;
}
}
}
else if (this.isBrowser(ClientInfo.MSIE))
{
startIndex = userAgent.indexOf("msie ");
if (startIndex != -1)
{
startIndex = startIndex + 5;
endIndex = userAgent.indexOf(";", startIndex);
}
}
else if (this.isBrowser(ClientInfo.MOZILLA))
{
startIndex = userAgent.indexOf("rv:");
if (startIndex != -1)
{
startIndex = startIndex + 3;
endIndex = userAgent.indexOf(")", startIndex);
}
}
else if (this.isBrowser(ClientInfo.SAFARI))
{
startIndex = userAgent.lastIndexOf("/");
if (startIndex != -1)
{
startIndex = startIndex + 1;
endIndex = userAgent.length;
}
}
if (startIndex != -1 && endIndex != -1 && startIndex < endIndex)
{
recognizedAgent = true;
this.m_browserVersion = userAgent.substring( startIndex, endIndex );
var decimalIndex = this.m_browserVersion.indexOf(".");
if (decimalIndex != -1)
{
this.m_browserVersionMajor = this.m_browserVersion.substring(0, decimalIndex);
this.m_browserVersionMinor = this.m_browserVersion.substring(decimalIndex+1);
}
else
{
this.m_browserVersionMajor = this.m_browserVersion;
this.m_browserVersionMinor = "";
}
}
}
if (recognizedAgent == false)
{
this.m_browserVersion      = "";
this.m_browserVersionMinor = "";
this.m_browserVersionMajor = "";
}
};
ClientInfo.prototype.setClientBrowser = function(oBrowser)
{
this.m_browserInfo[oBrowser.getId()] = oBrowser;
};
ClientInfo.prototype.setClientPlatform = function(oPlatform)
{
this.m_platformInfo[oPlatform.getId()] = oPlatform;
};
ClientInfo.prototype.isClientBrowserKnown = function()
{
return (this.getLength(this.m_browserInfo) > 0);
};
ClientInfo.prototype.isClientPlatformKnown = function()
{
return (this.getLength(this.m_platformInfo) > 0);
};
ClientInfo.prototype.getLength = function(assocArray)
{
var i = 0;
for (var p in assocArray)
{
i++;
}
return i;
};
var g_clientInfo = new ClientInfo();
function isModalPopup()
{
return ((!!(getTopLevelWnd().dialogArguments)) && (!!(getTopLevelWnd().dialogArguments.m_isWDKModalPopup)));
}
function getWindowOpener()
{
if (isModalPopup())
{
return getTopLevelWnd().dialogArguments.m_parentWindow;
}
else
{
return null;
}
}
function getTopMostWindowOpener()
{
var topMostWindowOpener = window;
while(topMostWindowOpener.getWindowOpener())
{
topMostWindowOpener = topMostWindowOpener.getWindowOpener();
}
return topMostWindowOpener;
}

