I had a working smoothtoogle function that was originally created to slide down or up an element, and I changed successfully to change the width.

I wanted to change it to work with any property, so I passed a "prop" value to the function with the name of the property I want to change.

Now the script only jumps to the last position, so the "reading" of the final property (set in html) is working, but not the motion loop.

this is the code, and I think the problem is the "obj[objname].style[propr[objname]]" property doesn't exist in the DOM.

(if that's the problem) How do I target a dynamically named property? (i.e. not "width" but "dynamicProperty" which contains 'width')

Thanks.

Code:
var timerlen = 5;
var slideAniLen = 300;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endValue = new Array();
var moving = new Array();
var dir = new Array();
var propr = new Array();

function smoothtoogle (trigBut, propr){
if(document.getElementById(trigBut).style.display == 'none') {
			slidedown(trigBut, propr)
	} else {
			slideup(trigBut, propr)
	}
}


function slidedown(objname,propr){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; // cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}

function slideup(objname,propr){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "none")
                return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}

function startslide(objname,propr){
        obj[objname] = document.getElementById(objname);

        endValue[objname] = parseInt(obj[objname].style[propr[objname]]);
        startTime[objname] = (new Date()).getTime();

        if(dir[objname] == "down"){
                obj[objname].style[propr[objname]] = "1px";
        }

        obj[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname,propr){
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endValue[objname]);
                if(dir[objname] == "up")
                        d = endValue[objname] - d;

                obj[objname].style[propr[objname]] = d + "px";
        }

        return;
}

function endSlide(objname,propr){
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

        obj[objname].style[propr[objname]] = endValue[objname] + "px";

        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endValue[objname]);
        delete(obj[objname]);
        delete(dir[objname]);

        return;
}