Waterfall display in Javascript