Adding javascript for loop into document.bplt causes page error