/*

FIND BROWSER TYPE.JS

This is a pile of code which tries to work out in easily testable forms, exactly
what browser we're running, and on what platform.

It defines some global variables (fbtBrowserType, etc) which are loaded and calculated
with sensible values, and you can then test the state of these variables in the page's code.

*/

var fbtBrowserType = "";
var fbtBrowserPlatform = "";
var fbtBrowserVersion = 0;
var fbtTempString = "";
var fbtWorkString = "";



// Determine the browser type, e.g. explorer, navigator, opera, etc.

	fbtTempString = navigator.userAgent.toLowerCase();
	if (fbtTempString.indexOf('msie')!= -1) fbtBrowserType = "explorer";
	else if (fbtTempString.indexOf('opera')!= -1) fbtBrowserType = "opera";
	else if (fbtTempString.indexOf('mozilla') != -1) fbtBrowserType = "navigator";
	else fbtBrowserType = "unknown";

	// Find out the version number of this browser (as a floating point num so
	// we can do greater than/less than comparisons)
	//
	// this is tricky if the browser is Explorer, as the version of Explorer is *not*
	// the first number in the appVersion string, but is in fact the number
	// after the "MSIE" part of the string.
	
	// firstly, set the tempString to navigator.appVersion.
	// This will suffice for Navigator, and also fixes things in case "msie"
	// doesn't appear in the string for some silly reason (e.g. Microsoft
	// change things)
	
	fbtTempString = navigator.appVersion;
	

	
	if (fbtBrowserType == "explorer")
	{
		// Create a new string object called workString, and load it with 
		// the output of navigator.appVersion. I think this works, without using
		// new to create a new object.

		
		fbtWorkString = navigator.appVersion.toLowerCase();
		
		// find out where in the string "msie" falls
		var fbtStartPos = fbtWorkString.indexOf ("msie");
		
		// only do this if the string actually *does* contain msie
		if (fbtStartPos != -1)
		{
			fbtStartPos += 4; // get past the msie part of the string
			fbtTempString = fbtWorkString.substr (fbtStartPos);
		}
	}
	
	// Similarly for Opera, except that opera's version number is
	// embedded in the userAgent string.
	
	else if (fbtBrowserType == "opera")
	{
		// Create a new string object called workString, and load it with 
		// the output of navigator.userAgent. I think this works, without using
		// new to create a new object.

		fbtWorkString = navigator.userAgent.toLowerCase();
		
		// find out where in the string "opera" falls
		var fbtStartPos = fbtWorkString.indexOf ("opera");
		
		// only do this if the string actually *does* contain opera
		if (fbtStartPos != -1)
		{
			fbtStartPos += 5; // get past the 'opera' part of the string
			fbtTempString = fbtWorkString.substr (fbtStartPos);
		}
	}
	


	fbtBrowserVersion = parseFloat(fbtTempString);

	// Determine the platform we're running on
			
	fbtTempString = navigator.platform.toLowerCase();
	if (fbtTempString.indexOf('mac') != -1) fbtBrowserPlatform = "mac";
	else if (fbtTempString.indexOf('win') != -1) fbtBrowserPlatform = "windows";
	else fbtBrowserPlatform = "unknown";