Contract all, works fine.
But expand all, has error (Object required) and not working :(
I dont know js syntax, but in php it would be something like this:
onclick="for($i=0; $i<$n; $i++) {echo "expandcontent('sub'.$i.');"}";

In ohter words, i need to optimize
onclick="expandcontent('sub1');expandcontent('subn-1');expandcontent('subn');expandcontent('subn+1');"