/* NOTE: This file permanently resides at <http://mikaels.net/archives/public/application/javascript/uaenvir/v3.3/uaenvir.3_3_5_1.js>

   ****	Copyrighted by lars.pm <mailto:larspeemm@netscape.net> (C) 2001-2008  
   
   **** * NOTE for release 3.3.4:
	* excluding trident from CSS2 check >= 1.8 (workaround problem with style.display)
   **** * NOTES for release 3.3.2:
	* The following /envir/ property has been *taken over* from uaexami.js:
	* dom (along with properties defining envir.dom.*)	  
   ****	* Version 3.2 has not been published as a separate file.
   	* Version 3.1 resides at <http://memo.mikaels.net/pm-public/uaenvir.js>
   **** */

function Dom() { 

if ((typeof document.implementation != 'undefined') && (typeof document.implementation.hasFeature != 'undefined')){
	if (document.implementation.hasFeature("HTML","1.0") ||
	 document.implementation.hasFeature("XML","1.0")) this.implemented = 1;
	if (document.implementation.hasFeature("Core","2.0")) this.implemented = 2; 
	if (document.implementation.hasFeature("Core","3.0")) this.implemented = 3;
	} else this.implemented = 0;
this.html=this.xml=0;
this.range=this.traversal=this.views=this.stylesheets=this.css=this.css2=0; 
this.events=this.uievents=this.mouseevents=this.mutationevents=this.htmlevents=0;
this.ls=this.lsasync=this.validation=0;
if (this.implemented == 1){
	if (document.implementation.hasFeature("HTML","1.0")) this.html = 1 ;
	if (document.implementation.hasFeature("XML","1.0")) this.xml = 1 ;
	}	
else if (this.implemented >= 2){
	if (document.implementation.hasFeature("HTML","2.0")) this.html = 2;
	else if (document.implementation.hasFeature("HTML","1.0")) this.html = 1;
	if (document.implementation.hasFeature("XML","2.0")) this.xml = 2;
	else if (document.implementation.hasFeature("XML","1.0")) this.xml = 1;
	if (document.implementation.hasFeature("Range","2.0")) this.range = 2;
	if (document.implementation.hasFeature("Traversal","2.0")) this.traversal = 2;
	if (document.implementation.hasFeature("Views","2.0")) this.views = 2;
	if (this.views){
		if (document.implementation.hasFeature("CSS","2.0")) this.css = 2;
		if (this.css){
			if (document.implementation.hasFeature("CSS2","2.0")) this.css2 = 2;
			}
		}
	if (document.implementation.hasFeature("StyleSheets","2.0")) this.stylesheets = 2;
	if (document.implementation.hasFeature("Events","2.0")) this.events = 2;
	if (this.events){
		if (this.views){
			if (document.implementation.hasFeature("UIEvents","2.0")) this.uievents = 2;
			if (this.uievents){
				if (document.implementation.hasFeature("MouseEvents","2.0")) this.mouseevents = 2;
				}
			}
		if (document.implementation.hasFeature("MutationEvents","2.0")) this.mutationevents = 2;
		if (document.implementation.hasFeature("HTMLEvents","2.0")) this.htmlevents = 2;
		}
//some DOM 3 features defined here
	if (document.implementation.hasFeature("LS","3.0")) this.ls = 3;
	if (this.ls){
		if (document.implementation.hasFeature("LS-Async","3.0")) this.lsasync = 3;
		}
	}	
if (this.implemented == 3){
	if (document.implementation.hasFeature("XML","3.0")) this.xml = 3;
	if (document.implementation.hasFeature("Validation","3.0")) this.validation = 3;
	}	

} //Dom ends

function Extra() {
//NOTE: This function requires JS1.1 and ECMA ed.1
//It is an optional mime types and plug-ins availability 
//test for some browsers only, notably *not* for Internet Explorer. 

  if (navigator.mimeTypes.length > 0 &&
	typeof(navigator.javaEnabled) =='function'){
  var mimetype, plugin, custom, prettyNameType, prettyNamePlug;
  	var s1eval = "navigator['x" , s2eval ="']";

    for (var p=0;p<arguments.length;p++){
	custom=arguments[p]; var cuiO = custom.indexOf('/') , cux = (custom.indexOf('/x-')!=-1); 
	if (cux) var modcustom=custom.substring(0,cuiO)+custom.substring(cuiO+2);
	else var modcustom=custom.substring(0,cuiO)+'-'+custom.substring(cuiO+1);
	var customList = modcustom.split('-');
	//removing "application"
    	if (customList[0].indexOf('application')>-1) customList[0]='';
    	var sPN=customList[0]; 

    	for (var o=1;o<customList.length;o++){
    	sPN+=customList[o].charAt(0).toUpperCase()+customList[o].substring(1);
	}
	prettyNameType = 'type'+sPN.charAt(0).toUpperCase()+sPN.substring(1);
	prettyNamePlug = 'plug'+sPN.charAt(0).toUpperCase()+sPN.substring(1);
	
 	//do not touch the eval conditions below  
  	eval(s1eval+prettyNameType+s2eval+" = true");
  	eval(s1eval+prettyNamePlug+s2eval+" = false");
  	mimetype = navigator.mimeTypes[custom];
  	if (mimetype)
  	{
     	plugin = mimetype.enabledPlugin;
     	if (plugin) eval(s1eval+prettyNamePlug+s2eval+" = true");  
  	}
  	else eval(s1eval+prettyNameType+s2eval+" = false");
    }

  //safety conditions ends
  } 
//Extra ends.
} 

function Envir(){
if (navigator.js >=1.1){
 //checking readiness for ANY JAVA
 this.java = (navigator.javaEnabled())
  	
 this.CSS2 = this.CSS1 = 0;
 //old envir properties - MAY BE REMOVED IN THE NEXT VERSION OF THIS SCRIPT:
 this.strict = this.standards = this.common = this.dhtml = false;
 this.noenvir = false;
//NOTE: navigator._exami array pos 0 is JScript number; pos 1 is ecma boolean; pos 2 is ecma3 boolean
//traditional competitors - classic sniffing -
        //environment is typical Netscape Navigator 4.x : array pos 3
  navigator._exami[3] = (navigator.kin == "Netscape/4" && (typeof(document.layers) != 'undefined'));
        //environment is typical Microsoft Internet Explorer 4+ : array pos 4
  navigator._exami[4] = (navigator.kin == "MSIE/4" && (typeof(document.all) != 'undefined'));
        //DOM standards (W3C recommendations) : array pos 5
  navigator._exami[5]  = (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.getElementsByTagName) != 'null' &&
        typeof(document.createElement) != 'undefined' && typeof(document.getElementById) != 'undefined');

//some additional capabilities : array pos 6 and 7
navigator._exami[6]=false; //domelementstyle
navigator._exami[7]=false; //domcreateevent
if (navigator._exami[5] && navigator._exami[2])  {
        var elem = document.createElement('p');
  navigator._exami[6] = (typeof(elem.style) == 'object');
  navigator._exami[7] = (typeof(document.createEvent) != 'undefined');  
  }
  
  var appuA = window.navigator.userAgent;
  var ua = appuA.toLowerCase(); var i = 0;
//decision on the compatibility version: the browser generation : array pos 8
  var appcn = window.navigator.appCodeName.toLowerCase(); var appCNS;
  //browser *not* identifying by the code name "Mozilla", so making empty string
  if (appcn != 'mozilla') appCNS = '';
  else 	{ i = ua.indexOf(appcn); 
  //code name "Mozilla" but *not* using that name in the ua string, so *temporarily* making it to version 1
     	if (i!=0) appCNS = 1; 
  //ua string version accepted
        else 	{ appCNS = parseFloat('0' + ua.substring(8));
  //recognising only five compatibility versions, if more, *temporarily* resetting it to version 1
   		if (appCNS >= 6) appCNS = 1;
 		if (appCNS <3 && navigator.js >= 1.1) appCNS=3;
 		else if (appCNS <2 && navigator.js >= 1.0) appCNS=2;
 		}
	}  
 var aCNS = parseFloat(appCNS); //maybe NaN
 //checking DHTML capabilities
 if (aCNS <5 && navigator._exami[2] && navigator._exami[5]) aCNS = 5;
 else if (aCNS <4 && navigator._exami[1] && (navigator._exami[5] || navigator._exami[3] || navigator._exami[4])) aCNS=4;
 navigator._exami[8] = aCNS;

// checking implementations of the W3C DOM
if (navigator._exami[8]>=5) this.dom = new Dom()
	 else {
	 this.dom = new Object(); this.dom.implemented = 0;
	 }

  //calling the Extra function for JavaScript MIME types and plug-ins check
	var a0 = "application/x-shockwave-flash"
  //Returns boolean values for property names on the basis of the MIME type, for example: 
  //if MIME type is available, then true for navigator.xtypeShockwaveFlash
  //if also plugin is available, then true for navigator.xplugShockwaveFlash

  //Popular plug-ins list - suitable for EDITING ***
  //Add or subtract mime types lines (in accordance with the pattern) to or from the list below.
  //Shockwave Flash is always checked; remove (or add) comment-outs "//" to enable (or disable) more checks.
   	if (navigator._exami[1]){ Extra(a0
//	, "application/futuresplash"
//	, "application/x-director"
// 	, "application/pdf"
// 	, "video/quicktime"
//	, "image/x-quicktime"
//	, "application/x-mtx"
// 	, "audio/x-pn-realaudio-plugin"
//	, "application/asx"
//	, "video/x-ms-asf-plugin"
//	, "application/x-mplayer2"
//	, "application/x-java-applet"
//	, "application/x-java-bean"
	);}

 if (navigator.js >= 1.2){

  // CSS COMPLIANCE
  /* Cascading Style Sheets are implemented gradually in browsers and therefore two approximate
   * implementation series are used for level 1 and 2 respectively:
   * 0.3 , 0.6 , 0.8 and 1.0 is for CSS1
   * 0.5 , 1.0 , 1.2 , 1.4 , 1.6 , 1.8 , 1.9 , 2.0 and 2.1 for CSS2
   * A selection of well-known browsers are used as targets for consideration of CSS compatibility. 
   * The values for these are preset to a certain degree. For other browsers we rely on checkings
   * of the style object. Browser support info and nice testings respectively found at
   * <http://www.westciv.com/style_master/academy/browser_support/index.html> 
   * <http://devedge.netscape.com/toolbox/tools/2001/feature-detection/>
   */
  
    //presetting the target compatibility (allowing spoofing of appName and appVersion)
  if (navigator.kin == 'Netscape/5') {this.CSS2 = 1.8; this.CSS1 = 1}
  else if (navigator.kin.indexOf('Opera') == 0){ this.CSS1 = 1;
  	if (parseInt(navigator.kin.charAt(6)) >= 5) this.CSS2 = 1.6;
  	else this.CSS2 = 1.2; }
  else if (navigator.kin == 'MSIE/4' && navigator.xOS[0] == 'mac') {
  	if (navigator.version >= 5) {this.CSS2 = 1.4; this.CSS1 = 1}
  	else {this.CSS2 = 1; this.CSS1 = 0.6}
  	}
  else if (navigator.kin == 'MSIE/4' && navigator.xOS[0] == 'win') {
  	if (navigator.version >= 5.5) {this.CSS2 = 1.6; this.CSS1 = 1}
  	else if (navigator.version >= 5){this.CSS2 = 1.2; this.CSS1 = 0.8}
  	else {this.CSS2 = 1; this.CSS1 = 0.6}
  	}
  else if (navigator.kin == 'Netscape/4') {this.CSS2 = 0.5; this.CSS1 = 0.3};  
  
    //Checking the style object
  
    if (document.body && document.body.style){
    	if (this.CSS2 < 0.5 || this.CSS1 < 0.3)
    		{
  		if (typeof document.body.style.background !='undefined' &&
  		typeof document.body.style.color !='undefined') { this.CSS2 = 0.5; this.CSS1 = 0.3}
  		}
  	if (this.CSS2 < 1 || this.CSS1 < 0.6)
  		{ //buggy with NC4
  		if (typeof document.body.style.backgroundColor !='undefined' &&
  		typeof document.body.style.backgroundImage !='undefined' &&
  		typeof document.body.style.width !='undefined') {this.CSS1+= 0.3;
  			if (typeof document.body.style.visibility !='undefined') this.CSS2+= 0.5}
  		}
  	if (this.CSS2 < 1.2 || this.CSS1 < 0.8)
  		{ //buggy with NC4 and IE4
  		if (typeof document.body.style.clear !='undefined') {if (this.CSS1 < 0.8) this.CSS1+= 0.2;
  			if (typeof document.body.style.zIndex !='undefined') this.CSS2+= 0.2}
  		}
  	if (this.CSS2 < 1.4 || this.CSS1 < 1)
  		{ //supported by IE5.5/Win, IE5/Mac, Netscape/5, Opera5
  		if (typeof document.body.style.cssFloat !='undefined' ||
  		typeof document.body.style.styleFloat !='undefined') {if (this.CSS1 < 1) this.CSS1+= 0.2;
  			if (typeof document.body.style.clip !='undefined') this.CSS2+= 0.2}
  		}
  	if (navigator._exami[6]){
        		if (this.CSS2 < 1.6)
        			{ 
        			if (typeof document.body.style.position !='undefined'){
        			var elementPos = document.createElement('div');
        			elementPos.style.position = 'absolute';
        			 if (elementPos.style.position == 'absolute'
        			 && typeof elementPos.style.left !='undefined'
        			 && typeof elementPos.style.top !='undefined') this.CSS2+= 0.2}
        			}
        		if (this.CSS2 < 1.8)
        			{ 
        			if (typeof document.body.style.maxWidth !='undefined'
        			 && typeof document.body.style.minHeight !='undefined') this.CSS2+= 0.2
        			}
        		if (typeof document.body.style.display !='undefined' && navigator.engine !='trident')
        		{ //NOTE: style.display chokes on IE, at least incl. prettyVersion 7
        		if (this.CSS2 > 1.7)
        			{ //checking tables
        			var elementTbl = document.createElement('table');
        			elementTbl.style.display = 'table';
        			if (elementTbl.style.display == 'table'
        			 && typeof elementTbl.style.tableLayout !='undefined'
        			 && typeof elementTbl.style.borderSpacing !='undefined'
        			 && typeof elementTbl.style.captionSide !='undefined') this.CSS2+= 0.1
        			}
        		if (this.CSS2 > 1.8)
        			{ //checking a rare value
        			var elementHdr = document.createElement('h1');
        			elementHdr.style.display = 'run-in';
        			if (elementHdr.style.display == 'run-in') this.CSS2+= 0.1
        			}
        		if (this.CSS2 > 1.9 && typeof document.body.style.cursor !='undefined')
        			{ //checking CSS 2.1 support
        			var element1 = document.createElement('p');
        			element1.style.display = 'inline-block';
        			var element2 = document.createElement('div');
        			element2.style.cursor = 'progress';
        			 if(element1.style.display == "inline-block" && 
        			 element2.style.cursor == "progress") this.CSS2+= 0.1 
        			}
        		}
        		}
    //Ending the style object check
        	}
  
  this.CSS1 = (Math.round(this.CSS1*10)/10);
  this.CSS2 = (Math.round(this.CSS2*10)/10);
  
/* THE SECTION BELOW MAY BE REMOVED IN THE NEXT VERSION OF THIS SCRIPT ****
 * HTML RENDERING MODES
   * Recent browsers are able to trigger a *standards* mode if dealing with HTML4.01 and referring
   * to the W3C DTD URI. Those browsers are attached with the "envir.standards" property. In order
   * not to exclude competent browsers, which use odd ways of identifying themselves, the decision
   * on this property should be lax, and therefore it's spoofable to some extent. The non-spoofable 
   * equivalent property is "envir.strict", which applies to HTML4.01 Strict and CSS level 2 
   * reasonably compliant applications. 
   */  
    //the 21st Century DOM browsers come here -
    //compliant with W3C Frameset and Transitional HTML4.01 and DTD URI reference -
    //NOTE: Spoofing is possible in /standards/ but not in /strict/ -
    this.standards = (navigator._exami[8] >= 5);
  
    //compliant with W3C Strict HTML4.01 (i.e. HTML, which is not backwards compatible) -
    this.strict = (navigator._exami[5] && this.CSS2 >= 1.8 && typeof(document.compatMode)!='undefined');
   
    //the 20th Century DHTML browsers come here -
    //including Netscape Communicator -
    this.dhtml = (navigator._exami[8] >= 4);   
    //excluding Netscape Communicator -
    this.common = (this.dhtml && this.CSS1 == 1);
// THE SECTION FOR FUTURE REMOVAL ENDS.
  if (navigator._exami[2]){
    navigator.js = 1.3;
    var num = 1;
    if (num == 0){
      function NoFunc() {
      }} 
    else if (num == 1){
      function RealFunc() {
      }};
    if (typeof(RealFunc) =='function' && typeof(NoFunc) !='function') navigator.js = 1.5;
   }
    if (navigator.js == 1.5 && Array.indexOf && Array.every) navigator.js = 1.6;
  //Ending the js1.2 clause
 }
 //Ending the js1.1 clause
 }
 else this.noenvir = true;
//Envir ends
}
var envir;
