﻿function Is ()
{
	var pos			= 0;
	var agt			= navigator.userAgent;	if (agt) { agt = agt.toLowerCase(); } else { agt = ""; }
	var app			= navigator.appName;	if (app) { app = app.toLowerCase(); } else { app = ""; }
	var ver			= navigator.appVersion;	if (ver) { ver = ver.toLowerCase(); } else { ver = ""; }

	this.browser_name	= "Unknown";
	this.os_name		= "Unknown";
	var isMozilla	= agt.indexOf('mozilla') != -1;
	var isGecko		= agt.indexOf('gecko') != -1;
	var isOpera		= agt.indexOf('opera') != -1;
	var isWebTv		= agt.indexOf('webtv') != -1;
	var isSpoofer	= agt.indexOf('spoofer') != -1;
	var isHotJava	= ((agt.indexOf('hotjava') != -1) || (agt.indexOf('sun)') != -1));
	var isCompatible= agt.indexOf('compatible') != -1;
	var isIE		= agt.indexOf("msie") != -1;
	var isAOL		= agt.indexOf("aol") != -1;
	var isMSN		= agt.indexOf("msn") != -1;
	var isDreamcast	= ((agt.indexOf("dreampassport") != -1) || (agt.indexOf("sonicpassport") != -1));
	var isNetFront	= agt.indexOf("avefront") != -1;		//PS2
	var isEgBrowser	= agt.indexOf("planetweb") != -1;		//PS2

	var isWin		= agt.indexOf("win") != -1;
	var isMac		= agt.indexOf("mac") != -1;
	var isLinux		= agt.indexOf("linux") != -1;
	var isSunOS		= agt.indexOf("sunos") != -1;
	var isFreeBSD	= agt.indexOf("freebsd") != -1;
	var isHPUX		= agt.indexOf("hp-ux") != -1;

	this.engine_version_major	= parseInt(ver);
	this.engine_version_minor	= parseFloat(ver);
	this.engine_Netscape		= (isMozilla && !isGecko && !isOpera && !isDreamcast && !isNetFront && !isEgBrowser);
	this.engine_Gecko			= isGecko;
	this.engine_IE				= (isIE && !isOpera);
	this.engine_Opera			= isOpera;
	this.engine_Dreamcast		= isDreamcast;
	this.engine_NetFront		= isNetFront;
	this.engine_EgBrowser		= isEgBrowser;

	this.vender_version_major			= parseInt(ver);
	this.vender_version_minor			= parseFloat(ver);
	if (		this.vender_Microsoft	= this.engine_IE) { }
	else if (this.engine_Netscape && !isCompatible)
	{ 			this.vender_Netscape	= true; }	// After exclude this.vender_Mozilla
	else if (this.vender_Netscape && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)))
	{			this.vender_NavOnly		= true; }
	else if (	this.vender_Opera		= isOpera)		{ this.vender_Microsoft	= false; this.vender_Netscape	= false; }
	else if (	this.vender_AOL			= isAOL)		{ this.vender_Microsoft	= false; }
	else if (	this.vender_MSN			= isMSN)		{ this.vender_Microsoft	= false; }
	else if (	this.vender_HotJave		= isHotJava)	{ this.vender_Netscape	= false; }
	else if (	this.vender_Spoofer		= isSpoofer)	{ this.vender_Netscape	= false; }
	else if (	this.vender_WebTv		= isWebTv)		{ this.vender_Netscape	= false; }
	else if (	this.vender_SEGA		= isDreamcast)	{ this.vender_Netscape	= false; }
	else if (	this.vender_NetFront	= isNetFront)	{ this.vender_Netscape	= false; }
	else if (	this.vender_Netscape	= isEgBrowser)	{  }


	if (this.engine_Gecko && (this.engine_version_major == 5))
	{
		if (agt.indexOf("netscape6") || agt.indexOf("netscape7"))
		{
			this.engine_version_major = parseInt(navigator.vendorSub);
			this.engine_version_minor = parseFloat(navigator.vendorSub);
		}

		// Identify between Netscape and Mozilla
		this.vender_Netscape = !(this.vender_Mozilla = (navigator.vendor == ""));

		if (this.vender_Netscape)
		{
			this.browser_name			= "Netscape";
			this.vender_version_major	= this.engine_version_major;
			this.vender_version_minor	= this.engine_version_minor;
		}
		else if (this.vender_HotJave)
		{
			if ((pos = agt.indexOf("hotjava")) != -1)
			{
				this.browser_name			= "HotJava";
				var temp = agt.substr(pos + 8, 8);
				this.vender_version_major	= parseInt(temp);
				this.vender_version_minor	= parseFloat(temp);
			}
			else // only "sun"
			{
				this.browser_name			= "HotJapa by Sun";
				this.vender_version_major	= 0;
				this.vender_version_minor	= 0;
			}
		}
		else if (this.vender_Spoofer)
		{
			if ((pos = agt.indexOf("spoofer")) != -1)
			{
				this.browser_name			= "Spoofer";
				var temp = agt.substr(pos + 8, 8);
				this.vender_version_major	= parseInt(temp);
				this.vender_version_minor	= parseFloat(temp);
			}
		}
		else if (this.vender_WebTV)
		{
			if ((pos = agt.indexOf("webtv")) != -1)
			{
				this.browser_name			= "WebTV";
				var temp = agt.substr(pos + 6, 8);
				this.vender_version_major	= parseInt(temp);
				this.vender_version_minor	= parseFloat(temp);
			}
		}
	}
	else if (this.engine_IE)
	{
		if ((pos = agt.indexOf("msie")) != -1)
		{
			var temp = agt.substr(pos + 5, 8);
			this.engine_version_major	= parseInt(temp);
			this.engine_version_minor	= parseFloat(temp);
		}

		if (this.vender_Microsoft)
		{
			this.browser_name			= "Internet Explorer";
			this.vender_version_major = this.engine_version_major;
			this.vender_version_minor = this.engine_version_minor;
		}
		else if (this.vender_AOL)
		{
			if ((pos = agt.indexOf("aol")) != -1)
			{
				this.browser_name			= "Internet Explorer by AOL";
				var temp = agt.substr(pos + 4, 8);
				this.vender_version_major = parseInt(temp);
				this.vender_version_minor = parseFloat(temp);
			}
		}
		else if (this.vender_MSN)
		{
			if ((pos = agt.indexOf("msn")) != -1)
			{
				this.browser_name			= "MSN Explorer";
				var temp = agt.substr(pos + 4, 8);
				this.vender_version_major	= parseInt(temp);
				this.vender_version_minor	= parseFloat(temp);
			}
		}
	}
	else if (this.engine_Opera)
	{
		if ((pos = agt.indexOf("opera")) != -1)
		{
			this.browser_name			= "Opera";
			var temp = agt.substr(pos + 6, 8);
			this.engine_version_major	= parseInt(temp);
			this.engine_version_minor	= parseFloat(temp);
			this.vender_version_major	= this.engine_version_major;
			this.vender_version_minor	= this.engine_version_minor;
		}
	}
	else if (this.engine_Dreamcast)
	{
		if ((pos = agt.indexOf("dreampassport")) != -1)
		{
			this.browser_name			= "Dreamcast";
			var temp = agt.substr(pos + 14, 8);
			this.vender_version_major	= parseInt(temp);
			this.vender_version_minor	= parseFloat(temp);
		}
	}
	else if (this.engine_NetFront)
	{
		if ((pos = agt.indexOf("avefront")) != -1)
		{
			this.browser_name			= "NetFront";
			var temp = agt.substr(pos + 8, 8);
			this.vender_version_major	= parseInt(temp);
			this.vender_version_minor	= parseFloat(temp);
		}
	}
	else if (this.engine_EgBrowser)
	{
		if ((pos = agt.indexOf("planetweb")) != -1)
		{
			this.browser_name			= "EgBrowser";
			var temp = agt.substr(pos + 10, 8);
			this.vender_version_major	= parseInt(temp);
			this.vender_version_minor	= parseFloat(temp);
		}
	}

	// *** Platform ***
		 if (this.os_Win		= isWin)					{ this.os_name = "Windows"; }
	else if (this.os_Mac		= isMac)					{ this.os_name = "Mac"; }
	else if (this.os_Linux		= isLinux)					{ this.os_name = "Linux"; }
	else if (this.os_SunOS		= isSunOS)					{ this.os_name = "SunOS"; }
	else if (this.os_FreeBSD	= isFreeBSD)				{ this.os_name = "FreeBSD"; }
	else if (this.os_HPUX		= isHPUX)					{ this.os_name = "HPUX"; }
	else if (this.os_PS2		= this.engine_NetFront)		{ this.os_name = "PS2"; }
	else if (this.os_PS2		= this.engine_EgBrowser)	{ this.os_name = "PS2"; }
	else if (this.os_Dreamcast	= this.engine_Dreamcast)	{ this.os_name = "Dreamcast"; }

	if (navigator.platform)
	{
		var platform = navigator.platform.toLowerCase();

			 if (this.os_Win		= (platform.indexOf("win") != -1)) {this.os_name = "Windows"; }
		else if (this.os_Mac		= (platform.indexOf("mac") != -1)) {this.os_name = "Mac"; }
	}

	if (this.engine_IE)
	{
		if (this.os_Win)
		{
				 if (this.os_version_WinXP = (agt.indexOf("windows nt 5.1") != -1))	{ this.os_WinNT = true; this.os_name = "Windows XP"; }
			else if (this.os_version_Win2K = (agt.indexOf("windows nt 5.0") != -1))	{ this.os_WinNT = true; this.os_name = "Windows 2000"; }
			else if (this.os_version_WinNT = (agt.indexOf("windows nt 4.0") != -1))	{ this.os_WinNT = true; this.os_name = "Windows NT"; }
			else if (this.os_version_WinME = (agt.indexOf("win 9x 4.90") != -1))	{ this.os_Win9x = true; this.os_name = "Windows ME"; }
			else if (this.os_version_Win98 = (agt.indexOf("windows 98") != -1))		{ this.os_Win9x = true; this.os_name = "Windows 98"; }
			else if (this.os_version_Win95 = (agt.indexOf("windows 95") != -1))		{ this.os_Win9x = true; this.os_name = "Windows 95"; }
		}
	}
	else if (this.engine_Netscape)
	{
		if (this.os_Win)
		{
				 if (this.os_version_WinXP = (agt.indexOf("windows nt 5.1") != -1))	{ this.os_WinNT = true; this.os_name = "Windows XP"; }
			else if (this.os_version_Win2K = (agt.indexOf("windows nt 5.0") != -1))	{ this.os_WinNT = true; this.os_name = "Windows 2000"; }
			else if (this.os_version_WinNT = (agt.indexOf("winnt") != -1))			{ this.os_WinNT = true; this.os_name = "Windows NT"; }
			else if (this.os_version_WinME = (agt.indexOf("win 9x 4.90") != -1))	{ this.os_Win9x = true; this.os_name = "Windows ME"; }
			else if (this.os_version_Win98 = (agt.indexOf("win98") != -1))			{ this.os_Win9x = true; this.os_name = "Windows 98"; }
			else if (this.os_version_Win95 = (agt.indexOf("win95") != -1))			{ this.os_Win9x = true; this.os_name = "Windows 95"; }
		}
	}
	else if (this.engine_Gecko)
	{
		if (this.os_Win)
		{
				 if (this.os_version_WinXP = (agt.indexOf("windows nt 5.1") != -1))	{ this.os_WinNT = true; this.os_name = "Windows XP"; }
			else if (this.os_version_Win2K = (agt.indexOf("windows nt 5.0") != -1))	{ this.os_WinNT = true; this.os_name = "Windows 2000"; }
			else if (this.os_version_WinNT = (agt.indexOf("winnt4.0") != -1))		{ this.os_WinNT = true; this.os_name = "Windows NT"; }
			else if (this.os_version_WinME = (agt.indexOf("win 9x 4.90") != -1))	{ this.os_Win9x = true; this.os_name = "Windows ME"; }
			else if (this.os_version_Win98 = (agt.indexOf("win 98") != -1))			{ this.os_Win9x = true; this.os_name = "Windows 98"; }
			else if (this.os_version_Win95 = (agt.indexOf("win 95") != -1))			{ this.os_Win9x = true; this.os_name = "Windows 95"; }
		}
	}
	else if (this.engine_Opera)
	{
		if (this.os_Win)
		{
				 if (this.os_version_WinXP = (app.indexOf("windows xp") != -1))		{ this.os_WinNT = true; this.os_name = "Windows XP"; }
			else if (this.os_version_Win2K = (app.indexOf("windows 2000") != -1))	{ this.os_WinNT = true; this.os_name = "Windows 2000"; }
			else if (this.os_version_WinNT = (app.indexOf("windows nt") != -1))		{ this.os_WinNT = true; this.os_name = "Windows NT"; }
			else if (this.os_version_WinME = (app.indexOf("windows me") != -1))		{ this.os_Win9x = true; this.os_name = "Windows ME"; }
			else if (this.os_version_Win98 = (app.indexOf("windows 98") != -1))		{ this.os_Win9x = true; this.os_name = "Windows 98"; }
			else if (this.os_version_Win95 = (app.indexOf("windows 95") != -1))		{ this.os_Win9x = true; this.os_name = "Windows 95"; }
		}
	}
}

var objUserInfo = new Is();
