/* dIntProg Browser. A webbrowser written in Java.
 * Copyright (C) 2001 Martin Geisler <gimpster@gimpster.com>
 *  
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * 
 * Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

import java.net.*;

/** A browser. This class creates a {@link BrowserController} which
 *  runs the show from that point on. */
public class Browser {
  
    /** Flag to determine if debugging is turned on. */
    public static boolean debugging = false;
    /** Flag to determine if antialiasing is turned on. */
    public static boolean antialias = true;
    
    /** Prints messages on <code>System.err</code> if debugging is
     *  enabled.
     *  @param s the string to print. */
    public static void debug(String s) {
        if (debugging) {
            System.err.println(s);
        }
    }

    /** The main method. It sets the flags and creates a {@link
     *  BrowserController}.
     *  @param args commandline arguments. An argument of '-d' will
     *  turn on debugging, and '-a' turns off antialiasing. */
    public static void main(String[] args) {
        String url_str = null;
        for (int i = 0; i < args.length; i = i + 1) {
            if (args[i].equals("-d")) {
                debugging = !debugging;
            } else if (args[i].equals("-a")) {
                antialias = !antialias;
            } else {
                url_str = args[i];
            }
        }
        
	URL url = null;
        try {
            if (url_str != null) {
                url = new URL(url_str);
            } else {
                url = new URL("http://www.gimpster.com/" +
                              "linux/dIntProg-Browser/index.php");
            }
        } catch (MalformedURLException e) {
            Browser.debug("Strange - we got a MalformedURLException...");
            System.exit(1);
        }
	new BrowserController(url);
    }

}