import java.applet.*;
import java.awt.*;
import java.net.*;

public class RMail extends Applet  
{
 int textcolor, textcolor2, bgcolor;
 int fontsize, fontstyle;
 String fontname, text, mail;
 Font font;
 int X, Y;
 Graphics g;
  
public void init()
  {
   text = getParameter("text");
   mail = getParameter("mailto");
   bgcolor = Integer.parseInt(getParameter("bgcolor"));
   textcolor = Integer.parseInt(getParameter("textcolor"));
   textcolor2 = Integer.parseInt(getParameter("textcolor2"));
   fontsize = Integer.parseInt(getParameter("size"));
   fontstyle = Integer.parseInt(getParameter("style"));
   fontname = getParameter("fontname");
   font = new Font(fontname, fontstyle,fontsize);
   
   X = (size().width - getFontMetrics(font).stringWidth(text))/2;
   Y = (int)(size().height/1.5);
   
   g = getGraphics();
   setBackground(new Color(bgcolor));
   
 
  }
public boolean mouseMove(Event e, int x, int y)
  {
     g.setColor(new Color(textcolor));
     g.setFont(font); 
     g.drawString(text, X, Y); //Huom. X ja Y isoja merkkejä
     showStatus(text);
     return true;
  }

public boolean mouseExit(Event e, int x, int y)
  {
   g.setColor(new Color(textcolor2));
   showStatus("");
   update(g);
   return true;
  }

public boolean mouseDown(Event e, int x, int y)
  {
 try {
	
 URL url = new URL(getDocumentBase(), "mailto:"+ mail);
 getAppletContext().showDocument(url);
     }
 catch (Exception ex) {}
 return true;
 }

public void paint(Graphics g)
  {
   g.setFont(font);
   g.setColor(new Color(textcolor));
   g.drawString(text, X, Y);
   g.setColor(new Color(textcolor2));
   g.drawString(text, X, Y+2);
  }
}
