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; 
}

function showflashWH(flashName, W, H) {
    var bnFlash = flashName;
    var bnW = W;
    var bnH = H;
    var flashV = "6";
    flash_id = flashName.replace('/', '_');
    document.getElementById(flash_id).innerHTML = showflashJS(bnFlash, bnW, bnH, flashV);
}

function showLinkedFlashWH(flashName, W, H, link_href) {
    var divholder = document.createElement('a');
    divholder.style.position = "relative";
    divholder.style.display = 'block';
    divholder.style.width = W + "px";
    divholder.style.height = H + "px";
    divholder.style.top = "-" + H + "px";
    divholder.style.margin = "0px auto -" + H + "px auto";
    divholder.href = link_href;
    divholder.innerHTML = '<img src="/pics/1.gif" border="0" width="' + W + '" height="' + H + '">';
    showflashWH(flashName, W, H);
    flash_id = flashName.replace('/', '_');
    document.getElementById(flash_id).appendChild(divholder);
}

function showflash(flashName) {
    showflashWH(flashName, 200, 200);
}

function showPleaseWait(type) {
    if (type == 'show') {
        document.getElementById("please_wait").innerHTML = "Пожалуйста подождите<br>загрузка может занять<br>несколько секунд";    
    } else {
        document.getElementById("please_wait").innerHTML = "";
        return false;
    }
    setTimeout('showPleaseWait("hide")', 15000);
}

function showflashJS(bnFlash, bnW, bnH, flashV) {
    var ie = (navigator.userAgent && (navigator.userAgent.indexOf("MSIE") >= 0) && (navigator.appVersion.indexOf("Win") != -1)) ? 1 : 0;
    var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
    var ret = "";

    if(plugin){
        var version = flashVersion();
        var pluginVersion = parseInt(plugin.description.substring(plugin.description.indexOf(".") - 2));
        version = pluginVersion > version ? pluginVersion : version;
        var isPlay = (version >= flashV);
    }
    else if(ie){
        isPlay = true;
        ret += '<script type="text/vbscript"> \n';
        ret += 'on error resume next \n';
        ret += 'isPlay = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+flashV+'")) \n';
        ret += '</script> \n';
    }

    if(isPlay){
        ret += '<object type="application/x-shockwave-flash" data="'+bnFlash + '"';
        ret +=' width="'+bnW+'" height="'+bnH+'" ';
        ret +='>';
        ret +='<param name="movie" value="'+bnFlash;
        ret +='">';
        ret +='<param name="quality" value="high">';
        ret +='<param name="wmode" value="transparent">';
        ret +='</object>';
    }
    return ret;
}
