﻿// used numbers in case of checking value from cookie (cookie returns false if it does not exist)
var PWM_SHOW_FLASH = 1;
var PWM_SHOW_TEXT = 2;
var pwm_default_showflash=PWM_SHOW_FLASH;
var plugin;
function PWM_Flash() {
 // set the default status
 this.showFlash=pwm_default_showflash;
};
PWM_Flash.prototype.init=function(){
 // check the flash player is installed
 var status = this.showFlash;
 if(!this.checkFlashPlayer()) {
  this.setStatus(PWM_SHOW_TEXT);
 }
 else {
  // check the query string - this will override the default value
  var querystring = document.location.href;
  var parameter = "showFlash=";
  if(querystring.indexOf(parameter)>0) {
   querystring = querystring.substring(querystring.indexOf(parameter)+parameter.length);
   if(querystring.length>1) {
    if(querystring.substring(0,1)=="f") {
     // show text
     this.setStatus(PWM_SHOW_TEXT);
    }
    else {
     // show flash
     this.setStatus(PWM_SHOW_FLASH);
    }
   }
  }
 }
};
PWM_Flash.prototype.setStatus=function(status) {
 this.showFlash = status;
};
PWM_Flash.prototype.getShowFlash=function() {
 return(this.showFlash==PWM_SHOW_FLASH);
};
PWM_Flash.prototype.showLayers=function() {
 var layer;
 var nlayer;
 if(this.getShowFlash()){
  layer = document.getElementById('flashLayer');
  layer.style.visibility = "visible";
  nlayer = document.getElementById('nonFlashLayer');
  nlayer.innerHTML = "";
 } else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
   nlayer = document.getElementById('nonFlashLayer');
   nlayer.style.visibility = "visible";
    layer = document.getElementById('flashLayer');
    layer.innerHTML = "";
 }else{
   nlayer = document.getElementById('nonFlashLayer');
   nlayer.style.visibility = "visible";
    layer = document.getElementById('flashLayer');
    layer.innerHTML = "";
 }
}
PWM_Flash.prototype.checkFlashPlayer=function() {
 plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
 if ( plugin ) {
   plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 6;
 }
 else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
  document.write('</SCRIPT\> \n');
 }
 return plugin;
}
var pwm_flashCheck=new PWM_Flash();