Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<img id="img1" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" onmouseup="zxcImageRotate.Swap('img1');"/>
<a id="img1Page" ></a>
<br />
<br />
<input type="button" name="" value="GoTo 1" onmouseup="zxcImageRotate.Swap('img2',0);" />
<input type="button" name="" value="GoTo 2" onmouseup="zxcImageRotate.Swap('img2',1);" />
<input type="button" name="" value="GoTo 3" onmouseup="zxcImageRotate.Swap('img2',2);" />
<br />
<a>
<img id="img2" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img"
onmouseover="zxcImageRotate.Pause('img2');"
onmouseout="zxcImageRotate.Auto('img2');"
onmouseup="zxcImageRotate.Swap('img2');"
/>
</a>
<br />
<a id="img2Page" ></a>
<br />
<a id="img2Caption" ></a>
<br />
<br />
<script type="text/javascript">
/*<![CDATA[*/
var zxcImageRotate={
init:function(o){
var oop=this,id=o.ID,ary=o.Array,ms=o.AutoRotate,srt=o.AutoStart,img=document.getElementById(id),p=document.getElementById(id+'Page'),t=document.getElementById(id+'Caption'),lk=img.parentNode,z0=0;
for (;z0<ary.length;z0++){
ary[z0][5]=new Image();
ary[z0][5].src=ary[z0][0];
}
o=zxcImageRotate['zxc'+id]={
img:img,
p:p,
t:t,
lk:lk,
ary:ary,
ms:typeof(ms)=='number'?ms:2000,
cnt:0
}
this.page(o);
this.title(o);
if (typeof(srt)=='number'){
this.Auto(id,srt);
}
},
Swap:function(id,nu){
var o=zxcImageRotate['zxc'+id];
if (o){
this.Pause(id);
if (o.ary[nu]){
o.cnt=nu;
}
else {
o.cnt=++o.cnt%o.ary.length;
}
if (o.ary[o.cnt][5].width>40){
o.img.removeAttribute('title');
if (o.ary[o.cnt][1]){
o.img.title=o.ary[o.cnt][1];
}
o.lk.removeAttribute('href');
if (o.ary[o.cnt][3]){
o.lk.href=o.ary[o.cnt][3];
}
o.img.src=o.ary[o.cnt][0];
this.page(o);
this.title(o);
if (nu===true){
this.Auto(id,o.ms);
}
}
else {
this.Swap(id);
}
return false;
}
},
Auto:function(id,ms){
var oop=this,o=zxcImageRotate['zxc'+id];
if (o){
o.to=setTimeout(function(){ oop.Swap(id,true); },ms||200);
}
},
Pause:function(id){
var o=zxcImageRotate['zxc'+id];
if (o){
clearTimeout(o.to);
}
},
page:function(o){
if (o.p){
o.p.innerHTML=(o.cnt+1)+' of '+o.ary.length;
}
},
title:function(o){
if (o.t){
o.t.innerHTML=o.ary[o.cnt][2]||'';
}
}
}
zxcImageRotate.init({
ID:'img1',
Array:[
['http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg'],
['http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg'],
['http://www.vicsjavascripts.org.uk/StdImages/Egypt7.jpg']
]
});
zxcImageRotate.init({
ID:'img2',
Array:[ // an array of arrays defining the image SRCs and titles. (array)
// field 0 = the image SRC.
// field 1 = (optional) the image title.
// field 2 = (optional) the image caption.
// field 3 = (optional) the image parent link HREF.
['http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg','Image 1','Caption 1'],
['http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg','Image 2','Caption 2','http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg'],
['http://www.vicsjavascripts.org.uk/StdImages/Egypt7.jpg','Image 3','Caption 3']
],
AutoRotate:2000, //(optional) the auto rotate 'hold' delay. (number, default = 2000)
AutoStart:1000 //(optional) the auto rotate 'start' delay on initialization. (number, default = no auto start)
});
/*]]>*/
</script>
</body>
</html>
Bookmarks