Code:
<html>
<head>
</head>
<body>
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" id="slide" width="601" height="355" alt="Healthy Mix" />
<script>
<!--
var Images=[
'http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt7.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt8.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt9.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt10.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt11.jpg',
'http://www.vicsjavascripts.org.uk/StdImages/Egypt12.jpg'
];
function slideit(id,ary,hold,ms){
var o=slideit[id],rdy,z0=0,img,p;
if (!o){
img=document.createElement('IMG');
img.style.position='absolute';
img.style.zIndex='101';
img.style.left='-3000px';
img.style.top='-3000px';
document.body.appendChild(img);
o=slideit[id]={
id:id,
obj:document.getElementById(id),
img:img,
ary:[],
hold:typeof(ms)=='number'&&hold>0?hold:2000,
ms:typeof(ms)=='number'&&ms>0?ms:1000,
cnt:0
}
for (;z0<ary.length;z0++){
o.ary[z0]=new Image();
o.ary[z0].src=ary[z0];
}
}
if (o&&o.obj&&o.ary[o.cnt]){
clearTimeout(o.to);
rdy=o.ary[o.cnt]&&o.ary[o.cnt].width>40;
if (rdy){
p=pos(o.obj);
zxcOpacity(o.img,0);
o.img.style.width=o.obj.width+'px';
o.img.style.height=o.obj.height+'px';
o.img.style.left=p[0]+'px';
o.img.style.top=p[1]+'px';
o.img.src=o.ary[o.cnt].src;
animate(o,0,100,new Date(),o.ms);
}
else {
o.cnt=++o.cnt%o.ary.length;
o.to=setTimeout(function(){ slideit(id); },200);
}
}
}
function animate(o,f,t,srt,mS){
var ms=new Date()-srt,n=(t-f)/mS*ms+f;
clearTimeout(o.dly);
if (isFinite(n)){
zxcOpacity(o.img,n);
}
if (ms<mS){
o.dly=setTimeout(function(){ animate(o,f,t,srt,mS); },10);
}
else {
zxcOpacity(o.img,2);
o.obj.src=o.img.src;
o.img.style.top='-3000px';
o.cnt=++o.cnt%o.ary.length;
o.to=setTimeout(function(){ slideit(o.id); },o.hold);
}
}
function zxcOpacity(obj,opc){
obj.style.filter='alpha(opacity='+opc+')';
obj.style.opacity=obj.style.MozOpacity=obj.style.WebkitOpacity=obj.style.KhtmlOpacity=opc/100-.001;
}
function pos(obj){
var rtn=[0,0];
while(obj){
rtn[0]+=obj.offsetLeft;
rtn[1]+=obj.offsetTop;
obj=obj.offsetParent;
}
return rtn;
}
// parameter 0 = the unique ID name of the image. (string)
// parameter 1 = an array of image SRCs. (array)
// parameter 2 = (optional) the auto 'hold' delay in milli seconds. (number, default = 2000)
// parameter 3 = (optional) the fade duration in milli seconds. (number, default = 1000)
slideit('slide',Images,2500,1000);
//-->
</script>
</body>
</html>
Bookmarks