/*
useragent.asp
Client-Side UserAgent Sniffer
Written by Sing Chan
Grey Worldwide Northwest - www.greynorthwest.com, 604.687.1001
Version 5.1 - Last modified December 1, 2002
*/
function MM_FlashInfo() {}

function uaWinX () {
  return (window.innerWidth) ? window.innerWidth : (document.body) ? document.body.clientWidth : 0;
}

function uaWinY () {
  return (window.innerHeight) ? window.innerHeight : (document.body) ? document.body.clientHeight : 0;
}

function uaScrollX () {
  return (!ua.isNS3 && pageXOffset != "undefined") ? pageXOffset : (document.body) ? document.body.scrollLeft : 0;
}

function uaScrollY () {
  return (!ua.isNS3 && pageYOffset != "undefined") ? pageYOffset : (document.body) ? document.body.scrollTop : 0;
}

function uaDebug () {
  var key;
  var s = "";
  for (key in this) {
    s += key + ": " + this[key] + "\n";
  }
  return (s);
}

function uaSniffer() {
  var s, i;
  this.sAgent   = navigator.userAgent.toLowerCase();
  this.os       = (this.sAgent.indexOf("win") >= 0) ? "win" : (this.sAgent.indexOf("mac") >= 0) ? "mac" : "other";
	this.isIE     = false;
	this.isIE4mac = false;
	this.isIE5mac = false;
	this.isGecko  = false;
	this.isNS4    = false;
	this.isNS3    = false;
	this.isOpera  = false;
	this.isKonqueror = false;
	this.isSafari = false;
	this.isOther  = false;
	this.version  = 0;

  if (this.sAgent.indexOf("mozilla/") >= 0 && parseFloat(navigator.appVersion) < 4) {
    this.version = parseFloat(navigator.appVersion);
    this.isNS3 = true;
	} else if ((i = this.sAgent.indexOf(s = "msie")) >= 0) { // check IE version
		this.version = parseFloat(this.sAgent.substr(i + s.length));
		this.isIE = true;
		this.isIE4mac = (this.os == "mac" && this.version < 5) ? true : false;
		this.isIE5mac = (this.os == "mac" && this.version >= 5) ? true : false;
	} else if ((i = this.sAgent.indexOf(s = "safari/")) >= 0) { // check Safari
		this.version = parseFloat(this.sAgent.substr(i + s.length));
		this.isSafari = true;
	} else if ((i = this.sAgent.indexOf(s = "opera/")) >= 0) { // check Opera
		this.version = parseFloat(this.sAgent.substr(i + s.length));
		this.isOpera = true;
	} else if ((i = this.sAgent.indexOf(s = "konqueror/")) >= 0) { // check Konqueror
		this.version = parseFloat(this.sAgent.substr(i + s.length));
		this.isKonqueror = true;
	} else if ((i = this.sAgent.indexOf(s = "mozilla/")) >= 0) { // check Gecko / Netscape 4 or 3 version
		this.version = parseFloat(this.sAgent.substr(i + s.length));
		if (this.version >= 5) { // if Gecko, check for revision version instead
      this.isGecko = true;
      this.version = this.sAgent.substr(this.sAgent.indexOf(s = "rv:") + s.length);
      s = this.version.substr(0, this.version.indexOf(".") + 1);
      this.version = this.version.substr(this.version.indexOf("."));
      for (i = 0; i < this.version.length; i++) {
        if (this.version.charAt(i) != ".") {
          s += this.version.charAt(i);
        }
      }
      this.version = parseFloat(s);
		} else if (this.version >= 4) {
			this.isNS4 = true;
		}
	} else {
		this.isOther = true;
	}
	this.isCool = ((this.isIE && this.version >= 5) || (this.isGecko && this.version >= 0.92) || (this.isKonqueror && this.version >= 3) || (this.isSafari)) ? true : false;

  this.screenX  = (this.isNS3) ? 0 : window.screen.width;
  this.screenY  = (this.isNS3) ? 0 : window.screen.height;
  this.winX     = uaWinX;
  this.winY     = uaWinY;
  this.scrollX  = uaScrollX;
  this.scrollY  = uaScrollY;
  this.debug    = uaDebug;
  this.flash    = new MM_FlashInfo();
  this.qt       = false;
}
