//J.G. im Mai 1997 

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.*;
import java.util.*;

public class Bild91 extends Applet implements Runnable {

	protected Thread animThread=null;	
	Image bild1;
	Image bild2;
	Image bild;
	Image bild12;	
	Graphics hintergrund;
	Rectangle r;
	int delay;
	MediaTracker tracker;	
	public String wString;
	
	//--------------------------
	public void start() {
	if (animThread==null) {animThread=new Thread(this);
	animThread.start();}	
	}
	
	//--------------------------
	public void stop() {
	if ((animThread!=null) && (animThread.isAlive()))
	animThread.stop();
	animThread=null;
	}	

	//--------------------------
	public void init() {
	bild1 = this.getImage(this.getDocumentBase(),this.getParameter("Bild1"));
	bild2 = this.getImage(this.getDocumentBase(),this.getParameter("Bild2"));
	bild12 = this.getImage(this.getDocumentBase(),this.getParameter("Bild12"));
	r = this.bounds();
	bild = createImage(r.width,r.height);
	hintergrund = bild.getGraphics();
	
	resize( size().width, size().height );
	tracker = new MediaTracker(this);
	tracker.addImage(bild1,0);
	tracker.addImage(bild2,0);
	try {tracker.waitForID(0);} catch(Exception e) { };
	try {tracker.waitForID(1);} catch(Exception e) { };
	//delay = Integer.parseInt(getParameter("delay"));
	wString = "5000";		
	}
	
	//------------------------------------
	public synchronized void update(Graphics g) {	
	g.clipRect(80,20,180,40);
	g.drawImage(bild,0,0,this);
	}	

	//--------------------------
	public void paint (Graphics hintergrund) {
	hintergrund.drawImage(bild,0,0,this);
	}

	//--------------------------
	public void run() {	
	
	delay = Integer.parseInt(wString);	
	delay = delay/7;	
	
	while (true){
	
		try {
							
		hintergrund.drawImage(bild1,0,0,this);		
		repaint();
		
		Thread.sleep(delay);
		
		hintergrund.drawImage(bild2,0,0,this);				
		repaint();
		
		Thread.sleep(delay);
	
		}
		catch (Exception e) { }
	}	
	
	}

}	
