Str
CODE:<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=windows-1251">
<title>Фотогалерея</title>
<script type="text/javascript">
<!--
var slideshows=
[
{
filesNames:
[
'image1.jpg',
'image2.jpg',
'image3.jpg',
'image4.jpg',
'image5.jpg'
],
links:
[
'image1.htm',
'image2.htm',
'image3.htm',
'image4.htm',
'image5.htm'
],
imagesPath: 'images/',
imgIdPrefix: 'image',
linksPath: '/',
linkIdPrefix: 'link',
current: 0,
activeImages: 3,
imagesShift: 2,
preloadedImages: null
},
{
filesNames:
[
'image1.jpg',
'image2.jpg',
'image3.jpg',
'image4.jpg',
'image5.jpg'
],
links:
[
'image10.htm',
'image20.htm',
'image30.htm',
'image40.htm',
'image50.htm'
],
imagesPath: 'slides/',
imgIdPrefix: 'slide',
linksPath: '/',
linkIdPrefix: 'slideLink',
current: 0,
activeImages: 3,
imagesShift: 1,
preloadedImages: null
}
];
function main()
{
var i, n;
for (n=0; n<slideshows.length; n++)
with (slideshows[n])
{
preloadedImages=new Array(filesNames.length);
for (i=0; i<filesNames.length; i++)
preloadedImages[i]=new Image();
preloadCurrent(n);
show(n);
setTimeout('preload('+n+')', 1000);
}
}
function hasSrc(image)
{
return image.src&&(image.src.lastIndexOf('.')>image.src.lastIndexOf('/'));
}
function preloadCurrent(n)
{
with (slideshows[n])
{
var i, src;
for (i=current; i<current+activeImages; i++)
if (!hasSrc(preloadedImages[i%preloadedImages.length]))
preloadedImages[i%preloadedImages.length].src=imagesPath+filesNames[i%preloadedImages.length];
}
}
function preload(n)
{
with (slideshows[n])
{
var i, currentLoads=0;
for (i=0; i<preloadedImages.length; i++)
if (hasSrc(preloadedImages[i])&&(!preloadedImages[i].complete))
currentLoads++;
for (i=current+activeImages; (currentLoads<activeImages)&&(i<preloadedImages.length); i++)
if (!hasSrc(preloadedImages[i]))
{
preloadedImages[i].src=imagesPath+filesNames[i];
currentLoads++;
}
for (i=0; (currentLoads<activeImages)&&(i<current); i++)
if (!hasSrc(preloadedImages[i]))
{
preloadedImages[i].src=imagesPath+filesNames[i];
currentLoads++;
}
for (i=0; i<preloadedImages.length; i++)
if (!hasSrc(preloadedImages[i]))
return setTimeout('preload('+n+')', 1000);
}
}
function back(n)
{
with (slideshows[n])
{
current-=imagesShift;
while (current<0)
current+=filesNames.length;
preloadCurrent(n);
show(n);
}
}
function forward(n)
{
with (slideshows[n])
{
current+=imagesShift;
while (current>=filesNames.length)
current-=filesNames.length;
preloadCurrent(n);
show(n);
}
}
function show(n)
{
with (slideshows[n])
{
var i, a;
for (i=current; (i-current)<activeImages; i++)
{
if (a=document.getElementById(imgIdPrefix+(i-current+1)))
a.src=preloadedImages[i%preloadedImages.length].src;
if (a=document.getElementById(linkIdPrefix+(i-current+1)))
a.href=linksPath+links[i%preloadedImages.length];
}
}
}
//-->
</script>
</head>
<body onload="main();">
<table width="400" align="center">
<tr>
<td width="33%">
<a href="#" target="_blank" id="link1">
<img src="images/image1.jpg" id="image1">
</a>
</td>
<td width="33%">
<a href="#" target="_blank" id="link2">
<img src="images/image2.jpg" id="image2">
</a>
</td>
<td width="33%">
<a href="#" target="_blank" id="link3">
<img src="images/image3.jpg" id="image3">
</a>
</td>
</tr>
</table>
<input type="button" value="Назад" onclick="back(0);">
<input type="button" value="Вперёд" onclick="forward(0);">
<table width="400" align="center">
<tr>
<td width="33%">
<a href="#" target="_blank" id="slideLink1">
<img src="images/image1.jpg" id="slide1">
</a>
</td>
<td width="33%">
<a href="#" target="_blank" id="slideLink2">
<img src="images/image2.jpg" id="slide2">
</a>
</td>
<td width="33%">
<a href="#" target="_blank" id="slideLink3">
<img src="images/image3.jpg" id="slide3">
</a>
</td>
</tr>
</table>
<input type="button" value="Назад" onclick="back(1);">
<input type="button" value="Вперёд" onclick="forward(1);">
</body>
</html> |