//      Client Sniffer Script       //

var maxVersion = 8;				// highest version of Flash we are going to detect. 

// global variables
var flash2Installed = false;	// boolean. true if Flash 2 is installed
var flash3Installed = false;	// boolean. true if Flash 3 is installed
var flash4Installed = false;	// boolean. true if Flash 4 is installed
var flash5Installed = false;	// boolean. true if Flash 5 is installed
var flash6Installed = false;	// boolean. true if Flash 6 is installed
var flash7Installed = false;	// boolean. true if Flash 7 is installed
var flash8Installed = false;	// boolean. true if Flash 8 is installed
var actualVersion = 0;			// version of Flash the user really has

var haveQT = false;				// boolean. true if quicktime is installed


// detects whether or not Quicktime is installed
// does not work in mac ie 4.  returns false in mac ie 4.
function detectQuicktime() {

	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;		// true if we're on ie
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

	if (isIE && isWin) { // don't write vbscript tags on anything but ie win
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');	
		document.write('Set theObject = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1") \n');
		document.write('On Error  goto 0 \n');
		document.write('If IsObject(theObject) Then \n');
		document.write('If theObject.IsQuickTimeAvailable(0) Then  \n');
		document.write('haveQT = true \n');
		document.write('End If \n');
		document.write('End If \n');
		document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
	}
	
	// for ie win return value
	if (isIE && isWin) { 
		if (eval(haveQT))
			return true; 
		return false;
	}
	

	if (navigator.plugins) {
		for (i=0; i<navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.indexOf("QuickTime") >= 0) {
				haveQT = true;
				return true;
			}
		}
	}
	return false;
}


// detects what version of Flash is installed. 
// if no version is found returns 0.	
// does not work in mac ie.  returns 0 in mac ie.
function detectFlash(){	

	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;		// true if we're on ie
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

	if (isIE && isWin) { // don't write vbscript tags on anything but ie win
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');	
		document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');	
		document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
		document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');	
		document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');	
		document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
	}
	
	if (navigator.plugins){								// does navigator.plugins exist?
		if (navigator.plugins["Shockwave Flash 2.0"] 	// yes>> then is Flash 2 
		|| navigator.plugins["Shockwave Flash"]){		// or flash 3+ installed?
	
			// set convenient references to flash 2 and the plugin description
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			// a flash plugin-description looks like this: Shockwave Flash 4.0 r5
			// so we can get the major version by grabbing the character before the period
			// note that we don't bother with minor version detection. do that in your movie with $version
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

			// we know the version, now set appropriate version flags
			flash2Installed = flashVersion == 2;		
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion >= 8;
		}
	}
	
	// loop through all versions we're checking, and set actualVersion to highest detected version
	for (var i = 2; i <= maxVersion; i++) {	
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	// if we're on webtv, the version supported is 2 (pre-summer2000, or 3, post-summer2000)
	// note that we don't bother sniffing varieties of webtv. you could if you were sadistic...
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;	
	
	// uncomment next line to display flash version during testing
	// alert("version detected: " + actualVersion);
	
	return actualVersion;
}


function getClientInfo ()
{

	// user-agent header in the form of: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
	var agent = navigator.userAgent.toLowerCase()
	
	// browser version
	this.major = parseInt(navigator.appVersion);
	// this.minor = parseFloat(navigator.appVersion);

	// browser type
	this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
	this.ns2 = (this.ns && (this.major == 2));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (agent.indexOf("netscape 6") != -1));
	this.ns7 = (this.ns && (agent.indexOf("netscape 7") != -1));

	this.ie   = ((agent.indexOf("msie") != -1) || agent == "");
	this.ie3  = ((this.ie && (this.major == 2)) || agent == "");
	this.ie4  = (this.ie && (this.major == 4));
	this.ie5  = (this.ie && (agent.indexOf("msie 5") != -1));
	this.ie6  = (this.ie && (agent.indexOf("msie 6") != -1));
	this.ie7  = (this.ie && (agent.indexOf("msie 7") != -1));

	// javascript version 
	this.js = (navigator.platform) ? 1.2 : (document.URL) ? 1.1 : 1.0;

	// platform type
	this.win   = ((agent.indexOf("win") != -1) || (agent.indexOf("16bit") != -1));
	this.win16 = ((agent.indexOf("win16") != -1) || (agent.indexOf("16bit") != -1) || (agent.indexOf("windows 3.1") != -1) || (agent.indexOf("windows 16-bit") != -1));
	this.win95 = ((agent.indexOf("win95") != -1) || (agent.indexOf("windows 95") != -1));
	this.win31 = ((agent.indexOf("win16") != -1) || (agent.indexOf("windows 3.1") != -1) ||	(agent.indexOf("windows 16-bit") != -1));
	this.win98 = ((agent.indexOf("win98") != -1) || (agent.indexOf("windows 98") != -1));
	this.winnt = ((agent.indexOf("winnt") != -1) || (agent.indexOf("windows nt") != -1));
	this.win32 = this.win95 || this.winnt || this.win98 || ((this.major >= 4) && (navigator.platform == "Win32")) || (agent.indexOf("win32") !=-1 ) || (agent.indexOf("32bit") != -1);
	this.mac    = (agent.indexOf("mac") != -1);
	this.mac68k = this.mac && ((agent.indexOf("68k") != -1) || (agent.indexOf("68000") != -1));
	this.macppc = this.mac && ((agent.indexOf("ppc")!=-1) || (agent.indexOf("powerpc")!=-1));

	// java (1.1 Browsers Only, all 1.0 browsers will return false);
	this.java = (this.js >= 1.1 && navigator.javaEnabled());

	// flash version
	this.flash = detectFlash();
	// uncomment next line to display flash version during testing
	// alert("version detected: " + this.flash);

	// quicktime
	this.quicktime = detectQuicktime();
}

// create instance of client info object

var ClientInfo = new getClientInfo();

// prints out all properties of ClientInfo
function printProperties () {
	document.writeln('Client Info Object Properties:<BR><BR>');
	// browser version
	document.writeln('Browser Version:<BR>');
	document.writeln('ClientInfo.major : ' + ClientInfo.major + '<BR><BR>');

	// browser type
	document.writeln('Browser Type:<BR>')
	document.writeln('ClientInfo.ns : ' + ClientInfo.ns + '<BR>');
	document.writeln('ClientInfo.ns2 : ' + ClientInfo.ns2 + '<BR>');
	document.writeln('ClientInfo.ns3 : ' + ClientInfo.ns3 + '<BR>');
	document.writeln('ClientInfo.ns4 : ' + ClientInfo.ns4 + '<BR>');
	document.writeln('ClientInfo.ie : ' + ClientInfo.ie + '<BR>');
	document.writeln('ClientInfo.ie3 : ' + ClientInfo.ie3 + '<BR>');
	document.writeln('ClientInfo.ie4 : ' + ClientInfo.ie4 + '<BR>');
	document.writeln('ClientInfo.ie5 : ' + ClientInfo.ie5 + '<BR><BR>');

	
	// javascript version 
	document.writeln('JavaScript Version:<BR>');
	document.writeln('ClientInfo.js : ' + ClientInfo.js + '<BR><BR>');
	
	// platform type
	document.writeln('Platform Type:<BR>');
	document.writeln('ClientInfo.win : ' + ClientInfo.win + '<BR>');
	document.writeln('ClientInfo.win16 : ' + ClientInfo.win16 + '<BR>');
	document.writeln('ClientInfo.win95 : ' + ClientInfo.win95 + '<BR>');
	document.writeln('ClientInfo.win31 : ' + ClientInfo.win31 + '<BR>');
	document.writeln('ClientInfo.win98 : ' + ClientInfo.win98 + '<BR>');
	document.writeln('ClientInfo.winnt : ' + ClientInfo.winnt + '<BR>');
	document.writeln('ClientInfo.win32 : ' + ClientInfo.win32 + '<BR>');
	document.writeln('ClientInfo.mac : ' + ClientInfo.mac + '<BR>');
	document.writeln('ClientInfo.mac68k : ' + ClientInfo.mac68k + '<BR>');
	document.writeln('ClientInfo.macppc : ' + ClientInfo.macppc + '<BR><BR>');

	// java (1.1 Browsers Only, all 1.0 browsers will return false);
	document.writeln('Java Enabled:<BR>');
	document.writeln('ClientInfo.java : ' + ClientInfo.java + '<BR><BR>');

	// flash version
	document.writeln('Flash Version:<BR>');
	document.writeln('ClientInfo.flash : ' + ClientInfo.flash + '<BR><BR>');

	// quicktime
	document.writeln('Quicktime Enabled:<BR>');
	document.writeln('ClientInfo.quicktime : ' + ClientInfo.quicktime + '<BR><BR>');

}


