//
//  Programma:    browdet6.js 
//  Functie:      Browser Detector
//  Datum:        augustus 2003 / juni 2004
//  Definieert:   functie BrowserDetector() en output parameters: this.browser, 
//                this.platform, this.version, this.majorver, this.minorver,
//                this.domid, this.dom, this.css, this.dombytable, this.cssbytable,
//                this.netscapecss, this.ScreenRes en this.HiRes 
//  Taal:         Javascript 1.2
//  Auteurs:      
//

function BrowserDetector() {

   // Initialise
   this.browser = navigator.appName; 
   this.useragent = "Unknown";
   this.platform = "Unknown";
   this.version = "";
   this.majorver = "";
   this.minorver = "";
   this.domid = '';
   this.dom = false;  
   this.css = false;
   this.dombytable = null;  
   this.cssbytable = null;
   this.netscapecss = false;
	 this.ScreenRes = '';
	 this.HiRes = false;
	
	// Voeg cssDo methods toe aan BrowserDetector object
	this.cssDo  = cssDo;		
	this.cssDo2 = cssDo2;	
  
   ua = navigator.userAgent;
   uaLen = ua.length;
 
   // Split into stuff before parens and stuff in parens
   var preparens = "";
   var parenthesized = "";

   i = ua.indexOf("(");
   if (i >= 0) {
      preparens = Trim(ua.substring(0,i));
         parenthesized = ua.substring(i+1, uaLen);
         j = parenthesized.indexOf(")");
         if (j >= 0) {
            parenthesized = parenthesized.substring(0, j);
         }
   }
   else {
     preparens = ua;
   }

  // First assume browser and version are in preparens
  // override later if we find them in the parenthesized stuff
  var browVer = preparens;

  var tokens = parenthesized.split(";");
  var token = "";
  // Now go through parenthesized tokens
  for (var i=0; i < tokens.length; i++) {
    token = Trim(tokens[i]);
        // compatible - might want to reset from Netscape
        if (token == "compatible") {
          // One might want to reset browVer to a null string
          // here, but instead, we'll assume that if we don't
          // find out otherwise, then it really is Mozilla
          // (or whatever showed up before the parens).
          // browser - try for Opera or IE
    }
    else if (token.indexOf("MSIE") >= 0) {
       browVer = token;
    }
    else if (token.indexOf("Opera") >= 0) {
       browVer = token;
    }
	 
    // platform - try for X11, SunOS, Win, Mac, PPC
    if ((token.indexOf("X11") >= 0) || (token.indexOf("SunOS") >= 0)) {
      this.platform = "Unix";
    }
	 else if (token.indexOf("Linux") >= 0) {
	    this.platform = "Linux";	
	 }
    else if (token.indexOf("Win") >= 0) {
      this.platform = 'Windows';
        }
    else if (token.indexOf("Mac") >= 0) {
	   this.platform = 'Mac';
	 }
	 else if (token.indexOf("PPC") >= 0) {
      this.platform = 'PPC';
    }
  }

  var msieIndex = browVer.indexOf("MSIE");
  if (msieIndex >= 0) {
    browVer = browVer.substring(msieIndex, browVer.length);
  }

  var leftover = "";
  if (browVer.substring(0, "Mozilla".length) == "Mozilla") {
    this.useragent = "Mozilla";
        leftover = browVer.substring("Mozilla".length+1, browVer.length);
  }
  else if (browVer.substring(0, "Lynx".length) == "Lynx") {
    this.useragent = "Lynx";
        leftover = browVer.substring("Lynx".length+1, browVer.length);
  }
  else if (browVer.substring(0, "MSIE".length) == "MSIE") {
    this.useragent = "Explorer";
    leftover = browVer.substring("MSIE".length+1, browVer.length);
  }
  else if (browVer.substring(0, "Microsoft Internet Explorer".length) ==
"Microsoft Internet Explorer") {
    this.useragent = "Explorer"
        leftover = browVer.substring("Microsoft Internet Explorer".length+1,
browVer.length);
  }
  else if (browVer.substring(0, "Opera".length) == "Opera") {
    this.useragent = "Opera"
    leftover = browVer.substring("Opera".length+1, browVer.length);
  }

  leftover = Trim(leftover);

  // Try to get version info out of leftover stuff
  i = leftover.indexOf(" ");
  if (i >= 0) {
    this.version = leftover.substring(0, i);
  }
  else
  {
    this.version = leftover;
  }
  j = this.version.indexOf(".");
  if (j >= 0) {
    this.majorver = this.version.substring(0,j);
    this.minorver = this.version.substring(j+1, this.version.length);
  }
  else {
    this.majorver = this.version;
  }
  
   // het volgende was de domDetect functie 
	// waarden: string 'dom' || 'ie4' || 'ns4' || 'basic' || ''
	
   if(document.documentElement) {
      this.domid = 'dom';
   }
   if (document.all) {
   	// document. -   all , style
      // window.   -   event
      this.domid = 'ie4';
   }
   if (document.layers) {
      // document. -   layers
      // array     -   push  , pop
      this.domid = 'ns4';
   }
   if(document.images) {
      this.domid = 'basic';
   }
   else {
      this.domid = '';
	}

		
   // vind this.dom door object detection
   if (document.getElementById || document.all || document.layers) this.dom = true;   
  
  
   // haal css waarde uit domid 
   if((this.domid == 'dom') || (this.domid == 'ie4')) { 
	   this.css = true; 
	}
	else { 
	   this.css = false;
	} 

	
   // waarden uit Webmonkey tabel (25 august 2003)
	// this.cssbytable en this.dombytable
  
   // versch.
   if (this.browser == 'Konqueror' || this.browser == 'OmniWeb' || this.browser == 'Safari' || this.browser == 'WebTV') {
      this.cssbytable = false;
		this.dombytable = false;
   }

	// BeZilla
   if (this.browser == 'BeZilla') {
      this.cssbytable = true;
		this.dombytable = false;
		this.platform = 'BeOS';
   }	

	// versch.
   if (this.browser == 'Camino' || this.browser == 'ergoBrowser' || this.browser == 'Firebird' || this.browser == 'Galeon' || this.browser == 'iCab' || this.browser == 'Mozilla' || this.browser == "Netscape" || this.browser == 'WarpZilla') {
      this.cssbytable = true;
		this.dombytable = true;
   }	
	
	// Explorer
   if (this.browser == 'Microsoft Internet Explorer' || this.useragent == 'IE') {
	
      if (this.version == '3.0') {
  		   this.cssbytable = true;
		   this.dombytable = false;
		}
		
      if (this.version == '4.0' || this.version == '4.01' || this.version == '4.5' || this.version == '5.0' || this.version == '5.5' || this.version == '6.0') {
  		   this.cssbytable = true;
		   this.dombytable = true;
		}		
	}
	
	// Opera
   if (this.browser == 'Opera') {
      if (this.version == '3.5') {
  		   this.cssbytable = false;
		   this.dombytable = false;
		}
		
      if (this.version == '3.60' || this.version == '3.62' || this.version == '4.02' || this.version == '5.12') {
  		   this.cssbytable = true;
		   this.dombytable = false;
		}	

      if (this.version == '5.11' || this.majorver == 6 || this.majorver == 7) {
  		   this.cssbytable = true;
		   this.dombytable = true;
		}			
	}

	// Navigator
   if (this.browser == 'Navigator') {
      if (this.version == '2.0' || this.version == '3.0' || this.version == '4.0') {
  		   this.cssbytable = false;
		   this.dombytable = false;
		}

      if (this.majorver == 4 && this.version != '4.0') {
  		   this.cssbytable = true;
		   this.dombytable = false;
		}	
		
      if (this.version == '4.5') {
  		   this.css = true;
		   this.dombytable = true;
		}			
		
      if (this.version == '4.7' && this.platform == 'Windows') {
  		   this.cssbytable = true;
		   this.dombytable = true;
		}
		
		// Navigator 4.74	(true, true) for Macintosh OS 9.x and Below 			
      if (this.version == '4.74' && this.platform == 'Mac') {
  		   this.cssbytable = true;
		   this.dombytable = true;
		}	
	}

	// netscapelike css
	this.netscapecss = (this.browser=='Nescape' || this.useragent=='Mozilla' || this.browser=='Navigator');

  // Detect screen resolution: ScreenRes values '' or '800 x 600' etc.
	 
	if (this.domid == 'basic' || this.domid == 'ns4') {
	  this.ScreenRes = screen.width + ' x ' + screen.height;
    if (screen.width>800) this.HiRes = true;
	}  

} // eind BrowserDetector



// Reactie op browser ivm CSS 
function cssDo(generalCss, netscapeCss) {

	// generalCss is url van algemeen stylesheet
	// netscapeCss is url van Netscape stijl stylesheet

	var csslink = "<LINK href='" + generalCss + "' type='text/css' rel='stylesheet'>";
	
	if (this.netscapecss) {
	   csslink = "<LINK href='" + netscapeCss + "' type='text/css' rel='stylesheet'>";
	}
	
	// Indien browser geen stylesheets ondersteunt ga dan 'back'
   if (!this.css || this.useragent=='Opera') {
		//if (history.length>1) history.back();
   } 
	return csslink;

} // cssDo


// Reactie op browser en screen ivm CSS 
function cssDo2(generalCss, netscapeCss, specific800x600Css, specific1024x768Css) {

	var csslink = ""; 

	if (this.netscapecss) {
     csslink = "<LINK href='" + netscapeCss + "' type='text/css' rel='stylesheet'>";
  }
  else {
	   csslink = "<LINK href='" + generalCss + "' type='text/css' rel='stylesheet'>";
	}
  
	if (this.HiRes) {
	   csslink = csslink + "<STYLE type='text/css'>@import " + specific1024x768Css + ";</STYLE>";
	}
  else {
     csslink = csslink + "<STYLE type='text/css'>@import " + specific800x600Css + ";</STYLE>";
  }
	
  
	// Indien browser geen stylesheets ondersteunt ga dan 'back'
  // if (!this.css || this.useragent=='Opera') {
		//if (history.length>1) history.back();
  // } 
	return csslink;

} // cssDo2


// Utility function to trim spaces from both ends of a string
// not part of BrowserDetector object itself
function Trim(inString) {
  var retVal = "";
  var start = 0;
  while ((start < inString.length) && (inString.charAt(start) == ' ')) {
    ++start;
  }
  var end = inString.length;
  while ((end > 0) && (inString.charAt(end - 1) == ' ')) {
    --end;
  }
  retVal = inString.substring(start, end);
  return retVal;
} // Trim


function SendMailToMe(name, subject) {	   
  locationstring = 'mai' + 'lto:' + name + '&#64;&#119;&#118;&#97;&#45;&#97;&#115;&#116;&#114;&#111;&#108;&#111;&#103;&#105;&#101;&#46;&#110;&#108;' + "?subject=" + escape(subject);
  window.location.replace(locationstring);   
}    

function MailMe() {	         
  locationstring = 'mai' + 'lto:' + 'webmaster' + '&#64;&#119;&#118;&#97;&#45;&#97;&#115;&#116;&#114;&#111;&#108;&#111;&#103;&#105;&#101;&#46;&#110;&#108;' + "?subject=" + escape(document.title);
  window.location.replace(locationstring);   
} 

 