//******************************************//
//	Create Browser / Platform Test Object	//
//******************************************//

//**************************//
//** Constructor Function **//
//**************************//

function BrowserObject()
{
	this.userAgent = navigator.userAgent.toLowerCase();
	this.OS = "unknown OS";
	this.browser = "unknown browser";
	this.version = -1;
	
	//internal variable
	var position = 0;
			
	if (this.userAgent.indexOf("konqueror") > -1){this.browser = "konqueror"; this.OS = "linux";}
	else if (this.userAgent.indexOf("safari") > -1) this.setBrowserDetails("safari", "safari");
	else if (this.userAgent.indexOf("omniweb") > -1) this.setBrowserDetails("omniweb", "omniweb");
	else if (this.userAgent.indexOf("opera") > -1) this.setBrowserDetails("opera", "opera");
	else if (this.userAgent.indexOf("webtv") > -1) this.setBrowserDetails("webtv", "webtv");
	else if (this.userAgent.indexOf("icab") > -1) this.setBrowserDetails("icab", "icab");
	else if (this.userAgent.indexOf("msie") > -1) this.setBrowserDetails("msie", "ie");
	else if (!this.userAgent.indexOf("compatible")  > -1){this.browser = "netscape"; this.version = this.userAgent.charAt(8);}
	else browser = "An unknown browser";
		
	if (this.OS == "unknown OS")
	{
		if (this.userAgent.indexOf("linux") > -1) this.OS = "Linux";
		else if (this.userAgent.indexOf("x11") > -1) this.OS = "Unix";
		else if (this.userAgent.indexOf("mac") > -1) this.OS = "Mac"
		else if (this.userAgent.indexOf("win") > -1) this.OS = "Windows"
		else this.OS = "an unknown operating system";
	}	
}

BrowserObject.prototype.setBrowserDetails = function(string, browser)
{
	this.browser = browser;
	this.version = this.userAgent.charAt((this.userAgent.indexOf(string) + 1 + string.length));
}

var browserObject = new BrowserObject();