
function isNumber (c)
{
	return c>='0' && c<='9';
}

function getVersion (s, subs) 
{
	st = s.indexOf (subs);
	
	if (st != -1)
	{
		i=st + subs.length-1;
		
		noVersion = false;
		while (i<s.length && isNumber(s.charAt(i))==false && !noVersion) {
			if (s.charAt(i)==";" || s.charAt(i)=="(" || s.charAt(i)==")" || s.charAt(i)==",")
			{
				noVersion = true;	
			}
			i++;	
		}
		if (i==s.length && !noVersion)
		{
			noVersion == true;
		}
	
		if (!noVersion)
		{
			st = i;
			while (i<s.length && (isNumber(s.charAt(i))==true || s.charAt(i)==".")  ) {
				i++;
			}
			version = s.substring (st, i);
			version = parseFloat (version);
			if (isNaN(version))
			{
				version = 0.0;
			}
		}
		else
		{
			version = 0.0;
		}
	}
	else
	{
		version = 0.0;	
	}
	
	return version;
}


var browserVersion
var agt=navigator.userAgent.toLowerCase();

var is_major = parseInt(navigator.appVersion);
var is_ns  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));
var is_ie   = (agt.indexOf("msie") != -1);
var is_opera = (agt.indexOf("opera")!=-1);
var is_firefox = (agt.indexOf("firefox")!=-1);

if (is_opera)
{
	is_ie = false;
	is_ns = false;
	is_firefox = false;
}
if (is_firefox)
{
	is_ie = false;
	is_ns = false;
	is_opera = false;
}

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_win16 = ((agt.indexOf("win16")!=-1) || (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("windows 16-bit")!=-1) );
var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || (agt.indexOf("windows 16-bit")!=-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));
var is_win2k = false;

var is_mac= (agt.indexOf("mac")!=-1);
var is_mac68k = (agt.indexOf ("mac68")!=-1);
var is_macppc = (agt.indexOf ("ppc")!=-1 && is_mac);

var is_linux = (agt.indexOf("linux")!=-1);

var is_unix = (agt.indexOf("unix")!=-1 && !is_linux);

// browser version number detection
if (is_ie)
{
	browserVersion = getVersion (agt, "msie");
}
else if (is_ns)
{
	if (agt.indexOf("netscape6")>=0)
		browserVersion = getVersion (agt, "netscape6/");
	else
		browserVersion = getVersion (agt, "mozilla");
}
else if (is_opera)
{
	browserVersion = getVersion (agt, "opera");
}
else if (is_firefox)
{
	browserVersion = getVersion (agt, "firefox");
}


// platform/OS version detection
if (is_win)
{
	osVersion = getVersion (agt, "win");
	if (osVersion == 0 && is_winnt)
	{
		osVersion = getVersion (agt, "windows nt");
	}
	if (osVersion>=5.0 && is_winnt)
	{
		is_win2k = true;
	}
			
}
else if (is_mac)
{
	if (agt.indexOf("mac68k") != -1)
	{
		osVersion = getVersion (agt, "mac68k");
	}
	else
	{
		osVersion = getVersion (agt, "mac");
	}
}
else if (is_linux)
{
	osVersion = getVersion (agt, "linux");
}
else if (is_unix)
{
	osVersion = getVersion (agt, "unix");
}


//screen size/color depth information detection
screenWidth = screen.width;
screenHeight = screen.height;
colorDepth = screen.colorDepth;

if (typeof(screenWidth)=="undefined")
{
	screenWidth = 0;
}
if (typeof(screenHeight)=="undefined")
{
	screenHeight = 0;
}
if (typeof(screenDepth)=="undefined")
{
	screenDepth = 0;
}

// CPU class detection (supported only by Internet Explorer)
cpu = navigator.cpuClass;
if (typeof (cpu)!="undefined")
{
	cpuType = cpu;
}
else
{
	cpuType = "";	
}


//---------------------------------------- Flash 5, 6, 7 AND 8 Detection

var state = 0;
var is_flash8 = false;
var is_flash7 = false;
var is_flash6 = false;
var is_flash5 = false;


// general detection (IE on Win will exit)
	var swplugins = navigator.plugins;
	for (var i=0; i<swplugins.length; i++)
	{
		var swplugin = swplugins[i];
		
		if (swplugin.description.toLowerCase().indexOf ("shockwave flash") > -1)
		{
			var plugin_version = 0;
			var plugin_descriptions = swplugin.description.split(" ");
				
			for (var j = 0; j < plugin_descriptions.length; j++)
			{
				var tmpversion = parseInt(plugin_descriptions[j]);
				if (!isNaN(tmpversion))
				{
					plugin_version = tmpversion;
					
					if (plugin_version >= 8) {
					is_flash8 = true;
					is_flash7 = true;
					is_flash6 = true;
					is_flash5 = true;
					}
				
					if (plugin_version >= 7) {
					is_flash7 = true;
					is_flash6 = true;
					is_flash5 = true;
					}
				
					if (plugin_version >= 6) {
					is_flash6 = true;
					is_flash5 = true;
					}
				
					if (plugin_version >= 5) {
					is_flash5 = true;
					}
				}
				else
				{
				}
			}
		}
	}

	

// for IE on win32
if (is_ie && is_win32 && !is_flash8 && !is_flash7 && !is_flash6 && !is_flash5) {
	document.write('<SCRIPT LANGUAGE="VBScript"\>\n');
	document.write('on error resume next\n');
	document.write('is_flash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n');
	document.write('on error resume next\n');
	document.write('is_flash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")))\n');
	document.write('on error resume next\n');
	document.write('is_flash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
	document.write('on error resume next\n');
	document.write('is_flash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
	document.write('</SCRIPT> \n');
}


