var aktiv = new Array(0,0,0,0,0,0,0,0,0,0);
var aktivd = new Array(0,0,0,0,0,0,0,0,0,0);
var maktiv = new Array(0,0,0,0,0,0,0,0,0,0);
var z = 0;
function kill_all()
{
    movedown('b1','t-rg.jpg');
    movedown('b2','t-kg.jpg');
    movedown('b3','t-at.jpg');
}
function movedown(id)
{
    var x = id.split("b")[1];
    if ((maktiv[x] != 2) && (parseInt(document.getElementById(id).style.top) < 0))
    {
        maktiv[x] = 2;
        window.clearInterval(aktivd[x]);
        aktivd[x] = window.setInterval("movedown1('"+id+"')",1);
    }
}
function movedown1(id)
{
    var x = id.split("b")[1];
    if ((parseInt(document.getElementById(id).style.top) < 0) && ((maktiv[x] == 2)))
    {
        if (parseInt(document.getElementById(id).style.height) < 5)
        {
            document.getElementById(id).style.height = "0px";
            document.getElementById(id).style.top = "0px";
        }
        else
        {
            document.getElementById(id).style.height = (parseInt(document.getElementById(id).style.height) -6) + "px";
            document.getElementById(id).style.top = (parseInt(document.getElementById(id).style.top) +6) + "px";
        }
        if (parseInt(document.getElementById(id).style.top) >= 0)
        {
            document.getElementById(id).style.top = "0px";
            document.getElementById(id).style.height = "0px";
            window.clearInterval(aktivd[x]);
            document.getElementById(id).style.paddingTop = "145px";
            maktiv[x] = 0;
        }
    }
}
function moveup(id)
{
    var x = id.split("b")[1];
    if ((maktiv[x] == 0) && (parseInt(document.getElementById(id).style.top) >= (-145)))
    {
        z++;
        if (x == 1)
        {
            movedown('b2','t-kg.jpg');
            movedown('b3','t-at.jpg');
        }
        if (x == 2)
        {
            movedown('b1','t-rg.jpg');
            movedown('b3','t-at.jpg');
        }
        if (x == 3)
        {
            movedown('b1','t-rg.jpg');
            movedown('b2','t-kg.jpg');
        }
        maktiv[x] = 1;
        window.clearInterval(aktiv[x]);
        aktiv[x] = window.setInterval("moveup1('"+id+"')",1);
    }
}
function moveup1(id)
{
    var x = id.split("b")[1];
    if (maktiv[x] == 1)
    {
        document.getElementById(id).style.height = (parseInt(document.getElementById(id).style.height) +6) + "px";
        document.getElementById(id).style.top = (parseInt(document.getElementById(id).style.top) -6) + "px";
        if ((parseInt(document.getElementById(id).style.top)+145) < 1)
        {
            document.getElementById(id).style.top = "-145px";
            document.getElementById(id).style.height = "145px";
            document.getElementById(id).style.paddingTop = "145px";
            window.clearInterval(aktiv[x]);
            maktiv[x] = 0;
        }
    }
}
