function onMainPageLoad()
{
    var version = flashVersion();
    if (0 != version) {
        location.replace("index_fla.htm");
    }
}

function ShowFlashInput(el_id)
{
    var version = flashVersion();
    var elem = document.getElementById(el_id);
    if (elem)
        elem.style.display = (0 != version) ? "block" : "none";
    
    //    location.replace("index_fla.htm");
}

function ShowSpectrBlock(div2show)
{
    for (var i = 1; i <= 10; i++) {
        var id = "s" + i;
        var elem = document.getElementById(id);
        if( elem )
            elem.style.display = div2show == id ? "block" : "none";
    }        
}

////////////////////////////////////////
function ShowDivBlock(div2show, AllDivs)
{
    for (var i = 0; i < AllDivs.length; i++) {
        var elem = document.getElementById(AllDivs[i]);
        if( elem ) {
            elem.style.display = div2show == AllDivs[i] ? "block" : "none";
        }
    }        
}

//////////////////////////////
function bg_image(id, img_url)
{
   var elem  = document.getElementById(id);
   if(elem)
     elem.style.backgroundImage = img_url;
}

//////////////////////
function addFavorite()
{
    if(navigator.appName=="Netscape") {
        alert("К сожалению ваш браузер не поддерживает эту функцию. Нажмите клавиши 'Ctrl+D'");
    } 
    else    {
        window.external.AddFavorite('http://www.servicelab.ru','Компания СервисЛаб - научное и лабораторное оборудование');
    }
}

///////////////////
function showDate()
{
    var Now = new Date(); 
    var smin  = Now.getMinutes() < 10 ? "0" + Now.getMinutes() : Now.getMinutes();
    var smnth = Now.getMonth() < 10 ? "0" + Now.getMonth() : Now.getMonth();
    var elem  = document.getElementById("tddate");
    if(elem)
       elem.nodeValue = Now.getHours() + ":" + smin + "   " + Now.getDate()+ "-" + smnth + "-" + Now.getFullYear();
}

//////////////////
function printit()
{
    if (navigator.appName == "Netscape")    {
        window.print();
    } 
    else     {
        var WebBrowser = '<object id="WebBrowser1" width=0 height=0 classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser.ExecWB(6, 2);
    }
}

///////////////////////
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;
}
