/*
	<meta name="author" 		content="Thomas Wilson">
	<meta name="host" 			content="wehostmacs.com">
	<meta name="host-admin" 	content="noc@wehostmacs.com">
	<meta name="keys"			content="brainfarts, add, apple">
	
	<meta name="creation" 		content="08/07/2005">
	<meta name="last_modified"	content="09/13/2005">
*/

//
// -- This detection script is adapted from Peter-Paul Koch's "Browser detect" script,
// -- described in full detail at "http://www.quirksmode.org/js/detect.html"
//
// -- If you develop JavaScript and have not discovered his site, quirksmode.org,
// -- you MUST do so! NOW!
//
// -- This script was written to require strict attention to the order in which specific
// -- browsers are detected. This is a "feature," not a hack. It is what allows fairly
// -- reliable detection with so little code.
//
// -- The browser's user-agent string is the key for proper detection for this script.
//
// -- Since the release of OmniWeb 5.1 Beta 1 (October 6th, 2004), the word "Safari"
// -- now appears in the OmniWeb browser's user-agent string. This causes OmniWeb to be
// -- detected as Apple's Safari browser using the script as published.
//
// -- I swapped the order of detection for Safari and OmniWeb, which seems to have fixed
// -- the problem - for now... (August 10th, 2005)
//

var detect = navigator.userAgent.toLowerCase();

var ns			= "";
var OS			= "unknown";
var	browser		= "unknown";
var	version		= "unknown";
var brsr_class	= "unknown";
var	thestring	= "";


if (checkIt('safari'))
	brsr_class = "Safari";


if (checkIt('konqueror')) {
	OS		= "Linux";
	browser = "Konqueror";
}

else if (checkIt('omniweb/'))	browser = "OmniWeb"
else if (checkIt('omniweb'))	browser = "OmniWeb"
else if (checkIt('shiira'))		browser = "Shiira"
else if (checkIt('safari'))		browser = "Safari"
else if (checkIt('opera'))		browser = "Opera"
else if (checkIt('webtv'))		browser = "WebTV";
else if (checkIt('icab'))		browser = "iCab"
else if (checkIt('msie'))		browser = "Explorer"

else if (!checkIt('compatible')) {
	ns = '*';
	browser = "Netscape";
	version = detect.charAt(8);
	
	if (checkIt('firefox'))
		brsr_class = "FireFox"
	
	else if (checkIt('seamonkey'))
		brsr_class = "SeaMonkey"
	
	else if (checkIt('netscape'))
		brsr_class = "Netscape"
	
	else if (checkIt('mozilla'))
		brsr_class = "Mozilla";
};

if (version == "unknown")
	version = detect.charAt(place + thestring.length);

if (OS == "unknown") {
	if (checkIt('linux'))	 OS = "Linux"
	else if (checkIt('x11')) OS = "Unix"
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows";
};

function checkIt(string) {
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
};
