javascript for dynamic block generation