Not an javascript expert either but found moving the script below the div worked with some slight changes.



<div id="canam">test</div>
<script language="javascript" type="text/javascript">...