﻿
///////////////////////////////////////////
//
// JavaScript cBrowser class
//
// Used to detect browsers
//
//========================================

function cBrowser()
{
    var d, dom;
   
    d = document;
    this.n = navigator;
    this.na = this.n.appVersion;
    this.nua = this.n.userAgent;
    this.win = ( this.na.indexOf( 'Win' ) != -1 );
    this.mac = ( this.na.indexOf( 'Mac' ) != -1 );
    this.lin = ( this.nua.indexOf( 'Linux' ) != -1 );
    this.ie = new Boolean(false);
    this.op =  new Boolean(false);
    this.konq =new Boolean(false);
    this.saf =new Boolean(false);
    this.moz =new Boolean(false);
    this.ie = new Boolean(false);
    this.ie4 = new Boolean(false);
    this.ie9 = new Boolean(false);
    this.ns6 = document.getElementById&&!document.all
    
    if ( !d.layers )
    {
	    dom = ( d.getElementById );
	    this.op = ( this.nua.indexOf( 'Opera' ) != -1 );
	    this.konq = ( this.nua.indexOf( 'Konqueror' ) != -1 );
	    this.saf = ( this.nua.indexOf( 'Safari' ) != -1 );
	    this.moz = ( this.nua.indexOf( 'Gecko' ) != -1 && !this.saf && !this.konq);
	    this.ie = ( d.all && !this.op );
	    this.ie4 = ( this.ie && !dom );
	    //this.ie9 = ( this.ie && (typeof window.performance !='undefined') );
	    this.ie9 = (this.ie && (this.getInternetExplorerVersion() >= 9.0) );

	    /*
	    ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
	    Opera will register true in this test if set to identify as IE 5
	    */

	    this.ie5x = ( d.all && dom );
	    this.ie5mac = ( this.mac && this.ie5x );
	    this.ie5xwin = ( this.win && this.ie5x );
    }
    
}

cBrowser.prototype.n; 
cBrowser.prototype.na; 
cBrowser.prototype.nua; 
cBrowser.prototype.ie; 
cBrowser.prototype.ie4; 
cBrowser.prototype.ie5x;
cBrowser.prototype.ie9;
cBrowser.prototype.moz;
cBrowser.prototype.kong;   
cBrowser.prototype.saf;   
cBrowser.prototype.ie5mac; 
cBrowser.prototype.ie5xwin; 
cBrowser.prototype.op;
cBrowser.prototype.win;
cBrowser.prototype.mac;
cBrowser.prototype.lin;
cBrowser.prototype.ns6;



cBrowser.prototype.getInternetExplorerVersion = function()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

