/*

Browser sniffer  -  Version 0.11b
by Borgar Ãžorsteinsson (borgar@undraland.com)

The script is currently in testing mode. It has been confirmed to work 
correctly with the following browsers:

- Mac : Safari 2.0.4 (419.3)
- Mac : Firefox 1.5
- Mac : Opera 9.02
- Windows : MSIE 6
- Windows : Firefox 1.5

As is the standard with code like this, bit are stolen from various 
sources online and/or books. 

The script is not ment to serve as a excaustive browser checking but 
rather match the most common patterns. It was programmed for use with 
simple web log analysis software where there is no need for endless 
details.

If you are in need of a more precise script then I reccomend the
one available from WebReference.com: http://www.webreference.com/tools/browser/javascript.html

# 
# Copyright (C) 2006 Borgar Ãžorsteinsson <borgar@undraland.com>.
# All rights reserved.
# 
# This program is free software; you can redistribute it and/or modify it 
# under the terms of the GNU General Public License as published by the 
# Free Software Foundation; either version 2 of the License, or (at your 
# option) any later version.
# 
# This program is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
# for more details.
# 
# http://www.gnu.org/licenses/gpl.html
#

*/

// search for a word in the user agent string
function mua(s) {
  var ua = navigator.userAgent.toLowerCase();
  return (ua.indexOf(s.toLowerCase()) > -1);
}

// get user agent version with a regexp
function regv(r) {
  var _rx = new RegExp(r);
  _rx.test(navigator.userAgent);
  return parseFloat(RegExp["$1"]);
}

// --- browser ---

isOpera  = mua("Opera"); // Opera
isSafari = mua("AppleWebKit"); // Konq & Safari
isKonq   = mua("Konqueror");
isKHTML  = mua("KHTML") || isKonq || isSafari;
isIE     = mua("compatible") && mua("MSIE") && !isOpera; // MSIE
isMoz    = mua("Gecko") && !isKHTML; // Mozilla
isFox    = isMoz && mua("Firefox"); // Firefox

var b  = "";
var bv = -1;
if (isSafari) 
{
  b  = "<br/><br/>BROWSER COMPATIBILITY ALERT: Our site is not fully compatible with your current web browser. Please use an alternate browser (ex: FireFox - Free download at http://www.mozilla.com/en-US/ )<br/><br/><br/>";
} 
else if (isKonq) 
{
  b  = "<br/><br/>BROWSER COMPATIBILITY ALERT: Our site is not fully compatible with your current web browser. Please use an alternate browser (ex: FireFox - Free download at http://www.mozilla.com/en-US/ )<br/><br/><br/>";
} 
 else if (isKHTML)
  {
  b  = "<br/><br/>BROWSER COMPATIBILITY ALERT: Our site is not fully compatible with your current web browser. Please use an alternate browser (ex: FireFox - Free download at http://www.mozilla.com/en-US/ )<br/><br/><br/>";
  } 
else if (isFox) 
{

} 
else if (isOpera) 
{

}
else if (isIE) 
{

}

/*
else 
{
  if (isMoz) 
  {
  } 
  else if (isKHTML)
  {
    b += "";
  } 
}
*/

// -- echo results --

// output a string to browser 
var ebuffer = "";
function echo(o) {
  ebuffer = ebuffer + o + "";
}

function report() {
  echo( '' + b );
 // echo( 'Browser version: ' + bv );
}

function find_self(selfname) {
  var _elms = document.getElementsByTagName("script");
  var i = 0;
  while (_elm = _elms[i++]) {
    if (_elm.src.indexOf(selfname) != -1) { return _elm };
  }
  return false;
}

function report_xml() {
  var _script = find_self('/scripts/sniffer.js');
  if (_script) {
    var _elm = document.createElement("div");
    _elm.innerHTML = ebuffer;
    _script.parentNode.appendChild(_elm);
  }
}

report();
if (isIE || !document.getElementById) {
  document.write(ebuffer);
} else {
  report_xml();
}




