/*
The code is available only to persons
currently affiliated with any of the following,
      o Universities and schools
      o Non-commercial research organizations
      o Registered not-for-profit organizations
      o Registered charities
For these people, the license is of the form of
the GNU Public License version 2.  The restrictions
must remain attached to this and any subsequently derived code.
All other people have no implicit right to use, read, or copy
this software unless granted by Mr. Deck
THIS SOFTWARE IS PROVIDED "AS IS" AND MR. DECK
MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, HE
MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT-
ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE
OF THE LICENSED SOFTWARE AND DOCUMENTATION WILL NOT
INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR
*/

import java.awt.*;
import java.net.*;

public class control extends Frame {
icontext it;
  public control(icontext i){
       super("");
       it = i;
       setLayout(null);
       setBackground(Color.white);
       setFont(env.font);
       pack();
       int hlfWid=100;
       int hlfHt=118;
       int width=hlfWid<<1;
       int height=hlfHt<<1;
       reshape(getToolkit().getScreenSize().width/2-hlfWid,
                getToolkit().getScreenSize().height/2-hlfHt,
                width,height);

       ilogo il = new ilogo(i);
       il.reshape(25,49,151,28);
       add(il);

       asciiBut b = new asciiBut("HELP",i);
       b.reshape(72,80,60,28);
       add(b);

       b = new asciiBut("SITEMAP ",i);
       b.reshape(72,110,60,40);
       add(b);

       b = new asciiBut("OKAY",i);
       b.reshape(72,160,60,28);
       add(b);
       show();
  }

   private void showPage(String url){
      URL u=null;
	try{
	  u = new URL("http://"+env.host+"/icontext/"+url);
	}catch(Exception ee){ee.printStackTrace();}
	it.getAppletContext().showDocument(u);
   }
   public boolean handleEvent(Event e){
        if(e.id==Event.WINDOW_DESTROY) this.dispose();
        else if(e.id==501 && e.target instanceof asciiBut) {
           if(((asciiBut)e.target).getLabel().equals("HELP")){
		showPage("html/help.html");
           }
           else if(((asciiBut)e.target).getLabel().equals("SITEMAP ")){
		showPage("html/sitemap.html#i");
           }
           else this.dispose();
         }
	 else if(e.id==501 && e.target instanceof ilogo){
		showPage("index.html");
	 }
         return true;
   }
}
