﻿var IsPlayerVisible = false;
//var m = null;
var sitePath = 'http://www.photonic-instruments.com/';
var playerPath = sitePath + 'Player/uflvplayer.swf';
var moviesPath = sitePath + 'Movies/'

// Показать плеер
// Параметры:
// filePath - путь к flv-файлу
function ShowVideo(filePath, description)
{
    //var t = m == null;
    var divPlayer = GetElementByName("player_canvas");
    var divPlace = GetElementByName("player_place");
    var divDescr = GetElementByName("description_place");

    document.body.scrollTop = 0;

    var fullFilePath = moviesPath + filePath;

    playerPath = "http://flv-mp3.com/i/pic/uflvplayer_500x375.swf";

//    if (test.IE)
//    {
//        if (!t)
//        {
//            divPlace.removeChild(m);
//        }

//        m = document.createElement("object");
//        m.data = playerPath;
//        m.type = "application/x-shockwave-flash";
//        m.width = "364px";
//        m.height = "273px";
//        m.bgcolor = "#000000";
//        m.allowFullScreen = false;
//        m.allowScriptAccess = "always";
//        m.movie = playerPath;

//        m.FlashVars = "way=" + fullFilePath + "&amp;swf=" + playerPath + "&amp;w=364&amp;h=273&amp;pic=http://&amp;autoplay=1&amp;tools=1&amp;skin=black&amp;volume=70&amp;q=1&amp;comment=";

//        if (divPlace != null)
//            divPlace.appendChild(m);
//    }
//    else
//    {
        var playerAsString = '<object type="application/x-shockwave-flash" data="' + playerPath + '"';
        playerAsString += 'width="364" height="273">';
        playerAsString += '<param name="bgcolor" value="#FFFFFF" />';
        playerAsString += '<param name="allowFullScreen" value="false" />';
        playerAsString += '<param name="allowScriptAccess" value="always" />';
        playerAsString += '<param name="movie" value="' + playerPath + '" />';
        playerAsString += '<param name="FlashVars" value="way=' + fullFilePath + '&amp;swf=' + playerPath + '&amp;w=364&amp;h=273&amp;pic=http://&amp;autoplay=1&amp;tools=2&amp;skin=black&amp;volume=70&amp;q=1&amp;comment=" />';
        playerAsString += '</object>';

        if (divPlace != null)
            divPlace.innerHTML = playerAsString;
//    }

    if (divDescr != null)
    {
        var test = TestBrowser();
        if (test.IE)
            divDescr.previousSibling.style.width = "174px";
        divDescr.innerHTML = '<span style="font-size: 12px; color: Black;"><br><b>' + filePath.split('/')[0] + ':</b>&nbsp;' + description + '</span>';
    }

    SetDisplay(divPlayer, 'block');
    SetDisplay(divDescr, 'block');
}

function ClosePlayer()
{
    var divPlayer = GetElementByName("player_canvas");
    var divDescr = GetElementByName("description_place");

    SetDisplay(divPlayer, 'none');
    SetDisplay(divDescr, 'none');
}

// Получить размер окна браузера
function getScreenSize(s)
{
    if (s == SCREEN_X)
    {
        if (bIE)
            return document.body.offsetWidth;

        return window.innerWidth;
    }
    else
    {
        if (bIE)
            return document.body.offsetHeight;

        return window.innerHeight;
    }
}

//Размер документа по горизонтали
function getDocumentWidth()
{
    return (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth;
}

//Размер документа по вертикали
function getDocumentHeight()
{
    return (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
}

function getBodyScrollTop()
{
    return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getClientWidth()
{
    return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientWidth : document.body.clientWidth;
}

function getClientHeight()
{
    return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientHeight : document.body.clientHeight;
}