/* Overlap Animation Applet
                  Coded By.KeN    Dec.14,1995
*/

import java.applet.AudioClip; 
import java.awt.*;
import java.lang.Integer;
import java.net.*;

public class LinkFlush extends java.applet.Applet {
  
  int r, g, b;
  int fr, fg, fb;
  Image src;
  boolean flag = false;
  String filename;
  URL anchor;
  Graphics goff;
  Image ioff;

  public void init() {

    String s = null;

    s = getParameter("r") ;
    r =  ( s != null ) ? Integer.valueOf(s).intValue() : 255;
    s = getParameter("g");
    g =  ( s != null ) ? Integer.valueOf(s).intValue() : 255;
    s = getParameter("b");
    b =  ( s != null ) ? Integer.valueOf(s).intValue() : 255;
    s = getParameter("fr") ;
    fr =  ( s != null ) ? Integer.valueOf(s).intValue() : 255;
    s = getParameter("fg");
    fg =  ( s != null ) ? Integer.valueOf(s).intValue() : 255;
    s = getParameter("fb");
    fb =  ( s != null ) ? Integer.valueOf(s).intValue() : 255;

    s = getParameter("href");
    try {
      anchor = new URL( getDocumentBase(),s );
    } catch ( MalformedURLException e ) {
      anchor = null;
    }
    
    filename = getParameter("src");
    ioff = createImage( size().width, size().height );
    goff = ioff.getGraphics();
  }

  public void paint( Graphics scr ) {
    if ( flag == true ) {
      goff.setColor( new Color ( fr, fg, fb ) );
    } else {
      goff.setColor( new Color ( r, g, b ) );
    }
    src = getImage( getDocumentBase(), filename );
    goff.fillRect( 0, 0, size().width, size().height );
    goff.drawImage( src, 0, 0, this );
    scr.drawImage( ioff, 0, 0, this );
  }

  public boolean mouseDown(Event e,int x,int y) {
    if ( anchor != null ) {
      this.getAppletContext().showDocument( anchor, "_top" );
    }
    return( true );
  }

  public boolean mouseEnter( Event e, int x, int y ) {
    flag = true;
    repaint();
    showStatus( (anchor != null)
                   ? "" + anchor.toExternalForm()
                   : null );
    return( true );
  }
  public boolean mouseExit( Event e, int x, int y ) {
    flag = false;
    repaint();
    return( true );
  }

  public void update( Graphics scr ) {
    paint( scr );
  }
}

