// launch-applet.js - launch an applet in the current browser
// Copyright 2005, Martin Rinehart

	/* load this library in your ?.html:
	<script type="text/javascript" src="launchApplet.js">
	</script>
	*/

	/* with this loaded, launch an applet one of these ways:
	<script type = "text/javascript">
	<!--
		a( "myApplet" );
	or
		app( "myApplet", 300, 200 );
	or
		appl( "myApplet", "code/base/", 300, 200 );
	or
		applet("myApplet","code/base/","my.jar",300,200);
	//>	
	</script>	
	*/
	
	function a( name ) 
	{ app( name, 300, 200 ); }
	
	function app( name, width, height )
	{ appl( name, ".", width, height ); }
	
	function appl( name, codebase, width, height )
	{ applet( name, codebase, "", width, height ); }

	function applet
		( name, codebase, archive, width, height ) {
        
		if ( navigator.appName.indexOf("Microsoft") > -1 ||
			navigator.userAgent.indexOf("MSIE") > -1 )
			windows
				( name, codebase, archive, width, height );

		else if ( navigator.appVersion.indexOf
			("Macintosh" ) > -1 )
			macintosh
				( name, codebase, archive, width, height );

		else mozilla
			( name, codebase, archive, width, height );
	
	} // end of applet
	
	function macintosh
		( name , codebase, archive, width, height ) {
	
		document.write(
			'<APPLET ' +
			'CODE="' + name + '" ' +
			'CODEBASE="' + codebase + '" ' +
			'ARCHIVE="' + archive + '" ' +
			'WIDTH=' + width + ' ' +
			'HEIGHT=' + height + '>' +
			'Your Macintosh browser is not ' +
				'applet-enabled.' +
			'</APPLET>'
		);
		
	} // end of macintosh()
	
	function mozilla
		( name, codebase, archive, width, height ) {
	
		type = "application/x-java-applet;version=1.4"
		page = "http://java.sun.com/products/plugin/" + 
			"index.html#download"
			
		document.write(
			'<EMBED ' +
			'TYPE="' + type + '" ' +
			'PLUGINSPAGE = "' + page + '" ' +
			'CODE="' + name + '" ' +
			'CODEBASE="' + codebase + '" ' +
			'ARCHIVE="' + archive + '" ' +
			'WIDTH=' + width + ' ' +
			'HEIGHT=' + height + ' ' +
			'SCRIPTABLE=false ' + '>'
		);
		document.write(
			'<NOEMBED>Your Mozilla-class browser is not ' + 
				'applet-enabled.</NOEMBED>' );
		document.write( '</EMBED>' );
			
	} // end of mozilla()
	
	function windows
		( name, codebase, archive, width, height ) {
	
		id = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
		cab = "http://java.sun.com/products/plugin/" + 
			"autodl/jinstall-1_4-windows-i586.cab#" + 
			"Version=1,4,0,0"
		type = "application/x-java-applet;jpi-version=1.4"
			
		document.write(
			'<OBJECT ' +
			'CLASSID="' + id + '" ' +
			'CODEBASE="' + cab + '" ' +
			'WIDTH=' + width + ' ' +
			'HEIGHT=' + height + ' >' 
		);
		document.write(	'<PARAM NAME = CODE ' + 
				'VALUE = "' + name + '" >' );
		document.write(	'<PARAM NAME = CODEBASE ' + 
				'VALUE = "' + codebase + '" >' );
		document.write( '<PARAM NAME = ARCHIVE ' +
			'VALUE = "' + archive + '" >' );
		document.write(	'<PARAM NAME = TYPE ' + 
				'VALUE = "' + type + '" >' );
		document.write( '</OBJECT>' );
		
	} // end of windows()
	
// end of launch-applet.js