some javascript chicanery