/*
    Script: BrowserSniffer.js
    Copyright: Fishnet NewMedia (c) 2009
    Create: 05/19/2009
    Version: 1.0.0
    Changes:
*/

var AHOY;
if (AHOY == undefined) AHOY = {};
if (AHOY.Widget == undefined) AHOY.Widget = {};
if (AHOY.Utilities == undefined) AHOY.Utilities = {};

AHOY.Utilities.BrowserSniffer = function () {
	var b = navigator.appName.toString();
	var p = navigator.platform.toString();
	var ua = navigator.userAgent.toString();

	this.isMozilla = false;
	this.isMSIE = false;
	this.isOpera = false;
	this.isSafari = false;

	var matchResults = false;
	if (matchResults = ua.match(/Opera.([0-9\.]*)/i)) {
		this.isOpera = true;
		this.version = parseFloat(matchResults[1]);
	}
	else if (matchResults = ua.match(/MSIE.([0-9\.]*)/i)) {
		this.isMSIE = true;
		this.version = parseFloat(matchResults[1]);
	}
	else if (matchResults = ua.match(/(applewebkit|safari)\/([\d\.]*)/i)) {
		this.isSafari = true;
		this.version = parseFloat(matchResults[2]);
	}
	else if (ua.match(/gecko/i)) {
		matchResults = ua.match(/rv:\s*([0-9\.]+)/i);
		this.isMozilla = true;
		this.version = parseFloat(matchResults[1]);
	}

	this.isWindows = false;
	this.isMac = false;
	this.isLinux = false;

	this.p =
		ua.match(/windows/i) ? "windows" :
			ua.match(/linux/i) ? "linux" :
				ua.match(/mac/i) ? "mac" :
					ua.match(/unix/i)? "unix" :
						"unknown";
};

AHOY.Browser = new AHOY.Utilities.BrowserSniffer();