
function Platform() {
  var agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
  this.ns2 = (this.ns && (this.major == 3));
  this.ns3 = (this.ns && (this.major == 3));
  this.ns4b = (this.ns && (this.minor < 4.04));
  this.ns4 = (this.ns && (this.major >= 4) && (this.major < 5));
  this.ns475 = (this.ns4 && this.minor >= 4.75);

  this.op3 = (agent.indexOf("opera") != -1);

  this.isGecko = navigator.product && navigator.product.toLowerCase() == "gecko";
  this.isMozilla = this.ns && !this.op3 && this.isGecko && (navigator.vendor && (navigator.vendor=="" || navigator.vendor=="Mozilla"));
  var rvs = /.*rv:(.*)\).*/.exec(agent);
  var rv = (rvs && rvs[1]) ? rvs[1].split(".") : null;
  this.rvMaj = rv && rv[0] ? rv[0] : 0;
  this.rvMin = rv && rv[1] ? parseInt(rv[1]) : 0;
  this.rvRel = rv && rv[2] ? rv[2] : 0;
  
  this.gecko101 = this.isGecko && this.rvMaj >= 1 && ( ( this.rvMin > 0 ) || (this.rvMin == 0 && this.rvRel >= 1) );
  this.gecko110 = this.isGecko && this.rvMaj >= 1 && this.rvMin > 0;
  
  
  this.ns62plus = (this.ns && navigator.vendor && navigator.vendorSub && (navigator.vendor=="Netscape6" || navigator.vendor=="Netscape") && parseFloat(navigator.vendorSub) >= 6.2);
  
  this.ie = (agent.indexOf("msie") != -1) && !this.op3; // make sure this isnt an Opera spoof
  this.ie3 = (this.ie && (this.major == 2));
  this.ie4 = (this.ie && (this.major >= 4));
  this.ie5  = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0")!=-1) );
  this.ie55  = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5")!=-1) );
  this.ie6  = (this.ie && (this.major == 4 && agent.indexOf("msie 6.0") != -1) );
  this.ie60sp1 = this.ie6 && navigator.appMinorVersion && navigator.appMinorVersion.indexOf("SP1") != -1;
  this.ie5plus  = this.ie55 || this.ie6;
  this.win = (agent.indexOf("win")!=-1);
  this.mac = (agent.indexOf("mac")!=-1);
  this.unix = (agent.indexOf("x11")!=-1);
  this.java = navigator.javaEnabled();
  this.NS4 = (document.layers ? true : false);
  this.IE4 = (document.all ? true: false);
  this.ver4 = (this.NS4 || this.IE4);
  this.isMac = (navigator.appVersion.indexOf("Mac") != -1);
  this.dynamic = ((this.NS4 && !this.ns4b) || (this.IE4 && !this.isMac));
}

Platform.prototype.toString = function () {
	var s="";
	var delim = "|";
	for (var i in this) {
		if (this[i]) s+=i+(typeof this[i] != 'boolean'?':'+this[i]:'')+delim;
	}
	return s;
}
