I'm using this script to randomly display a menu item. I would like to be able to use this throughout my document with the same array, just a random picture in each place. how could I modify this code to be able to do this? Currently, I'm using the script locally in the body. I would like to have a script in the head of the document and then use the array in different places. Here is the code:

Code:
<script type="text/javascript">
<!--
var imagesArray = new Array(
"image1.gif",
"image2.gif",
"image2.gif"
);
var index = Math.floor(Math.random() * imagesArray.length);
document.write("img src=" + imagesArray[index] + ".");
// -->
</script>
Thanks for any help!!!