I am decent web designer with limited scripting skills. Some Perl, but basically a Javascript novice.

I need to have an image inside a html table automatically swap with another image with a timed delay when the page loads without any user input.

working page without table:

www.ezsleeptravel.com/test2.html

I downloaded the following script and modified it to run my images. It works alone on a page, but I can't get it to work with the images inside a table:


Code:

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
// by Vic Phillips (02-11-2005) http://www.vicsjavascripts.org.uk/

var zxcFCnt=0;

function ToggleImage(objid,img,time){
if (typeof(objid)=='string'){ objid=document.getElementById(objid); }
if (!objid.toggle){
objid.toggle=new zxcAddFunctions(objid);
objid.toggle.one=objid.src;
objid.toggle.two=img;
objid.toggle.delay=time;
objid.toggle.auto();
return;
}
if (objid.toggle.run){
clearTimeout(objid.toggle.to);
objid.toggle.run=false;
}
else {
objid.toggle.run=true;
objid.toggle.auto();
}
}

function zxcAddFunctions(zxc){
this.mobj=zxc;
this.ref='auto'+zxcFCnt;
window[this.ref]=this;
this.run=true;
this.to=null;

this.setTimeOut= function(zxcf,zxcd){
this.to=setTimeout('window.'+this.ref+'.'+zxcf,zxcd);
}

this.auto=function(){
if(this.run){
this.setTimeOut('auto();',this.delay);
if (this.mobj.src==this.one){
this.mobj.src=this.two;
}
else {
this.mobj.src=this.one;
}
}
}

zxcFCnt++;
}


//-->
</script>

</head>

<body onload="ToggleImage('Img1','http://www.ezsleeptravel.com/images/Animation1.jpg',4000);" >

<img id="Img1" src="http://www.ezsleeptravel.com/images/Animation2.jpg" alt="Contact Us" width="588" height="422" border="0" id="contact"
onclick="ToggleImage(this,'http://www.vicsjavascripts.org.uk/StdImages/Two.gif',2000);"
/>

<br>



</body>

</html>


Destination page single image (no swap):

www.ezsleeptravel.com


This is probably pretty easy for anyone with moderate scripting skills, so anyone with any input would be greatly appreciated.

Also, if there is an easier way to do this, please let me know. Thanking you in advance.