1 - Something like this?
function slideIt(divToSlide) {
if (parseInt(divToSlide.style.left) < stopPosition) {
divToSlide.style.left = parseInt(divToSlide.style.left) + 2 + "px";
setTimeout(slideIt, 1);
active = true;
}
}
Not sure what active is doing.
2 - Push all the elements that are animated into an array. When you expand one, collapse the others.
function slideIt(divToSlide) {
for(var d in slidingDivs) {
if(d != divToSlide) collapseDiv(d);
}
...
}
3 - There are a few ways you could tackle this. Keep track of the state and check the state in your click handler.