It is possible, what i'd do (bearing in mind that i am not very good at javascript) is while loop to close them all then open a single one. for example
function collapse(open) {
for (x=1;x<=[NUMBER_OF_PARAGRAPHS];x++) {
document.getElementById("objectname" + x).style.display = "none";
}
document.getElementById("objectname" + open).style.display = "inline";
}
Hope that helps!