the code is unneccessarily complex
<img src='image1.jpg' onmouseover='src="image2.jpg";' onmouseout='src="image1.jpg";'>
the only javascript required is to load the second image in the background after the page is loaded and displayed, so there is no mouseover delay
...snip ..
</body>
<script language="javascript" type="text/javascript">
//<![CDATA[
<!--
image2 = new Image();
image2.src = "image2.jpg";
//-->
//]]>
</script>
</html>