var BrowserDetect = Class.create();

BrowserDetect.prototype = {
	
	detect: "",
	browserType: "",
	browserVersion: "",
	os: "",
	place: 0,
	thestring: "",
	
	initialize: function() {
		detect = navigator.userAgent.toLowerCase();
		
		//Retrieve browser type
		if (this.checkIt('konqueror')) browserType = "Konqueror";
		else if (this.checkIt('safari')) browserType = "Safari";
		else if (this.checkIt('omniweb')) browserType = "OmniWeb";
		else if (this.checkIt('opera')) browserType = "Opera";
		else if (this.checkIt('webtv')) browserType = "WebTV";
		else if (this.checkIt('icab')) browserType = "iCab";
		else if (this.checkIt('msie')) browserType = "Internet Explorer";
		else if (this.checkIt('firefox')) browserType = "Firefox";
		else if (!this.checkIt('compatible')) browserType = "Netscape Navigator";
		else browserType = "An unknown browser";

		//Retrieve browser version
		browserVersion = detect.charAt(place + thestring.length)

		//Retrieve operation system
		if (this.checkIt('linux')) os = "Linux";
		else if (this.checkIt('x11')) os = "Unix";
		else if (this.checkIt('mac')) os = "Mac"
		else if (this.checkIt('win')) os = "Windows"
		else os = "an unknown operating system";
	},
	
	getBrowserType: function() {
		return browserType;
	},
	
	getBrowserVersion: function() {
		return browserVersion;
	},
	
	getOperationSystem: function() {
		return os;
	},
	
	checkIt: function(string) {
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}
}