You will need to split this into two parts and use the HTML Snippet widget twice.
In the first part you would include your HTML in the Snippet with the HTML option checked.
In the second HTML snippet you would check Javascript and then include the Javascript code (without the script tags).
Hope this helps.