
function BrowserObject() {
	var place , thestring;
	var detect	= navigator.userAgent.toLowerCase();
	var checkIt	= function(string) {
		place		= detect.indexOf(string) + 1;
		thestring	= string;
		return place;
	};

	this.os,this.name,this.v;

	if (checkIt('konqueror')) {
		this.name	= "konq";
		this.os		= "linux";
	}
	else if (checkIt('chrome'))	{this.name = "chrome"}
	else if (checkIt('safari'))	{this.name = "safari"}
	else if (checkIt('omniweb'))	{this.name = "omni"}
	else if (checkIt('opera'))	{this.name = "opera"}
	else if (checkIt('webtv'))	{this.name = "web"}
	else if (checkIt('firefox'))	{this.name = "firefox"}
	else if (checkIt('icab'))	{this.name = "icab"}
	else if (checkIt('msie'))	{this.name = "internetexplorer"}
	else if (!checkIt('compatible')) {
		this.name	= "navigator";
		this.v		= detect.charAt(8);
	}
	else				{this.name = "unknown"}

	// added for safari 4 which has it's version number declared after the word 'version', instead of after it's name like all other browsers do...
	if (!this.v && (
		detect.match(new RegExp('version\\s*[ /]\\s*(\\d)' , 'i')) ||
		detect.match(new RegExp(thestring + '\\s*[ /]\\s*(\\d)' , 'i'))
	)) {this.v = RegExp.$1}

	// old version extractor
	if (!this.v) {this.v = detect.charAt(place + thestring.length)}

	if (!this.os) {
		if	(checkIt('linux'))	{this.os = "linux"}
		else if (checkIt('x11'))	{this.os = "unix"}
		else if (checkIt('mac'))	{this.os = "mac"}
		else if (checkIt('win'))	{this.os = "win"}
		else				{this.os = "unknown"}
	}

//alert(detect +' en '+ this.v)

	this.ie		= this.name	== "internetexplorer";
	this.opera	= this.name	== "opera";
	this.ff		= this.name	== "firefox";
	this.nav	= this.name	== "navigator";
	this.chrome	= this.name	== "chrome";
	this.safari	= this.name	== "safari";
	this.win	= this.os	== "win";
	this.mac	= this.os	== "mac";
}
bw = new BrowserObject();
