
function getElementPosition(elem)
{

    var w = elem.offsetWidth;
    var h = elem.offsetHeight;

    var l = 0;
    var t = 0;

    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {
        "left":l,
        "top":t,
        "width":w,
        "height":h
    };
}

function getOpacityProperty()
{
  if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
    return 'opacity';
  else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 и младше, Firefox 0.8
    return 'MozOpacity';
  else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
    return 'KhtmlOpacity';
  else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
    return 'filter';

  return false; //нет прозрачности
}

function setElementOpacity2(elem, nOpacity)
{
  var opacityProp = getOpacityProperty();


  if (!elem || !opacityProp) return; // Если не существует элемент с указанным id или браузер не поддерживает ни один из известных функции способов управления прозрачностью

  if (opacityProp=="filter")  // Internet Exploder 5.5+
  {
    nOpacity *= 100;

    // Если уже установлена прозрачность, то меняем её через коллекцию filters, иначе добавляем прозрачность через style.filter
    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; // Для того чтобы не затереть другие фильтры используем "+="
  }
  else // Другие браузеры
    elem.style[opacityProp] = nOpacity;
}

//
//
//e = document.getElementById("servicetext0");
//window.setTimeout(ChangeOpacity, 40, e, 1.0, -0.1);
//

function FlowProccess(p_IdCell, p_IdBox)
{
    this.m_CellObject = document.getElementById(p_IdCell);
    this.m_BoxObject = document.getElementById(p_IdBox);
    this.m_State = "Start";

    this.m_TimeCircle = 36000.0;
    this.m_TimeStep = 100.0;

    this.m_GlobalNumber = 0;

    this.m_Opacity = 0.0;

    this.Work = function()
    {
        switch (this.m_State)
        {
            case "Start":
            {
                this.Start();
                //setTimeout(Worker, 0, this);
                setTimeout("Worker(g_DivServiceList[" + this.m_GlobalNumber + "])", 0);
                break;
            }
            case "Flow":
            {
                this.Flow();
                //setTimeout(Worker, this.m_TimeStep, this);
                setTimeout("Worker(g_DivServiceList[" + this.m_GlobalNumber + "])", this.m_TimeStep);
                break;
            }
            case "Finish":
            {
                this.Finish();
                //setTimeout(Worker, this.m_TimeCircle, this);
                setTimeout("Worker(g_DivServiceList[" + this.m_GlobalNumber + "])", this.m_TimeCircle);
                break;
            }
        }
    }

    this.Start = function()
    {
        kc = getElementPosition(this.m_CellObject);

        this.m_BoxObject.style.left = "" + kc.left + "px";
        this.m_BoxObject.style.top =  "" + kc.top + "px";
        this.m_BoxObject.style.width =  "" + kc.width + "px";

        this.m_BoxObject.style.position="absolute";
        this.m_BoxObject.style.display="inline";

        this.m_BoxObject.style.left = "" + kc.left + "px";
        this.m_BoxObject.style.top =  "" + kc.top + "px";
        this.m_BoxObject.style.width =  "" + kc.width + "px";
        this.m_BoxObject.style.zIndex =  "4";

        setElementOpacity2(this.m_BoxObject, 0.0);
        this.m_Opacity = 0.0;

/*
        this.m_CellObject.style.left = "" + kc.left + "px";
        this.m_CellObject.style.top =  "" + kc.top + "px";
        this.m_CellObject.style.width =  "" + kc.width + "px";
*/
        this.m_CellObject.style.zIndex =  "3";

        this.m_State = "Flow";
    }

    this.Flow = function()
    {
        this.m_Opacity = this.m_Opacity + 0.1;
        if(1.0 < this.m_Opacity)
        {
            this.m_Opacity = 1.0;
            this.m_State = "Finish";
        }

        setElementOpacity2(this.m_BoxObject, this.m_Opacity);
        setElementOpacity2(this.m_CellObject, 1.0 - this.m_Opacity);
    }


    this.Finish = function()
    {
        this.m_CellObject.innerHTML = this.m_BoxObject.innerHTML;
        this.m_BoxObject.style.display="none";
        setElementOpacity2(this.m_CellObject, 1.0);
        
        
        this.m_State = "Start";

    }
}

function Worker(t)
{
    t.Work();
}

var g_DivServiceList = new Array();

//function LineProccess