//-------------------------------------------------------
// Xdk JavaScipt support routines
// (c) 2001, 2002 RepubliCorp P/L
// Version 1.1
// Author: John Bradnam
//-------------------------------------------------------

//----------------------------------------------
//Generic popup functions
//----------------------------------------------

var m_sErrLinksToObjects = 'Hyperlinks to objects do not work in popups.'

var m_PopupDiv = null;
var m_PopupShadowDiv = null;
var m_PopupTopicDiv = null;
var m_PopupDivStyle = null;
var m_PopupIFrame = null;
var m_PopupIFrameStyle = null;
var m_wPopupClickX = 0;
var m_wPopupClickY = 0;
var m_fPopupTimeoutExpired = false;

function XdkOnMouseOver(event)
{
  var oBody   = document.body;
  var oBanner = oBody.firstChild;
  var wHeight = 0;
  var wTop    = oBody.scrollTop;
  var wLeft   = oBody.scrollLeft;
  if (oBanner.id == "XdkBanner") {
    wHeight   = oBanner.offsetHeight;
    wTop      = oBanner.nextSibling.scrollTop;
    wLeft     = oBanner.nextSibling.scrollLeft;
  }

  //Record mouse position over link for popup positioning
  window.m_wPopupClickX = event.clientX + wLeft;
  window.m_wPopupClickY = event.clientY + wTop - wHeight;
} //XdkOnMouseOver

function XdkPopup(sUrl)
{
  //Only work on IE4 and higher for Windows
  if ((parseInt(navigator.appVersion) >= 4) && 
      (navigator.appName.indexOf("Microsoft") != -1) &&
      (navigator.userAgent.toLowerCase().indexOf("mac") == -1)) {
    if (m_PopupDiv == null) {
      var oTag = document.all.tags("div");
      for (var iDiv = 0; iDiv < oTag.length; iDiv++) {
        if (oTag(iDiv).id == "XdkPopup")
          m_PopupDiv       = oTag(iDiv);
        if (oTag(iDiv).id == "XdkPopupShadow")
          m_PopupShadowDiv = oTag(iDiv);
        if (oTag(iDiv).id == "XdkPopupTopic")
          m_PopupTopicDiv  = oTag(iDiv);
      } //for
      m_PopupIFrame = eval("m_PopupDiv.document.frames['XdkPopupIFrameName']");
      m_PopupDivStyle = eval("m_PopupDiv.style");
      m_PopupIFrameStyle = eval("document.all['XdkPopupIFrameName'].style");
    }
    if (this.name == "XdkPopupIFrameName") {
      //Use existing window
      location.href = sURL;
      parent.window.m_fPopupTimeoutExpired = false;
    }
    else {
      m_PopupIFrame.location.href = sUrl;
      window.m_fPopupTimeoutExpired = false;
    }
    setTimeout("_XdkPopup()",200);
  }
  else {
    var sParam = "titlebar=no,toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=yes,";
    sParam = sParam + "height=300,width=400";
    sParam = sParam + ",screenX=" + window.m_wPopupClickX + ",screenY=" + window.m_wPopupClickY;
    window.open(sUrl,"",sParam);
  }
} //XdkPopup

function _XdkPopup()
{
  if ((window.m_PopupIFrame.document.readyState == "complete") && (window.m_PopupIFrame.document.body != null))
    _XdkResize();
  else
    setTimeout("_XdkPopup()",200);
} //_XdkPopup

function _XdkResize()
{
  window.m_PopupDivStyle.visibility = "hidden";
  var oSize         = new _XdkGetPointObject(0,0);
  _XdkGetPopupSize(window.m_PopupIFrame,oSize);
  window.m_PopupDivStyle.width  = oSize.x;
  window.m_PopupDivStyle.height = oSize.y;
  var oPosition     = new _XdkGetPointObject(0,0);
  _XdkGetPopupPosition(oPosition,oSize);
  window.m_PopupDivStyle.left = oPosition.x;
  window.m_PopupDivStyle.top = oPosition.y;
  window.m_PopupShadowDiv.style.left = 6;
  window.m_PopupShadowDiv.style.top = 6;
  window.m_PopupShadowDiv.style.width = oSize.x;
  window.m_PopupShadowDiv.style.height = oSize.y;
  window.m_PopupTopicDiv.style.width = oSize.x;
  window.m_PopupTopicDiv.style.height = oSize.y;
  window.m_PopupIFrameStyle.width = oSize.x;
  window.m_PopupIFrameStyle.height = oSize.y;
  window.m_PopupDivStyle.visibility = "visible";
  setTimeout("_XdkResizeTimeout();", 100);
  return false;
} //_XdkResize

function _XdkResizeTimeout()
{
  if ((m_PopupIFrame.document.readyState == "complete") && (m_PopupIFrame.document.body != null)) {
    window.m_fPopupTimeoutExpired = true;
    if (m_PopupIFrame.document)
      m_PopupIFrame.document.body.onclick = _XdkPopupClicked;
    document.onmousedown = _XdkPopupParentClicked;
  }
  else
	setTimeout("_XdkResizeTimeout()", 100);
} //_XdkResizeTimeout

function _XdkGetPointObject(x, y)
{
  this.x = x;
  this.y = y;
} //_XdkGetPointObject

function _XdkGetPopupSize(oWindow,oSize)
{
  var wClientWidth  = document.body.clientWidth;
  var wClientHeight = document.body.clientHeight;
  var oBody         = oWindow.document.body;
  var wX            = wClientWidth - 20;
  var wY            = 1;
  oWindow.resizeTo(1,1);
  oWindow.resizeTo(1,1);
  oWindow.resizeTo(wX,oBody.scrollHeight);
  oWindow.resizeTo(wX,oBody.scrollHeight);
  oSize.x           = wX;
  oSize.y           = oBody.scrollHeight;
  var wBottom       = 25;
  var wTop          = oSize.x;
  var wMiddle       = 0;
  while (wX != wMiddle) {
    wMiddle         = wX;
    wX              = (wBottom + wTop) >> 1;
    oWindow.resizeTo(wX,oSize.y);
    oWindow.resizeTo(wX,oSize.y);
    if ((oBody.scrollHeight > oSize.y) || (oBody.scrollWidth > wX))
      wBottom       = wX;
    else
      wTop          = wX;
  } //while
  wX                = wBottom;
  oWindow.resizeTo(wX,wY);
  oWindow.resizeTo(wX,wY);
  oSize.x           = oBody.scrollWidth + 20;
  if (oSize.y < 40)
    oSize.y         = 40;
  oWindow.resizeTo(oSize.x,oSize.y);
  oWindow.resizeTo(oSize.x,oSize.y);
  return;
} //_XdkGetPopupSize

function _XdkGetPopupPosition(oPosition,oSize)
{
  var oBody   = document.body;
  var oBanner = oBody.firstChild;
  var wHeight = 0;
  var wTop    = oBody.scrollTop;
  var wLeft   = oBody.scrollLeft;
  if (oBanner.id == "XdkBanner") {
    wHeight   = oBanner.offsetHeight;
    wTop      = oBanner.nextSibling.scrollTop;
    wLeft     = oBanner.nextSibling.scrollLeft;
  }
  var wClickX = window.m_wPopupClickX;
  var wClickY = window.m_wPopupClickY;
  var wMaxWidth  = oBody.clientWidth + wLeft - 20;
  var wMaxHeight = oBody.clientHeight + wTop - 40;
  if (wClickX + oSize.x < wMaxWidth)
    oPosition.x = wClickX;
  else
    oPosition.x = wMaxWidth - oSize.x - 8;
  if (wClickY + oSize.y + 20 < wMaxHeight)
    oPosition.y = wClickY + 10;
  else
    oPosition.y = wMaxHeight - oSize.y - 20;
  if (oPosition.x < 0) oPosition.x = 1;
  if (oPosition.y < 0) oPosition.y = 1;
} //_XdkGetPopupPosition

function _XdkPopupParentClicked()
{
  _XdkPopupClicked();
  return;
} //_XdkPopupParentClicked

function _XdkPopupClicked()
{
  var fResult = false;
  if (window.m_fPopupTimeoutExpired) {
    var oEvent = m_PopupIFrame.window.event;
    if ((oEvent != null) &&
        (oEvent.srcElement != null) &&
        (oEvent.srcElement.tagName == "A") &&
        (oEvent.srcElement.href.indexOf("javascript:") == 0) &&
        (oEvent.srcElement.href.indexOf(".") != -1)) {
      //Call through an object error
      m_PopupIFrame.window.event.cancelBubble = true;
      alert(m_sErrLinksToObjects);
    }
    else {
      if (m_PopupIFrame.document)
        m_PopupIFrame.document.body.onclick = null;
      document.onclick = null;
      document.onmousedown = null;
      m_PopupDivStyle.visibility = "hidden";
      fResult = true;
    }
  }
  return fResult;
} //_XdkPopupClicked

//----------------------------------------------
//Generic tracking functions
//----------------------------------------------

function XdkTrack(sFrameSetUrl,sTocFrameName,fObject)
{
  var date = new Date();
  date.setYear(date.getYear() + 1);
  if ((window.frameElement == null) || (window.frameElement.tagName != "IFRAME")) {
    var sThisUrl = "none";
    if (navigator.cookieEnabled) {
      var aCookie = document.cookie.split(";");
      for (var i=0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if ((aCrumb[0] == "RpoTrack") && (aCrumb[1] != "none")) {
          //Before we access the cookie, check to see if the toc window is present
          try{
            if (fObject == true)
              window.parent.frames[sTocFrameName].document.toc.setCurrent(window.location.href);
            else
              window.parent.frames[sTocFrameName].setCurrent(window.location.href);
            //Will only get here if the toc is loaded and running
            sThisUrl = unescape(aCrumb[1]);
            if (sThisUrl != window.location.href) {
              window.status = "Switching to " + sThisUrl;
              setTimeout("_XdkTrackWait('" + sThisUrl + "','" + sTocFrameName + "'," + fObject + ")",2000);
            }
            else
              document.cookie = "RpoTrack=none;path=/;expires=" + date.toGMTString();
          }
          catch(wError) {
            setTimeout("XdkTrack('" + sFrameSetUrl + "','" + sTocFrameName + "'," + fObject + ")",250);
            sThisUrl = "";
          }
          break;
        }
      } //for
    }
    if (sThisUrl == "none") {
      if (window.parent.frames[sTocFrameName])
        _XdkTrackWait(location.href,sTocFrameName,fObject);
      else {
        if (navigator.cookieEnabled)
          document.cookie = "RpoTrack=" + escape(location.href) + ";path=/;expires=" + date.toGMTString();
        window.location.replace(sFrameSetUrl);
//      open(sFrameSetUrl,"_top");
      }
    }
  }
} //XdkTrack

function _XdkTrackWait(sPageUrl,sTocFrameName,fObject)
{
  //Set the href of the frame and when the TOC is ready, sync it
  try {
    if (fObject == true)
       window.parent.frames[sTocFrameName].document.toc.setCurrent(sPageUrl);
    else
       window.parent.frames[sTocFrameName].setCurrent(sPageUrl);
    if (window.location.href != sPageUrl) {
      window.location.href = sPageUrl;
      throw "error";
    }
    var date = new Date();
    date.setYear(date.getYear() - 1);
    if (navigator.cookieEnabled)
      document.cookie = "RpoTrack=none;path=/;expires=" + date.toGMTString();
    window.status = "Done";
  }
  catch(wError) {
    setTimeout("_XdkTrackWait('" + sPageUrl + "','" + sTocFrameName + "'," + fObject + ")",500);
  }
} //_XdkTrackWait

//----------------------------------------------
//Generic show/hide division functions
//----------------------------------------------

function XdkShowHide(sId) {
  var   oCol = null;
  var   oDiv = null;
  var   oImg = null;
  var   wIndex

  oCol = document.all.item(sId);  //Can return a image and span or division
  oDiv = oCol;
  if (oCol.length != 0) {
    for (wIndex = 0;wIndex < oCol.length;wIndex++) {
      if (oCol(wIndex).tagName == "IMG")
        oImg = oCol(wIndex);
      else
        oDiv = oCol(wIndex);
    }//for
  }
  if (oDiv != null) {
    if ((oDiv.style != null) && (oDiv.style.display == "none")) {
      oDiv.style.display = "";
      if (oImg != null)
        oImg.src = oImg.show;
    }
    else {
      oDiv.style.display = "none";
      if (oImg != null)
        oImg.src = oImg.hide;
    }
  }
} //XdkShowHide

//----------------------------------------------
//Create a popup menu
//----------------------------------------------

var oXdkGblMenu = null;

function XdkPopupMenu(event) {
  var oSty       = null;
  var oMnu       = null;
  var oTbl       = null;
  var oNxt       = null;
  var oSpn       = null;
  var oRow       = null;
  var wTop       = 0;
  var wBottom    = 0;
  var sAdd       = '';
  var oAnc       = event.srcElement;
  var oBody      = document.body;
  var wMouseX    = event.clientX - 10;
  var wMouseY    = event.clientY - 5;
  var rightedge  = oBody.clientWidth - wMouseX;
  var bottomedge = oBody.clientHeight - wMouseY;
  var oBanner    = oBody.firstChild;
  var wTop       = oBody.scrollTop;
  var wLeft      = oBody.scrollLeft;
  if (oBanner.id == "XdkBanner") {
    wTop         = oBanner.nextSibling.scrollTop;
    wLeft        = oBanner.nextSibling.scrollLeft;
  }

  oMnu                 = document.createElement("div");
  oMnu.attachEvent("onmouseover",_XdkHighlightPopupMenu);
  oMnu.attachEvent("onmouseout",_XdkLowlightPopupMenu);
  oMnu.attachEvent("onmousedown",_XdkClickPopupMenu);
  oSty = oMnu.style;
  oSty.position        = "absolute";
  oSty.visibility      = "hidden";
  oSty.overflow        = "hidden";
  document.body.appendChild(oMnu);
  oTbl                 = document.createElement("table");
  oMnu.appendChild(oTbl);
  //Add the elements
  oTbl.style.cursor    = "default";
  oTbl.style.color     = "menutext";
  oTbl.style.backgroundColor = "menu";
  oTbl.style.border    = "2px outset threedhighlight";
  oTbl.cellPadding     = 1;
  oTbl.cellSpacing     = 1;
  oTbl.onselectstart   = "javascript:return false;"
  if ((oAnc.tagName == "IMG") && (oAnc.up == null))
    oAnc               = oAnc.parentElement;
  oSpn                 = oAnc.nextSibling;
  while ((oSpn != null) && (oSpn.tagName == "SPAN") && (oSpn.href != null)) {
    oNxt      = oSpn.nextSibling;
    wTop      = 1;
    wBottom   = 1;
    if (oSpn == oAnc.nextSibling)
      wTop    = 2;
    if ((oNxt == null) || (oNxt.tagName != "SPAN") || (oNxt.href == null))
      wBottom = 2;
    oRow      = oTbl.insertRow(-1);
    oRow.style.fontFamily = "tahoma";
    oRow.style.fontSize   = "8pt";
    oRow.style.color      = "menutext";
    oRow.style.padding    = wTop + "px 10px " + wBottom + "px 10px";
    if (oSpn.getAttribute("href") != null)
      oRow.href=oSpn.getAttribute("href");
    if (oSpn.getAttribute("target") != null)
      oRow.target=oSpn.getAttribute("target");
    oRow.insertCell(-1).innerText = oSpn.innerText;
    oSpn               = oNxt;
  } //while
  //show menu
  if (rightedge < oTbl.offsetWidth)
    oSty.left          = wLeft + wMouseX - oTbl.offsetWidth;
  else
    oSty.left          = wLeft + wMouseX;
  if (bottomedge < oTbl.offsetHeight)
    oSty.top           = wTop + wMouseY - oTbl.offsetHeight;
  else
    oSty.top           = wTop + wMouseY;
  oSty.visibility      = "visible";
  //set event to close it
  oXdkGblMenu          = oMnu;
  document.attachEvent("onmouseup",_XdkDestroyPopupMenu);
} //XdkPopupMenu

function _XdkDestroyPopupMenu() {
  document.detachEvent("onmouseup",_XdkDestroyPopupMenu);
  if (oXdkGblMenu != null) {
    oXdkGblMenu.style.visibility = "hidden";
    if ((parseInt(navigator.appVersion) >= 4) && (navigator.appVersion.indexOf("MSIE 5.0;") == -1))
      oXdkGblMenu.removeNode(true);
    oXdkGblMenu = null;
  }
} //_XdkDestroyPopupMenu

function _XdkHighlightPopupMenu() {
  var oMnu = event.srcElement;

  if (oMnu.tagName == "TD")
    oMnu = oMnu.parentElement;
  if (oMnu.tagName == "TR") {
    oMnu.style.backgroundColor = "highlight";
    oMnu.style.color = "highlighttext";
  }
} //_XdkHighlightPopupMenu

function _XdkLowlightPopupMenu() {
  var oMnu = event.srcElement;

  if (oMnu.tagName == "TD")
    oMnu = oMnu.parentElement;
  if (oMnu.tagName == "TR") {
    oMnu.style.backgroundColor = "menu";
    oMnu.style.color = "menutext";
  }
} //_XdkLowlightPopupMenu

function _XdkClickPopupMenu() {
  var sUrl    = "";
  var sTarget = "";
  var wError  = 0;
  var oMnu    = event.srcElement;

  if (oMnu.tagName == "TD")
    oMnu = oMnu.parentElement;
  if (oMnu.tagName == "TR") {
    sUrl      = oMnu.getAttribute("href")
    sTarget   = oMnu.getAttribute("target");
    try {
      if (sTarget != null)
        window.open(sUrl,sTarget);
      else
        window.location = sUrl;
    }
    catch (wError) {
      alert('Can\'t execute "' + sUrl + '"');
    }
  }
} //_XdkClickPopupMenu

function XdkPopupMenuExecute() {
} //XdkPopupMenuExecute

//----------------------------------------------
//Generic title area
//----------------------------------------------

function XdkBanner(wLines) {
  var oRest   = null;
  var oNext   = null;
  var oNsr    = null;
  var oScroll = null;
  var wHeight = 0;
  var wTopPad = 6;
  var wBotPad = 0;

  var fIFrame = ((window.frames.length != 0) && (window.frames(0).name != "XdkPopupIFrameName"));
  var oBody   = document.body;
  var oBanner = oBody.firstChild;
  if ((oBanner != null) && (wLines != 0)) {
    oNsr                = document.createElement("div");
    oNsr.id             = "XdkBanner";
    oNsr.style.width    = oBody.clientWidth;
    oNsr.style.height   = 0;
    oNsr.style.overflow = "hidden";
    oBanner.insertAdjacentElement("beforeBegin",oNsr);
    wTopPad             = 6;
    while ((oBanner != null) && (wLines != 0)) {
      if ((oBanner.tagName == "DIV") && (oBanner.className.toLowerCase().indexOf("section") != -1)) {
        oNext   = oBanner.firstChild;
        oBanner.removeNode(false);
        oBanner = oNext;
      }
      if (oBanner.tagName == "TABLE") {
        wHeight = wHeight + oBanner.scrollHeight + 2;
        wTopPad = 6;
      }
      else {
        oBanner.style.margin = "0";
        oBanner.style.textIndent = "0";
        if ((wLines == 1) || 
            ((oBanner.nextSibling != null) && (oBanner.nextSibling.tagName == "TABLE")))
          wBotPad = 6;
        else
          wBotPad = 0;
        oBanner.style.padding = wTopPad + "px,6px," + wBotPad + "px,6px";
        if (wLines == 1)
          oBanner.style.borderBottom = "solid 1pt black";
        wHeight = wHeight + oBanner.scrollHeight;
        wTopPad = 0;
      }
      oBanner   = oBanner.nextSibling;
      oNsr.appendChild(oNsr.nextSibling.removeNode(true));
      wLines  = wLines - 1;
    } //while
    oNsr.style.height            = wHeight;
    oRest                        = oNsr.nextSibling;
    if (oRest != null) {
      oBody.style.overflow       = "hidden";
      oScroll = document.createElement("div");
      oScroll.style.width        = oBody.style.width;
      oScroll.style.padding      = "5px";
      oScroll.style.overflowX    = "auto";
      oScroll.style.overflowY    = "scroll";
      if (fIFrame) {
        oScroll.style.padding    = "0px";
        oScroll.style.overflowY  = "auto";
      }
      oBody.style.margin         = "0";
      oRest.insertAdjacentElement("beforeBegin",oScroll);
      while (oScroll.nextSibling != null)
        oScroll.appendChild(oScroll.nextSibling.removeNode(true));
      window.attachEvent('onresize',_XdkOnResizeBody);
      _XdkOnResizeBody();
    }
  }
  else if (fIFrame) {
    oBody.scroll           = "no";
    oBody.style.overflow   = "hidden";
    oBody.style.margin     = "0px";
  }
} //XdkBanner

function _XdkOnResizeBody() {
  var oBody   = document.body;
  var oBanner = oBody.firstChild;
  var oScroll = oBanner.nextSibling;
  if (oBody.clientHeight > oBanner.clientHeight)
    oScroll.style.height = oBody.clientHeight - oBanner.clientHeight - 1;
  else
    oScroll.style.height = 0;
  oScroll.style.width    = oBody.clientWidth;
  oBanner.style.width    = oBody.clientWidth;
} //_XdkOnResizeBody

//----------------------------------------------
//Generic search highlighting
//----------------------------------------------

function RePublicoSelectWords(sWords, fOn) {
  if( sWords!=null && sWords!="" ) {
    //Show all hidden text
    var wIndex = 0;
    var oDiv   = document.all.tags("DIV");
    if (oDiv != null) {
      for (wIndex = 0;wIndex < oDiv.length;wIndex++) {
        if ((oDiv[wIndex].style != null) && (oDiv[wIndex].style.display == "none")) {
          oDiv[wIndex].style.visibility = "hidden";
          oDiv[wIndex].style.display = "";
          oDiv[wIndex].setAttribute("xdk","search",0);
        }
      } //for
    }
    // word delimeters
    var aWords = sWords.split(sOrAnd);
    var i = 0;
    var fFirst = true;
    for( i in aWords ) {
      var sWord = aWords[i];
      var oRange = window.top.frames(sTocTarget).document.body.createTextRange();
      while( oRange.findText(sWord) ) {
        if (fOn == true) {
          oRange.execCommand("BackColor",false,sSelBack);
          oRange.execCommand("ForeColor",false,sSelFore);
          if (fFirst == true)
            oRange.scrollIntoView();
          fFirst = false;
        }
        else
          oRange.execCommand("RemoveFormat",false,null);
        oRange.collapse(false);
      } //while
    }
    //Hide all hidden text
    if (oDiv != null) {
      for (wIndex = 0;wIndex < oDiv.length;wIndex++) {
        if (oDiv[wIndex].getAttribute("xdk",0) == "search") {
          oDiv[wIndex].style.display = "none";
          oDiv[wIndex].style.visibility = "visible";
          oDiv[wIndex].removeAttribute("xdk",0);
        }
      } //for
    }
  }
} //RePublicoSelectWords

//----------------------------------------------
//Image effect
//----------------------------------------------

function XdkImageEffect(oObject) {
  oObject.style.visibility='hidden';
  oObject.filters.item(0).Apply();
  oObject.style.visibility='';
  oObject.filters.item(0).Play();
} //XdkImageEffect

//----------------------------------------------
//XDK Button
//----------------------------------------------

function XdkButtonOver(oImg) {
  if (oImg.down != oImg.src)
    oImg.src = oImg.over;
} //XdkButtonOver

function XdkButtonOut(oImg) {
  oImg.src = oImg.up;
} //XdkButtonOut

function XdkButtonDown(oImg) {
  oImg.src = oImg.down;
} //XdkButtonDown

function XdkButtonUp(oImg) {
  var sUrl    = "";
  var sTarget = "";
  var sSrc    = "";
  var wError  = 0;

  oImg.src  = oImg.over;
  sSrc      = oImg.getAttribute("src")
  sUrl      = oImg.getAttribute("href")
  sTarget   = oImg.getAttribute("target");
  if ((sUrl != null) && (sUrl != sSrc)) {
    try {
      if (sTarget != null)
        window.open(sUrl,sTarget);
      else
        window.location = sUrl;
    }
    catch (wError) {
      alert('Can\'t execute "' + sUrl + '"');
    }
  }
} //XdkButtonUp

//----------------------------------------------
//XDK Tab bar
//----------------------------------------------

function XdkTabClick(oTable,sId) {
  var fTabbar = (sId.substring(0,3) == "XDK");
  var fLastActive = false;
  if (oTable.className != sId + "Active") {
    var oTabRow = oTable.parentElement.parentElement;
    var oTabCol = oTabRow.firstChild;
    while (oTabCol != null) {
      if ((oTabCol.firstChild == null) || (oTabCol.firstChild.className == null))
        ;
      else if (oTabCol.firstChild == oTable) {
        oTabCol.firstChild.className = sId + "Active";
        eval(oTabCol.firstChild.href);
        fLastActive = true;
      }
      else {
        if ((oTabCol.firstChild.className == sId + "Active") && (fTabbar))
          eval(oTabCol.firstChild.href);
        if (fLastActive) {
          oTabCol.firstChild.className = sId + "InactiveAfter";
          fLastActive = false;
        }
        else if ((oTabCol.nextSibling != null) && (oTabCol.nextSibling.firstChild == oTable))
          oTabCol.firstChild.className = sId + "InactiveBefore";
        else
          oTabCol.firstChild.className = sId + "Inactive";
      }
      oTabCol = oTabCol.nextSibling;
    } //while
  }
} //XdkTabClick

function XdkTabIFrame(sUrl,sTarget)
{
  var oFrame = document.all[sTarget];
  if (oFrame != null)
    oFrame.src = sUrl;
} //XdkTabIFrame

//----------------------------------------------
//XDK Play sound file
//----------------------------------------------

function XdkPlaySoundFile(sFile) {
  var oSound = document.all.XdkSound;
  if (oSound == null) {
    oSound = document.createElement("bgsound");
    oSound.id = "XdkSound";
    document.body.appendChild(oSound);
  }
  oSound.loop = 1;
  oSound.src  = './Multimedia/' + sFile;
} //XdkPlaySoundFile

//----------------------------------------------
//XDK column control
//----------------------------------------------

function XdkColumnSetGraphic(oTable,sImage) {
  oTable.firstChild.firstChild.firstChild.firstChild.src = sImage;
} //XdkColumnSetGraphic

function XdkColumnMouseDown(oTable,sId) {
  oTable.className = sId + "Down";
} //XdkColumnMouseDown

function XdkColumnMouseOut(oTable,sId) {
  oTable.className = sId + "Up";
} //XdkColumnMouseOut

function XdkColumnMouseUp(oTable,sId) {
  oTable.className = sId + "Down";
  oTable.style.cursor = "wait";
  oTable.id = sId;
  setTimeout("_XdkColumnMouseUp('"+sId+"')",10);
} //XdkColumnMouseUp

function _XdkColumnMouseUp(sId) {
  var sRow1 = "";
  var sRow2 = "";
  var oTmp  = null;
  var oTbl  = null;
  var oRow1 = null;
  var oRow2 = null;
  var fSwap = false;

  var oTable = document.all[sId];
  //Sort column
  var fDescend = (oTable.getAttribute("ascend") == "1");
  //Find which column to sort
  var wCol = 1;
  var oCol = oTable.parentElement;
  if (oCol.tagName == "TD") {
    while (oCol.previousSibling != null) {
      wCol = wCol + 1;
      oCol = oCol.previousSibling;
    }
    //Sort rows
    var oHdr    = oCol.parentElement;
    do {
      fSwap = false;
      if ((oHdr.nextSibling == null) && (oHdr.parentElement.tagName == "THEAD"))
        oRow1 = oHdr.parentElement.nextSibling.firstChild;
      else
        oRow1 = oHdr.nextSibling;
      if (oRow1 != null) {
        while (oRow1.nextSibling != null) {
          oRow2 = oRow1.nextSibling;
          sRow1 = XdkColumnGetText((fDescend ? oRow2 : oRow1),wCol);
          sRow2 = XdkColumnGetText((fDescend ? oRow1 : oRow2),wCol);
          if (sRow1 <= sRow2)
            oRow1 = oRow1.nextSibling;
          else {
            while ((sRow1 > sRow2) && (oRow2.nextSibling != null)) {
              oRow2 = oRow2.nextSibling;
              if (!fDescend)
                sRow2 = XdkColumnGetText(oRow2,wCol);
              else
                sRow1 = XdkColumnGetText(oRow2,wCol);
            } //while
            oTmp = oRow1.nextSibling;
            oRow1.removeNode(true);
            if (sRow1 > sRow2)
              oRow2.insertAdjacentElement("afterEnd",oRow1);
            else
              oRow2.insertAdjacentElement("beforeBegin",oRow1);
            oRow1 = oTmp;
            fSwap = true;
          }
        } //while
      }
    } while (fSwap == true);
    //Set image and clear all other column graphics
    oCol = oHdr.firstChild;
    while (oCol != null) {
      oTbl = oCol.firstChild;
      if ((oTbl != null) && (oTbl.tagName == "TABLE")) {
        if (oTbl != oTable) {
          XdkColumnSetGraphic(oTbl,"./Images/RpoColumnNone.gif");
          oTbl.removeAttribute("ascend");
        }
        else if (fDescend) {
          XdkColumnSetGraphic(oTbl,"./Images/RpoColumnDown.gif");
          oTbl.setAttribute("ascend","0");
        }
        else {
          XdkColumnSetGraphic(oTbl,"./Images/RpoColumnUp.gif");
          oTbl.setAttribute("ascend","1");
        }
      }
      oCol = oCol.nextSibling;
    } //while
  }
  oTable.style.cursor = "";
  oTable.className = sId + "Up";
} //_XdkColumnMouseUp

function XdkColumnGetText(oRow,wCol) {
  var oCol  = oRow.firstChild;
  var sText = "";
  while ((oCol != null) && (wCol != 1)) {
    wCol = wCol - 1;
    oCol = oCol.nextSibling;
  } //while
  if (oCol != null)
    sText = oCol.firstChild.innerText;
  return sText;
} //XdkColumnGetText

//----------------------------------------------
//Generic print functions
//----------------------------------------------

function XdkOnBeforePrint() {
  var wIndex = 0;
  var oDiv   = document.all.tags("DIV");
  if (oDiv != null) {
    for (wIndex = 0;wIndex < oDiv.length;wIndex++) {
      if ((oDiv[wIndex].style != null) && (oDiv[wIndex].style.display == "none")) {
        oDiv[wIndex].style.display = "";
        oDiv[wIndex].setAttribute("xdk","print",0);
      }
    } //for
  }
  //Disable banner
  var oBody = document.body;
  var oBanner = oBody.firstChild;
  if (oBanner.id == "XdkBanner") {
    var oScroll = oBanner.nextSibling;
    oBody.style.overflow = "visible";
    oBanner.style.overflow = "visible";
    oScroll.style.overflow = "visible";
    oScroll.style.height = "auto"
    oScroll.style.width  = "auto";
  }
} //XdkOnBeforePrint
        
function XdkOnAfterPrint() {
  var wIndex = 0;
  var oDiv   = document.all.tags("DIV");
  if (oDiv != null) {
    for (wIndex = 0;wIndex < oDiv.length;wIndex++) {
      if (oDiv[wIndex].getAttribute("xdk",0) == "print") {
        oDiv[wIndex].style.display = "none";
        oDiv[wIndex].removeAttribute("xdk",0);
      }
    } //for
  }
  //Enable banner
  var fIFrame = ((window.frames.length != 0) && (window.frames(0).name != "XdkPopupIFrameName"));
  var oBody   = document.body;
  var oBanner = oBody.firstChild;
  if (oBanner.id == "XdkBanner") {
    var oScroll = oBanner.nextSibling;
    oBody.style.overflow = "hidden";
    oBanner.style.overflow = "hidden";
    oScroll.style.overflow = "visible";
    oScroll.style.overflowX = "auto";
    oScroll.style.overflowY = "scroll";
    if (fIFrame) {
      oScroll.style.padding    = "0px";
      oScroll.style.overflowY  = "auto";
    }
    _XdkOnResizeBody();
  }
} //XdkOnAfterPrint

//-------------- end of Xdk.js --------------------------
