Try this instead! If im goin to make some slideShow (or image swapping) this is what i usually do. Its up to you if you wanna try my demo. I've provided different titles for every image that will get to be swapped.
<html>
<head>
<title>Arrays and Putting title on your swapped image</title>
<script type="text/javascript">
<!--
var i = 0;
function putTitle() {
var imgArray = [];
var img = document.getElementById('swap');
var myTitle = document.getElementById('imgTitle');
if (document.images) {
/* Total n# of images to be swapped or icremented in which 4 is my incrementing value on this demo. */
for (var x = 0; x < 4; x++) {
imgArray[x] = new Image();
/* You must provide a valid path and a sequential n# with your images filename (e.g. image1, image2, image3, and so on...). */
imgArray[x].src = 'image' + x + '.jpg'; }
if (imgArray.length > 1) {
img.src = imgArray[i].src;
i++;
}
} switch(i) {
case 1 : img.title = 'Title1'; break;
case 2 : img.title = 'Title2'; break;
case 3 : img.title = 'Title3'; break;
case 4 : img.title = 'Title4'; break;
default : img.title = 'Original Title'; break; }
myTitle.innerHTML = img.title;
i = ( i == 4 ) ? 0 : i;
}
//-->
</script>
</head>
<body>
<img src="image.jpg" id="swap">
<button onclick="putTitle();">Click</button>
<!-- Let's see the title output of every image on the swapping sequence, by showing their title on the div below -->
<div id="imgTitle">Current Title Of Your Image</div>
</body>
</html> Hope you find this usefull...