b-phase: Div Slider

Beitrag lesen

Hallo zusammen

ich habe da ein kleines Verständnisproblem, vielleicht (wahrscheinlich) kann mir jemand helfen. Eine Funktion klappt, die andere nicht, hier erst mal die funktionierende:

-----------------------------------------------------------------------------
function init(){
        if(document.getElementById){
        obj = document.getElementById("gallery");
        obj.style.top = "0";
        }
}

function slideDown(){
        if(document.getElementById){
                if(parseInt(obj.style.top) < 200){
        obj.style.top = parseInt(obj.style.top) + 2 + "px";
                        setTimeout("slideDown()",10);
                }
        }
}

<body onload="init()">

<a href="javascript:slideDown()">Galerie</a></div>

----------------------------------------------------------------------------

nun, die die nicht funktioniert:

function moveDown(target, pos){
obj = document.getElementById("gallery");
obj.style.top = pos;
        if(document.getElementById){
                if(parseInt(obj.style.top) < 200){
        obj.style.top = parseInt(obj.style.top) + 2 + "px";
                        setTimeout("slideDown()",10);
                }
        }
}

<a href="javascript:slideDown('gallery', '0')">Galerie</a></div>

----------------------------------------------------------------------------

Ich verliere sofort nach dem ersten Timerdurchlauf den ID-Tag, warum? Auch wenn ich diesen noch mal mit dem Timeout übergebe "setTimeout("slideDown('target', 'pos')",10)" wird das obj nicht mehr erkannt. Die erste Funktion definiert möglicherweise das obj als globale Variable oder? Ich möchte die Funktion eben auf verschiedene divs anwenden, wie schaffe ich das?

danke schon mal für eure Antwort