Do you really need to use ExpandLevel at client-side?
There's node.expand() client-side method.
Anyway, you can try to create a recursive function that uses expand() method to expand required number of levels.
Like this:
function expandNodes(node, level)
{
var childNodes = node.getChildNodes();
for(var i = 0; i < childNodes.length; i++)
{
var child = childNodes[i];
child.expand();
if (level > 1)
{
expandNodes(child, level - 1);
}
}
}