/* DESIGN:

The document will load an invisible gif file named 0cchm0.gif (containing
1 white pixel), so the document must contain:

	<img src="0cchm0.gif">

and in its header must contain

	<script src="cc_wlog.js"></script>

Depending on the Chime plugin status of the browser,
exactly one of the following files will be loaded by log_cchime()
which is called with
	<body onLoad="log_cchime()">

The significance of each file is indicated after its name below. These
gif files differ only in name; all contain the same invisible
single white pixel.

The standard web log file will then indicate Chime plugin status
of each visitor's browser accessing the document which invokes
log_cchime().

The following files must be in the local folder on the server:
	cc_wlog.js (this file)
  0cchm0.gif (loaded initially, to be ignored in web log)
  __cchm_.gif (see # below)
  0_cchm_.gif (No Chime installed)
  i_cchm_.gif (Chime 0.9 for SGI IRIX installed)
  1_cchm_.gif (Chime 1 installed)
  2_cchm_.gif (Chime 2 installed)

Assumptions (true at the time of this writing, March 1999):
-The only version of Chime available for SGI IRIX is 0.9.
-Both versions 1 and 2 of Chime have "Chemscape Chime" in the navigator.plugins
string.
-All versions of Chime 2 (beta's 1 through 4 and full release) contain
the string "2." in the navigator.plugins string.

# Since all Chime plugin names contain the string "chemscape chime",
this condition should never occur, unless a plugin which is not Chemscape
Chime happens to include "chime" in its name.

*/


//- - - - - - - - - - - - - - - - - - - - - - - - - - - 
function log_cchime()
{
	var anycc = NP_chime_match();
//	alert(anycc);
	var result = "";

	// initial gif is 0cchm0.gif

	if (anycc.length == 0) // NO CHIME
		result = "../shared/0_cchm_.gif";

	else if (anycc.indexOf("libchimeplugin") != -1)
		result = "../shared/i_cchm_.gif"; // SGI IRIX
	else if (anycc.indexOf("chemscape") == -1)
		result = "../shared/__cchm_.gif"; // CHIME W/O CHEMSCAPE 'IMPOSSIBLE'

	// plugin has both 'chime' and 'chemscape'

	else if (anycc.indexOf("2.") != -1)
		result = "../shared/2_cchm_.gif"; // CHIME 2

	else result = "../shared/1_cchm_.gif"; // CHIME 1

//	alert(result);
// Here is the file fetch which records the Chime version in the weblog:
	document.cchimelog.src = result;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - 
function NP_chime_match()
{
	var nplen = navigator.plugins.length;
	var piname = "";
	var i;

	for (i = 0; i < nplen; i++)
	{
		piname = navigator.plugins[i].name.toLowerCase();
	
		if (piname.indexOf("chime") != -1)
			return piname; // return plugins name string containing "chime".
	}
	// Condition below (return "") would occur if Chime is not installed
	// or if navigator.plugins.length is 0.
	return ("");
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - 
//- - - - - - - - - - - - - - - - - - - - - - - - - - - 
