///////////////////
// GLOBAL VARIABLES

var	G_HapDetection		=	new Object();		// contains 'browser', 'platform', and respective *_okay
	G_HapDetection.browser_okay	=	false;
	G_HapDetection.platform_okay	=	false;
	G_HapDetection.browser		=	"unknown";
var	G_HapPluginData		=	new Object();		// contains 'plugin', 'plugin_version', 'language', and respective *_okay
	G_HapPluginData.Filename	=	"NPHapPlugIn.dll";
	G_HapPluginData.AXCTRL		=	"ACTIVEHAPTEKX.ActiveHaptekXCtrl.1";
	G_HapPluginData.CLSID		=	"CLSID:C6DC0AE5-A7BE-11D2-BDF1-0090271F4931";
	G_HapPluginData.mimetype	=	"fake/mime-type";
	G_HapPluginData.plugin_okay	=	false;
	G_HapPluginData.language	=	"us";
var	G_HapErrorHandlerOrig		=	null;

function sdErrorHandler1(msg, url, line)
{
	if (msg	== "Automation server can't create object")
	{
		document.write("<script>if(G_HapDetection.browser=='ie')window.onerror=G_HapErrorHandlerOrig;<\/script>");
		return true;
	}
	else
		return false;
}

function	sdJustFileBS(s)
{
	delimit	= "\\";
	sa	= s.split(delimit);
	if (sa.length > 0)
		rtn	= sa[sa.length - 1];
	else
		rtn	= s;
	return rtn;
}

// *** *** *** CODE BELOW EXTRACTED IS FROM NETSCAPE COMMUNICATIONS *** *** ***
// *** Much is clipped, to reduce code size. So bugs may not be theirs. ***
// Ultimate client-side JavaScript client sniff. 
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute. 
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below). 

    var agt=navigator.userAgent.toLowerCase(); 
    var is_major = parseInt(navigator.appVersion); 
    var is_minor = parseFloat(navigator.appVersion); 

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
                && (agt.indexOf('webtv')==-1)); 
    var is_nav4 = (is_nav && (is_major == 4)); 
    var is_navVFREADY = (is_nav && (is_minor >= 4.03)); 
 

    var is_ie   = (agt.indexOf("msie") != -1); 
    var is_ie3  = (is_ie && (is_major < 4)); 
    var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
    var is_ie4up  = (is_ie  && (is_major >= 4)); 

    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));


// *** *** *** END EXTRACTED CODE FROM NETSCAPE COMMUNICATIONS *** *** ***



//////////////////////////
//BEGIN ENVIRONMENT DETECT

if(is_navVFREADY)
{
	G_HapDetection.browser		=	"nav";
	G_HapDetection.browser_okay	=	true;
}
else if(is_ie4up)
{
	G_HapDetection.browser		=	"ie";
	G_HapDetection.browser_okay	=	true;
}


if(is_win32)
{
	G_HapDetection.platform_okay	=	true;
}



///////////////////
// PLUGIN DETECTION
if(G_HapDetection.platform_okay && G_HapDetection.browser_okay)
{


	if(G_HapDetection.browser	==	"nav")
	{
		navigator.plugins.refresh();

		G_HapPluginData.plugin	=	"";
		for(i=0; i<navigator.plugins.length; i++)
		{
			if(sdJustFileBS(navigator.plugins[i].filename) == G_HapPluginData.Filename)
			{
				G_HapPluginData.plugin	= 	sdJustFileBS(navigator.plugins[i].filename);
				G_HapPluginData.plugin_okay	=	true;
			}
		}

	}

	if(G_HapDetection.browser	==	"ie")
	{
		G_HapErrorHandlerOrig	=	window.onerror;
		window.onerror		=	sdErrorHandler1;

		var MyObject		=	new ActiveXObject(G_HapPluginData.AXCTRL);

		if (MyObject)
		{
			G_HapPluginData.plugin	=	G_HapPluginData.AXCTRL;
			G_HapPluginData.plugin_okay	=	true;
			delete MyObject;
		}
	}
}

