﻿function FlashDetection_GetFlashVersion(){
  // ie
  try {
    try {
      // avoid fp6 minor version lookup issues
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  // other browsers
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}

function FlashDetection_IsFlashVersionSub10()
{
    var version = FlashDetection_GetFlashVersion().split(',').shift();
    
    if (version < 10)
    {
        return true;
    }
    else
    {
        return false;
    }
}


// Call from pages that absolutely require flash to work.
// If flash is not detected this will redirect to an error page.
function FlashDetection_PerformCriticalFlashCheck()
{
    if (FlashDetection_IsFlashVersionSub10())
    {
        $("body").hide();
        window.location = "/Pages/ErrorIncompatibleClientSettings/ErrorIncompatibleClientSettings.aspx?IncompatibilityType=2";
    }
    else
    {
        
    }
}

// Call from pages that use flash but the can still "work" without it.
// If flash is not detected it will show an error div on the page in the place of the flash content.
function FlashDetection_PerformNonCriticalFlashCheck(FlashDivID, ErrorDivID)
{
    if (FlashDetection_IsFlashVersionSub10())
    {
        $("#" + FlashDivID).hide();
        $("#" + ErrorDivID).show();   
    }
    else
    {
        $("#" + FlashDivID).show();
        $("#" + ErrorDivID).hide();
    }
}
