This script and the ones below it I would have pulled out into an external javascript file:

```
<script src="templates-page.js" type="text/javascript"></script>
```