
// build and show a pop-up window for help text
//
// tested and works with:
//   Konqueror v3.0.1/linux
//   mozilla v1.1a/linux, v0.9.6/Win2K
//   MSIE v5.00/Win2K
//   netscape v4.77/linux
//   Opera v6.01/linux
//
// JT 20020704 EBI.

// where we'll store help text strings
var helpTexts = new Array();

// the help window itself
var helpWindow;

// attributes for the pop-up help window
var windowAttributes = "width=300,height=300,toolbar=0,menubar=0,scrollbars=1,resizeable=0,status=0,copyhistory=0,personalbar=0";

// functions

// add a bit of help text
// arguments: id    - a unique id for this help item
//            title - a short title for the item
//            text  - the actual help text. Can contain HTML tags if required
function addHelpText( id, title, text ) {
  var string = "<h2>" + title + "</h2>";
  string += "<p>" + text + "</p>";
	
//  string += "<div style=\"position: absolute; right: 10px; vertical-align: bottom\"><a href=\"http://burke.ebi.ac.uk:4694/help.html#" + id + "\">more detail</a>\&nbsp;::\&nbsp;<a href=\"javascript:window.close()\">close</a></div>";
  string += "<div style=\"position: absolute; right: 10px; vertical-align: bottom\"><font color=\"grey\">more detail</font>\&nbsp;::\&nbsp;<a href=\"javascript:window.close()\">close</a></div>";
  helpTexts[id] = string; 
}

// display a help item
// arguments: id - the unique id of the item to display
function showHelp( id ) {

  if( helpWindow == null || helpWindow.closed ) {
    helpWindow = window.open( "", id, windowAttributes );
  } 

  // don't write the same thing twice...
  if( id == helpWindow.id ) return;

  // new bit of text. Write it to the help window
  helpWindow.document.open( "text/html" );
  helpWindow.document.write( helpTexts[id] );
  helpWindow.id = id;

  // this is probably paranoia, but Opera seems to need it...
  helpWindow.document.close();
}

//------------------------------------------------------------------------------

// simple alert box, returning false so that forms won't get submitted
function error( msg ) {
  alert( msg );
  return false;
}

