
flash = 0;

function flashVersion()
{
  // Отдельно определяем Internet Explorer
  var ua = navigator.userAgent.toLowerCase();
  var isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1);
  // Стартовые переменные
  var version = 0;
  var lastVersion = 10; // c запасом
  var i;

  if (isIE)
  { // browser == IE
    try
    {
      for (i = 3; i <= lastVersion; i++)
      {
        if (eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+i+'")'))
        {
          version = i;
        }
      }
    }
    catch(e){}
    }
    else
    { // browser != IE
      for (i = 0; i < navigator.plugins.length; i++)
      {
        if (navigator.plugins[i].name.indexOf('Flash') > -1)
        {
          version = (parseInt(navigator.plugins[i].description.charAt(16)) > version) ? parseInt(navigator.plugins[i].description.charAt(16)) : version;
        }
      }
    }

    return version;
}

flash = flashVersion();

function GetFlash(swf_file, swf_ver, width, height, loop, movid, link)
{
  var rnd = Math.round(Math.random() * 1000000000);
  var link_enc = escape(link).replace(/\\+/g,'%2B');

  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version='+swf_ver+',0,0,0" id="'+movid+'" width="'+width+'" height="'+height+'">');
  document.write('<param name="loop" value="'+loop+'">');
  document.write('<param name="movie" value="'+swf_file+'" />');
  document.write('<param name="wmode" value="transparent">');
  document.write('<param name="quality" value="high" />');
  document.write('<param name="FlashVars" value="rb_link='+link_enc+'" />');
  document.write('<embed name="'+movid+'" wmode="transparent" flashvars="rb_link='+link_enc+'" src="'+swf_file+'" quality="high" swLiveConnect="true" loop="'+loop+'" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgiP1_Prod_Version=ShockwaveFlash" />');
  document.write('</object>');
}


function thisMovie(movieName)
{
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if(navigator.appName.indexOf ("Microsoft") !=-1)
	{
    return window[movieName]
  }
	else
	{
    return document[movieName]
  }

  alert("Произошел вызов функции thisMovie c параметром "+movieName);
}


function PlayTopMenu(Action, ButtonName)
{
  if(Action == "over")
  {
    thisMovie(ButtonName).Play();
  }
  else
  {
    thisMovie(ButtonName).Play();
  }
}
