﻿//UTF-8 with Signature
// A few variables to help figure out what platform we're on
var ie  = (navigator.appName.toLowerCase().indexOf('microsoft') != -1);
var ns  = (navigator.appName.toLowerCase().indexOf('netscape') != -1);
var win = (navigator.platform.toLowerCase().indexOf('win') != -1);
var mac = (navigator.platform.toLowerCase().indexOf('mac') != -1);
var browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf('msie') + 4) : navigator.appVersion);
//
// do we have the version we need?
function testShockwave() {
   var bdetected = false;
   if (browserCanDetect()) {
	  bdetected = (win) ? detectShockwaveVerWin(8.5) : detectShockwaveVerMac(8.5);
   }
   if (!bdetected) {
      if (confirm(stringres['jsprompt03'])) {
         //window.open('http://www.macromedia.com/go/getshockwaveplayer/');
         //window.open('http://sdc.shockwave.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFull');
         window.open('http://www.adobe.com/shockwave/download/');
      }
   }
}
// will detection even work?
function browserCanDetect() {
   if (ie && win) return (browserVer >= 4.0) // Works in lower versions, but detection difficult.
   if (ie && mac) return (browserVer >= 5.0) // Works in lower versions, but can't do detection.
   if (ns && win) return (browserVer >= 3.0)
   if (ns && mac) return (browserVer >= 3.0)
   return false;
}
//
// windows shockwave detection
function detectShockwaveVerWin(nver) {
   var n;
   // this function returns a floating point value which should be the version of the Shockwave control or 0.0
	if (win) {
	   strver = getShockwaveVersionWin();
	   if (strver != '0.0') {
	      // if we get 1.0 we assume it is actually 6.0
	      n = (strver == '1.0' ? 6.0 : parseFloat(strver))
	      return (nver ? n >= nver : n);
	   }
   }
   return (nver ? false : 0.0);
}
//
// mac detection
function detectShockwaveVerMac(nver) {   // This function only returns useful information if called from Netscape or IE Mac 5.0+
   if (!navigator.plugins) return (nver ? false : 0.0); // IE Mac 4.5 and lower don't have a plugins array.
   // Set these local variables to avoid the Netscape 4 crashing bug.
   arr_plugs = navigator.plugins;
   arr_plugs_length = arr_plugs.length;
   // Step through each plugin in the array.
   for (i = 0; i < arr_plugs_length; i++) {
      // Set these local variables to avoid the Netscape 4 crashing bug.
      p = arr_plugs[i];
      p_name   = p.name;
      p_desc   = p.description;
      // if the plugin is Shockwave...
      if (p_name.indexOf('Shockwave') != -1 && p_name.indexOf('Director') != -1) {
         // ...extract the version information
         strver = p_desc.substring(p_desc.indexOf('version ') + 8);
         if (strver.indexOf('.') > 0) {
            versionMajor = strver.substring(0,strver.indexOf('.'));
            versionMinor = strver.substring(strver.indexOf('.') + 1);
            if (versionMinor.indexOf('.') > 0) {
               versionMinor = versionMinor.substring(0,strver.indexOf('.')) + versionMinor.substring(versionMinor.indexOf('.') + 1);
            }  
            strver = parseInt(versionMajor) + '.' + versionMinor;
         }
        return (nver ? (parseFloat(strver) >= nver) : parseFloat(strver));
      } 
   }
   return (nver ? false : 0.0);
}
//
//// If Shockwave not found, then return '0.0'
// Else return Shockwave version # xx.yy.zz
function getShockwaveVersionWin(){
	//// extract number xx.yy.zz from string
	// This routine filters out the revision # from the version #
	function getNum(A){
		var m = /[\d][\d\.]*/.exec(A);
		return m ? m[0] : null
	};
	// Find version for Navigator
	if (navigator.plugins && navigator.plugins.length > 0){
	    var i,m,p;
	    for(i=0;i<navigator.plugins.length;++i){
	        p = navigator.plugins[i];
	        if (p.name.indexOf('Director') != -1){
				return getNum(p.description)
			}
	    }
		return '0.0'; // Shockwave not installed on Navigator
	};
	//
	var obj=null,s,e;
	try{
		obj=new ActiveXObject("SWCtl.SWCtl")
	}
	catch(e){
		return '0.0';
	};
	if (obj!=null){
		s = obj.ShockwaveVersion("");
		if (typeof s == "string" && s.length>0){
	  		return getNum(s)
		}
	};
	//
	// SW versions < 8.5 do not allow ActiveXObject("SWCtl.SWCtl")
	// so we create object for each specific version
	try{ new ActiveXObject("SWCtl.SWCtl.8");return "8"}
	catch(e){}
	try{ new ActiveXObject("SWCtl.SWCtl.7");return "7"}
	catch(e){}
	try{ new ActiveXObject("SWCtl.SWCtl.1");return "6"}
	catch(e){}
	//
	return '0.0'; // Shockwave not installed on IE
};
