/*

The functions defined below implement text that changes when the user
mouses over an HTML element. It's a replacement for Erik Bosrup's overlib
(http://www.bosrup.com/web/overlib/), which has been giving us trouble
under IE 6. To use it, use the event handlers onmouseout and onmouseover,
e.g.
  <p>
  Touch the link to show the status.
  <a href="foo"
     onmouseover="return overlib( 'Build your own Tax and Benefit System' );"               
     onmouseout="return nd();"
  >Foo</a>.
  </p>
or
  <p>
  Touch the button to show the status.
  <input type=submit value="Foo"
         onmouseover="return overlib( 'Go home to dinner' );"          
         onmouseout="return nd();"
  >
  </p>

They alter text in a div with id 'over_div'.

The function overlib is synonymous with 
displayHelpText, and nd with clearHelpText.

Note that this library needs a bit of a prelude to work
properly. That is output by the code that includes the
library in DisplayFunctions.php, since it uses a bit
of HTML and two versions of JavaScript, which we can't
include here.
*/


/*
This code supresses syntax errors caused by browsers that don't recognise
any JavaScript 1.2 constructions we may be using. See page 394 of David
Flanagan, "JavaScript - The Definitive Guide" (O'Reilly). It also enables
us to test for JavaScript 1.2 without actually requestingit in the script
tag, since doing so apparently provokes bugs in Netscape.
*/

function supressErrors() 
{
  return true;
}

if ( !has_js12 ) {
  window.onerror = supressErrors;
}


/* If this returns true, we should be able to
   call the JavaScript without any errors, even
   if it doesn't always execute. Since it's
   only being used to enhance appearence,
   that shouldn't matter.
   The function uses a div with id 'test' 
   which must be included above the library to test that
   referring to an element by ID works.
*/
function OKForJavaSscript()
{
  return document.getElementById &&
         document.getElementById("test");
  return true;
}


/* Displays the help text in the div named "over_div" in
   the Darts history panel. To be called when the
   mouse moves onto an HTML element (e.g. part of the
   Darts navigation bar) for which such text is needed.
   This is done via the onmouseover event.
*/
function displayHelpText( text )
{
  if ( !OKForJavaSscript() ) {
    return;
  }

  setHelpText( text );

  return false;
}


/* Clears the help text. To be called when the mouse 
   moves off the appropriate element, via the onmouseout 
   event.
*/
function clearHelpText()
{
  if ( !OKForJavaSscript() ) {
    return;
  }

  setHelpText( "" );

  return false;
}


/* Alias for displayHelpText. This is because we were 
   originally generating our Web pages to call Erik Bosrup's 
   overlib (http://www.bosrup.com/web/overlib/), and we want to 
   keep to the same function names when calling the event 
   handlers.
*/
function overlib( text )
{
  displayHelpText( text );
}


/* Alias for clearHelpText. Once again, this is for
   compatibility with overlib.
*/
function nd()
{
  clearHelpText();
}


/* Places the text into the div. Called by the two 
   functions above.
*/
function setHelpText( text )
{
  var text_space = document.getElementById( "over_div" );
  text_space.lastChild.nodeValue = text;
}
