/*
***********************************************************************************************
   Associate an event handler to specific element and events
***********************************************************************************************
*/
window.onerror = handleScriptError;

/*
NB: The statements above will execute first, because all other statements are contained
within a function.
*/

/*
NB: The error handling function must be the first on this page, because at page load time the
script engine parses the script block in top-to-bottom order.
***********************************************************************************************
   Name: handleScriptError()
   Parameters: Text-based error description, URL which exhibited the script error, the line
               number being executed when the error occurred.
   Returns: True
   Purpose: Global error handler to catch both syntax and run-time errors (client-side only).
   Author: If this code works, it was written by Alyda Gilmore
***********************************************************************************************
*/
function handleScriptError(msg, url, line)
{
  var sErr = '';
  var oWindow;
  var sFeatures;

  sErr += '<userAgent>' + window.navigator.userAgent + '</userAgent>';
  sErr += '<description>' + msg + '</description>';
  sErr += '<line>' + line + '</line>';
  sErr += '<pageurl>' + url + '</pageurl>';

  // open a popup window with error details and give user opportunity to submit the message!
  sFeatures = 'status=no, toolbar=no, directories=no, menubar=no, location=no, resizable=no, scrollbars=yes';
  oWindow = open('error.asp?ErrInfo=' + sErr, null, sFeatures);
  oWindow.focus();
  oWindow.resizeTo(480, 410);

  // stop the event from bubbling up to the default window.onerror handler
  return true;
}
