oldSearchItem = "initialised" //global variable for highlight function (not sure when or if these get set)
srchItem = "initialised"  //global variable for highlight function

function HighLightSpan()
     {
       if (typeof(lastSrchItem)== "undefined")
          {
           lastSrchItem=" "
          }

      srchItem = document.location.href.split('#')[1];

      if (srchItem) //evaluates to false if undefined
        {
          if (srchItem != lastSrchItem)
            {
             lastSrchItem = srchItem
             document.all(srchItem).style.backgroundColor="#F05252"
             theString = "fadeOut(\'" + srchItem + "\'," + 0 + ")"
             setTimeout (theString,200)
            }
          else
            {
             setTimeout("HighLightSpan()",200) //keep checking for changed url
            }
        }
      else
        {
         setTimeout("HighLightSpan()",200) //keep checking for changed url
        }

     }

function fadeOut(srchItem,reps)
     {
      reps=reps+1
      if (reps == 1)
         document.all(srchItem).style.backgroundColor="#F48E8E"
      if (reps == 2)
         document.all(srchItem).style.backgroundColor="#FDCDCD"
      if (reps == 3)
         document.all(srchItem).style.backgroundColor="#FFEBEB"
      if (reps == 4)
         document.all(srchItem).style.backgroundColor="White"
      if (reps<4)
        {
         theString = "fadeOut(\'" + srchItem + "\'," + reps + ")"
         setTimeout (theString,200)
        }
      else
        {
         setTimeout("HighLightSpan()",200)
        }
     }
      
function TestMe()
    {
     alert ("hello")
    }

function showTerm(sourceFrame,frmHght,frmWidth)
 {
      while (document.all.tags("IFrame").length > 0) //this is needed in case delIframe left frame intact
        document.all.tags("IFrame")[0].removeNode(true)
      window.event.cancelBubble = true
      document.body.onclick = delAllchildIframes
      source = window.event.srcElement
      
      if (frmWidth > document.body.clientWidth)
        frmWidth = document.body.clientWidth * 0.9

      if (frmHght > document.body.clientHeight)
        frmHght = document.body.clientHeight * 0.9

      runningOffset = source.offsetTop
      runningLeftOffset = source.offsetLeft

      //need to allow for source element being in a parent offseter eg table

       while (source.offsetParent)
        {
         source=source.offsetParent
         runningOffset = runningOffset + source.offsetTop
         runningLeftOffset = runningLeftOffset + source.offsetLeft
        }

      fromTopofWin = runningOffset - document.body.scrollTop
      sticksBelow = fromTopofWin + frmHght - document.body.clientHeight
      sticksBelow = 0.5*(sticksBelow + Math.abs(sticksBelow))
      if (sticksBelow > 0)
        sticksBelow = sticksBelow + 3
      fromLeftinWin = runningLeftOffset - document.body.scrollLeft
      sticksLeft = fromLeftinWin + frmWidth - document.body.clientWidth
      sticksLeft = 0.5*(sticksLeft + Math.abs(sticksLeft))
      if (sticksLeft > 0)
        sticksLeft = sticksLeft + 3
      newFrame = document.createElement("iFrame")
      newFrame.style.position = "absolute"
      newFrame.style.top = fromTopofWin + document.body.scrollTop - sticksBelow
      absLeft = fromLeftinWin - sticksLeft
      if (absLeft < 0)
         absLeft = 3
      newFrame.style.left = absLeft
      newFrame.height = frmHght
      newFrame.width = frmWidth
      frameID=sourceFrame //start to create ID for frame
      if (frameID.split("/")[0] != frameID)
        {

         //coping with relative paths
         frameID=frameID.split("/")[frameID.split("/").length-1]
        }
      frameID = frameID.split(".")[0] //strips off ".htm" extension
      newFrame.id = frameID
      newFrame.scrolling = 'auto'
      newFrame.style.filter = "progid:DXImageTransform.Microsoft.DropShadow(enabled, Color='gray')"
      document.body.appendChild(newFrame)
      polIframeTerm(frameID,sourceFrame)
 }


function polIframeTerm(frameID,sourceFrame)
  {
   if ((document.all[frameID] != null) && (document.all[frameID].readyState == "complete"))
     {
      carryOnTerm(frameID,sourceFrame)
     }

   else
    {
     theString = "polIframeTerm(\'" + frameID + "\',\'" + sourceFrame + "\')"
     setTimeout (theString,100)
    }
  }

function carryOnTerm(frameID,sourceFrame)
  {
   document.all[frameID].src = sourceFrame
   setOnclick (frameID)
  }

function setOnclick(frameID, sourceFrame) //this is indirect for timing reasons
  {
   if ((document.all[frameID] != null) && (document.all[frameID].readyState == "complete"))
     {
      //start making new script element for doc in iFrame
      //cant get innerText to work for new script element this is alternative
      document.all(frameID).contentWindow.document.body.style.backgroundColor = "whitesmoke"

      newEl = document.all(frameID).contentWindow.document.createElement("SCRIPT")
      newEl.src = "delIframe.js"
      newEl.type ="text/Jscript"
      newEl.event = "onclick" //making onclick script for body
      newEl.htmlFor = frameID //body also given same id as iframe
      document.all(frameID).contentWindow.document.getElementsByTagName("head")[0].appendChild(newEl)
      document.all(frameID).contentWindow.document.body.id=frameID
     }
   else
    {
     theString = "setOnclick(\'" + frameID + "\',\'" + sourceFrame + "\')"
     setTimeout (theString,100)
    }
  }

function dispHelp(helpDef)
    {
     //this script gets round needing to specify absolute paths in windows showhelp method
     //the topic is calling a topic in another chm in same folder
     //script derives folder path from href property of current topic
     //helpDef is help filename and topic in it to show 
    theLoc = window.location.href //tip - needs href to be a string
//    alert (theLoc)
    if ((theLoc.indexOf('@MSITStore') == -1) && (theLoc.indexOf('ms-its') == -1))
      {
          re = new RegExp("///") //for if the file in a network drive
          theLoc = theLoc.replace(re,'//')
          theLoc = theLoc.split('file://')[1] //leave bit after specified string
          theLoc = theLoc.substr(0, theLoc.lastIndexOf('/') +1) //strip of the htm file name to leave the path
          theLoc = 'mk:@MSITStore:' + theLoc + helpDef
//          alert (theLoc)
          window.showHelp(theLoc)
      }
     else  //compiled help
       {
        if (theLoc.indexOf('@MSITStore') != -1) //if string present
         {
          theLoc = theLoc.split('@MSITStore:')[1] //leave bit after specified string
          re = /\\/g
          theLoc = theLoc.replace(re,'/') //replace slashes sloping wrong way
          theLoc = theLoc.substr(0, theLoc.lastIndexOf('::')) //strip of path within the chm
          theLoc = theLoc.substr(0, theLoc.lastIndexOf('/')) //stip of the chm file name to leave the path
          theLoc = 'mk:@MSITStore:' + theLoc + '/' + helpDef
//          alert (theLoc)
          window.showHelp(theLoc)
         }
        else
         {
          theLoc = theLoc.split('ms-its')[1] //leave bit after specified string
          re = /\\/g
          theLoc = theLoc.replace(re,'/') //replace slashes sloping wrong way
          theLoc = theLoc.substr(0, theLoc.lastIndexOf('::')) //strip of path within the chm
          theLoc = theLoc.substr(0, theLoc.lastIndexOf('/')) //stip of the chm file name to leave the path
          theLoc = 'mk:@MSITStore:' + theLoc + '/' + helpDef
//          alert (theLoc)
          window.showHelp(theLoc)
         }
       }
         
    }



function delAllchildIframes()
  {
//   alert ("deleting children")
   window.event.cancelBubble = true
   while (window.document.all.tags("Iframe").length > 0)
     window.document.all.tags("Iframe")[0].removeNode(true)
  }

