
function detect_setCps(band)
{
	var caps = new Array();
	caps[0] = detection_flashVersion();
	caps[1] = detection_shockwaveVersion();
	caps[2] = screen ? screen.width : 0;
	caps[3] = screen ? screen.height : 0;
	caps[4] = screen ? (browser_ie() ? screen.colorDepth : screen.pixelDepth) : 0;
	caps[5] = band ? band : 0;

	var brcps = "";

	for (var i=0;i<caps.length;i++) brcps += caps[i] + "_";

	util_setCookie("brcps",brcps);
}

/*
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_shockwaveVersion()
{
	return (browser_ie() && !browser_mac())
		? detection_shockwaveAxVersion()
		: detection_shockwaveNsVersion();
}

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

function detection_shockwaveNsVersion()
{
  // 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.
    var theplugin = thearray[i]
    var thename   = theplugin.name
    var thedesc   = theplugin.description

    // If the plugin is Shockwave...
    if (thename.indexOf("Shockwave") != -1 && thename.indexOf("Director") != -1)
    {
      var versionString = thedesc.substring(thedesc.indexOf("version ") + 8);
      
      if (versionString.indexOf(".") > 0)
      {
        var versionMajor = versionString.substring(0,versionString.indexOf("."));
        var versionMinor = versionString.substring(versionString.indexOf(".") + 1);
        
        if (versionMinor.indexOf(".") > 0)
        {
        	versionMinor = versionMinor.substring(0,versionString.indexOf(".")) 
        		+ versionMinor.substring(versionMinor.indexOf(".") + 1)
        }
        
        return parseFloat(versionMajor + "." + versionMinor);
      }
      
      else return parseFloat(versionString);
    }
  }
  
  return 0.0;
}

//***************************
// 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;
}

//***************************
// For detecting the ActiveX of shockwave for ie win.
// Requires a vbscript function be included on the page
// to do the actual checking returns version found or 0.0

function detection_shockwaveAxVersion()
{
	// 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 versionString = VBGetShockwaveVersion(i);
		// if we get 1.0 we assume it is actually 6.0 or less
		if (versionString != "0.0") return (versionString == "1.0" ? 6.0 : 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;
}

