function detectFlash()
{
  var flashVersion = -1;
  if(navigator.plugins.length > 0)
  {
    if (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash'])
    {
      var isVersion2 = navigator.plugins['Shockwave Flash 2.0'] ? ' 2.0' : '';
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var nPos = flashDescription.indexOf('.');
      if(nPos >= 0)
        flashVersion = parseInt(flashDescription.substring(nPos-2, nPos));
      //flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf('.') - 1));
    }
  }
  return flashVersion;
}

function ControlVersion()
{
  var flashVersion = -1;
  var axo;
  var e;
  
  flashVersion = detectFlash();
  if(flashVersion < 1)
  {
		try
		{
		  axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.10");
		  flashVersion = 10;
		}
		catch (e) {}
  }
  if(flashVersion < 1)
  {
		try
		{
		  axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.9");
		  flashVersion = 9;
		}
		catch (e) {}
  }

  if(flashVersion < 1)
  {
    try
    {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");
      flashVersion = 8;
    }
    catch (e) {}
  }
  if(flashVersion < 1)
  {
    try
    {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
      flashVersion = 7;
    }
    catch (e) {}
  }
  if(flashVersion < 1)
  {
    try
    {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
      flashVersion = 6;
    }
    catch (e) {}
  }

  if(flashVersion < 1)
  {
    try 
    {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.5");
      flashVersion = 5;
    }
    catch (e) {}
  }

  if(flashVersion < 1)
  {
    try
    {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
      flashVersion = 3;
    }
    catch (e) {}
  }

  if(flashVersion < 1)
  {
    try
    {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      flashVersion = 2;
    }
    catch (e) {}
  }
  return flashVersion;
}

function showFlash(flashurl, width, height, bgcolor, transparent, sNoFlash)
{
  var flashVersion =  ControlVersion();
  var sFlashCode = '';
  if(flashVersion > 0)
  {
    sFlashCode = '<OBJECT id="inside" name="inside1" align="top"';
    sFlashCode += ' width=' + width + ' height=' + height;
    sFlashCode += ' type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"';
    sFlashCode += '>\r\n';
    if(transparent) sFlashCode += '<PARAM name="wmode" value="transparent"></PARAM>\r\n';
    sFlashCode += '<PARAM name="movie" value="' + flashurl + '"></PARAM>\r\n';
    sFlashCode += '<PARAM name="quality" value="high"></PARAM>\r\n';
    if(bgcolor > '') sFlashCode += '<PARAM name="bgcolor" value="' + bgcolor + '"></PARAM>\r\n';
    sFlashCode += '<PARAM name="scale" value="exactfit"></PARAM>\r\n';
    sFlashCode += '<PARAM name="menu" value="false"></PARAM>\r\n';
    sFlashCode += '<EMBED src="' + flashurl + '"';
    if(transparent) sFlashCode += ' wmode="transparent"';
    sFlashCode += ' scale="showall" menu="false" quality="high"';
    if(bgcolor > '') sFlashCode += ' bgcolor="' + bgcolor + '"' 
    sFlashCode += '  WIDTH="' + width + '" HEIGHT="' + height + '" scale="exactfit" TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
    sFlashCode += '</EMBED>\r\n</OBJECT>';
  }
  else
  {
    sFlashCode = sNoFlash;
  }
  document.write(sFlashCode);
}

function writeFlash(p) 
{
  var flashVersion =  ControlVersion();
  var sImg = p.altimg;
  if(flashVersion > 0 || sImg == '')
  {
	  writeEmbed('D27CDB6E-AE6D-11cf-96B8-444553540000', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', 'application/x-shockwave-flash', p);
	}
	else
	{
	  var nHeight = p.height;
	  var nWidth = p.width;
	  var s = '<img src="' + sImg + '" width="' + nWidth + '" height="' + nHeight + '"/>';
	  document.write(s);
	}
}

function writeShockWave(p) 
{
	writeEmbed('166B1BCA-3F9C-11CF-8075-444553540000', 'https://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0', 'application/x-director', p);
}

function writeQuickTime(p)
{
	writeEmbed('02BF25D5-8C17-4B23-BC80-D3488ABDDC6B', 'https://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0', 'video/quicktime', p);
}

function writeRealMedia(p) 
{
	writeEmbed('CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', 'audio/x-pn-realaudio-plugin', p);
}

function writeWindowsMedia(p) 
{
	p.url = p.src;
	writeEmbed('6BF52A52-394A-11D3-B153-00C04F79FAA6', 'https://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701', 'application/x-mplayer2', p);
}

function writeEmbed(cls, cb, mt, p) 
{
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? ' id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? ' name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? ' width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? ' height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? ' align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '" />';
	h += '<embed type="' + mt + '"';
	for (n in p)
		h += n + '="' + p[n] + '" ';
	h += '></embed>';
	h += '</object>';
	document.write(h);
}
