/*
This library handles flash and shockwave detection for Plugins and ActiveX controls.

For activeX detection the detection_axdetect.vbs script should also be included in the page.
*/

//***************************
// Start player detection

//***************************
// Netscape detection,
// returns the version of Shockwave plugin found or 0.0

function detection_flashVersion()
{
	return (browser_ie() && !browser_mac())
		? detection_flashAxVersion()
		: detection_flashNsVersion();
}

//***************************
// Netscape detection,
// returns the version of Shockwave plugin found or 0.0

function detection_flashNsVersion()
{
  // this function returns a floating point value which should be the version of the Shockwave plugin or 0.0
  // this function only returns useful information if called from Netscape or IE Mac 5.0+

  // Set these local variables to avoid the Netscape 4 crashing bug.
  var thearray = navigator.plugins
  var arraylen = thearray.length

  // Step through each plugin in the array.
  for (var i=0; i < arraylen; i++) {
    // Set these local variables to avoid the Netscape 4 crashing bug.
    theplugin = thearray[i]
    thename   = theplugin.name
    thedesc   = theplugin.description

    // If the plugin is Flash...
    if (thename.indexOf("Shockwave") != -1 && thename.indexOf("Flash") != -1)
    {
		var versionString = thedesc.substring(thedesc.indexOf("Flash ") + 6);
		
		// Look for an " r".  Whatever's after the "r" is the minor version. For
		// example, "Flash 4.0 r12" is minor release 12 of Flash 4.
		var versionLoc = versionString.indexOf(" r");
		
		if (versionLoc != -1)
		{
			// If there is an "r", then everything before the " r" is the major version...
			var versionMajor = versionString.substring(0,versionLoc);
			
			// ...and everything after is the minor version.
			var versionMinor = parseInt(versionString.substring(versionLoc + 2));
			
			// pad with zeroes
			if (versionMinor < 10) versionMajor += "0";
			
			// Format the final version string as x.xyy where x.x is the major version
			// and yy is the minor release version.
			
			return parseFloat(versionMajor + versionMinor);
		}
		else return parseFloat(versionString);
    }
  }
  
  return 0.0;
}

function detection_flashAxVersion(){
	// This function returns a floating point value which should 
	// be the version of the Shockwave control or 0.0.
	// This function should only be called from Internet Explorer
	// for Windows.

    // loop backwards through the versions until we get a bite
	for (var i=8;i>0;i--){
		var versionNum = VBGetFlashVersion(i);
		if (versionNum != 0){
			var versionMajor = Math.floor(versionNum / 65536);
			var versionMinor = versionNum % 65536;
			var versionMiddle = ".";
			for (var i=100;i>5;i/=10) if (versionMinor < i) versionMiddle += "0";
			return parseFloat(versionMajor + versionMiddle + versionMinor);
		}
	}
	return 0.0;
}


//***************************
// Do the detection

//if (!document.sw_skipEntry)
//{
//	detection_siteEntry();
//}
