// Decide whether to EMBED JSyn Plugin for Navigator.
// Author: Phil Burk 1999
// Modifications:
//   4/6/01 - PLB added sniffer for iCab and check for Java enabled	
// Is it a type of Netscape browser?
var app = navigator.appName.toLowerCase();
var is_netscape = (app.indexOf("netscape") != -1 );
// Is it iCab for Macintosh masquerading as a Netscape browser?
var agt = navigator.userAgent.toLowerCase();
var is_icab = (agt.indexOf("icab") != -1);
if( !navigator.javaEnabled() ) {
	document.writeln("<P><B>Java is NOT enabled for your browser.");
	document.writeln("Cannot run JSyn without Java!</B><P>");
}
else if( is_netscape && !is_icab ){
// If we are running an actual Netscape browser then we should use the Netscape Plugin.
// Has the plugin been installed?
// Check for name that we used on both Mac and PC.
	var jsynPcPlugin = navigator.plugins["SoftSynth JSyn"];
	var jsynMacPlugin = navigator.plugins["npJSyn"];
	if( (jsynMacPlugin == undefined) && (jsynPcPlugin == undefined))	{
		document.writeln("<p><b>ERROR:</b> The JSyn plugin could not be found!");
		document.writeln("You can download the free JSyn plugin from ");
		document.writeln('<A HREF="http://www.softsynth.com/jsyn/plugins">here</A>.<P>');
	}
	else	{
	// check property on global navigator object to see if plugin window already open
	// If open, don't open it again because Netscape may hang if
	// the garbage collector is running, or if threads call the plugin
	// while we are EMBEDding plugin.
		jsynPluginWindow = navigator.jsynPluginWindow;
		if (jsynPluginWindow)		{
			document.writeln("Using already open JSyn Plugin Window.<P>");
		}
		else
		{	// not open so we had better open it now
			navigator.jsynPluginWindow = window.open("embed_jsyn_plugin.html",
				"SharedJSynWindow",
				"toolbar=no,resizable=yes,scrollbars=yes,height=240,width=520");
			document.writeln("Opened Plugin Window for JSyn.<P>");
		}
	}
}
else
{
// For Internet Explorer or iCab, don't try to EMBED the Netscape Plugin for IE because IE may crash.
	document.writeln("This non-Netscape browser requires JSyn to run this Applet. ");
	document.writeln("If the Applet does not load correctly, then download JSyn from ");
	document.writeln('<A HREF="http://www.softsynth.com/jsyn/plugins">here</A>.<P>');
}
