// Get screen resolution
var screenHeight = screen.height;
var screenWidth = screen.width;

// Detect flash version
// This script will test up to the following version.
flash_versions = 20;

// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';

// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length) {
   for (x=0; x < navigator.plugins.length; x++) {
      if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
         flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
         flash.installed = true;
         break;
      }
   }
}
// Then, dig through ActiveX-style plug-ins afterward
else if (window.ActiveXObject) {
   for (x = 2; x <= flash_versions; x++) {
      try {
         oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
         if(oFlash) {
            flash.installed = true;
            flash.version = x + '.0';
         }
      }
      catch(e) {}
   }
}
//if none of the above is avail check the MIME types, unfortunately the MIME types cannot tell us what version
//of flash a user has installed, but it can detect an installation.
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	
	if (x && x.enabledPlugin){
	   flash.installed = true;
	   flash.version = 'unknown';
   }
}


// Do XMLHTTPRequest
var req;

function loadXMLDoc(url) {
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       req.open("GET", url, true);
       req.send(null);
   // branch for IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
       req = new ActiveXObject("Microsoft.XMLHTTP");
       if (req) {
           req.open("POST", url, true);
           req.send();
       }
   } else {
      if (document.body) {
         document.body.innerHTML += '<img src="'+url+'&showImg=1" height="0" width="0" />';
      }
      else if (docRef = document.getElementsByTagName("body").item(0)) {
         docRef.innerHTML += '<img src="'+url+'&showImg=1" height="0" width="0" />';
      }
   }
}

var URL = window.location.protocol+"//"+window.location.host+"/misc/detect.php?jsEnabled=1&flashVersion=" + 
   flash.version + "&scrH=" + screenHeight+"&scrW=" + screenWidth;

loadXMLDoc(URL);

