How to use Java script in HTML Snippet (or on a page?)

How to use Java script in HTML Snippet (or on a page?)

Want to add some java script to a page. Any way to do this? Basically need to drag one image to another spot. Will also need to update a field in the record... but that will be the next step (and extra credit if you provide pointers on that!). For now, just need to get the drag and drop to work. 

<style>
#div1, #div2, #div3 {
  float: left;
  width: 100px;
  height: 35px;
  margin: 10px;
  padding: 10px;
  border: 1px solid black;
}
</style>
<script>
function allowDrop(ev) {
  ev.preventDefault();
}

function drag(ev) {
  ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {
  ev.preventDefault();
  var data = ev.dataTransfer.getData("text");
  ev.target.appendChild(document.getElementById(data));
}
</script>
<body>

<h2>Drag and Drop</h2>
<p>Drag the image back and forth between the two div elements.</p>

<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
  <%=urlstring%>
</div>

<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>

<div id="div3" ondrop="drop(event)" ondragover="allowDrop(event)"></div>