﻿var Browser = Class.create(); Browser.prototype = { initialize: function() { this.userAgent = navigator.userAgent.toLowerCase(); this.isMozilla = (typeof document.implementation!='undefined') && (typeof document.implementation.createDocument!='undefined') && (typeof HTMLDocument!='undefined'); this.isIE = window.ActiveXObject ? true : false; this.isFirefox = (this.userAgent.indexOf("firefox") != -1); this.isSafari = (this.userAgent.indexOf("safari") != -1); this.isOpera = (typeof window.opera != 'undefined'); this.isMacOS = (navigator.platform.indexOf("Mac") != -1); this.version = 1; if(this.isFirefox) this.version = parseFloat(this.userAgent.substr(this.userAgent.indexOf("firefox")+8, 3)); else if(this.isOpera) { if(window.opera.version) this.version = parseFloat(window.opera.version()); else this.version = 7.5; } else if(this.isIE) { var re = new RegExp("msie ([0-9]{1,}[\.0-9]{0,})"); if(re.exec(this.userAgent) != null) this.version = parseFloat(RegExp.$1); else this.version = 3; } else if(this.isSafari) { var kitName = "applewebkit/"; var kitVersion = this.userAgent.substring(this.userAgent.indexOf(kitName) + kitName.length, this.userAgent.length); kitVersion = parseInt(kitVersion.substring(0, kitVersion.indexOf(" "))); this.version = kitVersion >= 400 ? 2.0 : kitVersion >= 300 ? 1.3 : kitVersion > 100 ? 1.2 : 1.0; } } };
