// Lightning strikes around the cursor
// LANGUAGE="JavaScript1.3"


if (1) //if (document.images)
{
  var isNetscape = navigator.appName=="Netscape";

  imageMax = 2;
  imageNum = 0;
  var CursorLightningTimerID = null;
  var Xpos = 50;
  var Ypos = 50;

  function AnimEnt(File)
  {
    this.File = File;
    this.Image = new Image();
  }

  theAnim = new Array(imageMax+1);
  theAnim[0] = new AnimEnt("../common/jcl_Stroke1.gif");
  theAnim[1] = new AnimEnt("../common/jcl_Stroke2.gif");
  theAnim[2] = new AnimEnt("../common/jcl_Stroke3.gif");
  // Preload animation images
  for(i=0; i<=imageMax; i++)
  {
    theAnim[i].Image.src = theAnim[i].File;
  }

  // just save mouse position for animation to use
  function MoveHandler(e)
  {
    Xpos = e.pageX;
    Ypos = e.pageY;	  
    return true;
  }

  // just save mouse position for animation to use
  function MoveHandlerIE()
  {
    Xpos = window.event.x + document.body.scrollLeft;
    Ypos = window.event.y + document.body.scrollTop;
  }

  if (isNetscape)
  {
    document.captureEvents(Event.MOUSEMOVE);
    document.onMouseMove = MoveHandler;
  }
  else
  {
    document.onmousemove = MoveHandlerIE;
  }

  function TimerCursorLightning()
  {
    // TrackCursorWithImage()
    if (isNetscape)
    {
      document.LayerCursor.top = Ypos - 83;
      document.LayerCursor.left = Xpos +5;
    }
    else
    {
      LayerCursor.style.top = Ypos - 83;
      LayerCursor.style.left = Xpos +5;
    }

    // SwapCursor
    imageNum = (Math.round((Math.random() * imageMax)));
    if (isNetscape)
    {
      document.LayerCursor.document.images["ImgStroke"].src = theAnim[imageNum].File;
    }
    else
    {
      document.images["ImgStroke"].src = theAnim[imageNum].File;
    }

    CursorLightningTimerID = setTimeout("TimerCursorLightning()", (5000 + Math.random() * 5000)); // run again in 5-10 seconds
  } // TimerCursorLightning()

  function StartCursorLightning()
  {
    // Add the DIV tag to make the cursor layer.
    LightningInvocation = "";
    // Netscape 4.7 refuses to dynamically reposition the first DIV tag, so we provide a hidden sacrifical DIV tag.
    LightningInvocation = LightningInvocation + '<div id="junk_jlc" style="position: absolute; visibility: hidden; height: 1; width: 1;"></div>';
    LightningInvocation = LightningInvocation + '<div id="LayerCursor" style="position: absolute; height: 179; width: 166; "><IMG id="ImgStroke" NAME="ImgStroke" LOWSRC="../common/invisible.gif" SRC="../common/jlc_Stroke1.gif" WIDTH=166 LENGTH=179 ALIGN=left></div>';
    document.write(LightningInvocation);

    // Start it up...
    TimerCursorLightning();
  } // StartCursorLightning()

} // if (document.images)

