// Title       : h.com Flash-Detection for non IE-Browsers
// Description : Use to detect if flash is installed.
// Version     : 1.0
// Date        : 2005-03-18
// CVS-Info    : $Id: flashdetect.js,v 1.1 2009-12-16 13:14:08 karlb Exp $

var hcomFlashControlInstalled;     // Variable, set by an VB-Script. Info, if ActiveX is installed
var hcomFlashControlVersion;       // Version of the ActiveX

function FlashInfoObject() {
  this.FlashDetectedSelf = function () { return (document.cookie.indexOf("MM_FlashDetectedSelf") != -1); }

  if(navigator.plugins && navigator.plugins.length > 0) {
    this.implementation = "Plug-in";
    this.autoInstallable = false;       // until Netscape SmartUpdate supported
    // Check whether the plug-in is installed:

    if (navigator.plugins["Shockwave Flash"]) {
      this.installed = true;
      // Get the plug-in version and revision:
      var words = navigator.plugins["Shockwave Flash"].description.split(" ");
      for(var i = 0; i < words.length; ++i) {
        if(isNaN(parseInt(words[i]))) continue;
        this.version = words[i];
        this.revision = parseInt(words[i + 1].substring(1));
      }
    } else {
      this.installed = false;
    }
  } else if (hcomFlashControlInstalled != null) {
    this.implementation = "ActiveX control";
    this.installed = hcomFlashControlInstalled;
    this.version = hcomFlashControlVersion;
    this.autoInstallable = true;
  } else if(this.FlashDetectedSelf()) {
    this.installed = true;
    this.implementation = "Plug-in";
    this.autoInstallable = false;
  }

  this.canPlay = function (contentVersion, requireLatestRevision) {
    var canPlay;
    if(this.version) {
      canPlay = (parseInt(contentVersion) <= this.version);
      if(requireLatestRevision) {
        if (this.revision && this.revision < MM_FlashLatestPluginRevision(this.version)) {
          canPlay = false;
        }
      }
    } else {
      canPlay = MM_FlashDetectedSelf();
    }
    return canPlay;
  }

  this.FlashRememberIfDetectedSelf = function (count, units) {
    // the sniffer appends an empty search string to the URL
    // to indicate that it is the referrer
    if (document.location.search.indexOf("?") != -1) {
      if(!count) count = 60;
      if(!units) units = "days";
      var msecs = new Object();
      msecs.minute = msecs.minutes = 60000;
      msecs.hour = msecs.hours = 60 * msecs.minute;
      msecs.day = msecs.days = 24 * msecs.hour;
      var expires = new Date();
      expires.setTime(expires.getTime() + count * msecs[units]);
      document.cookie = 'MM_FlashDetectedSelf=true ; expires=' + expires.toGMTString();
    }
  }

  this.FlashUserDemurred = function () { return (document.cookie.indexOf("MM_FlashUserDemurred") != -1); }

  this.FlashDemur = function (count, units) {
    if (!count) count = 60;
    if (!units) units = "days";
    var msecs = new Object();
    msecs.minute = msecs.minutes = 60000;
    msecs.hour = msecs.hours = 60 * msecs.minute;
    msecs.day = msecs.days = 24 * msecs.hour;
    var expires = new Date();
    expires.setTime(expires.getTime() + count * msecs[units]);
    document.cookie = 'MM_FlashUserDemurred=true ; expires=' + expires.toGMTString();
    if(!this.FlashUserDemurred()) {
      alert("Your browser must accept cookies in order to save this information.  Try changing your preferences.");
      return false;
    }
    return true;
  }
}


