Cały plik galeria.js:
var gallery1 = [
"img/full/foto1.jpg",
"img/full/foto1532.jpg",
"img/full/foto1533.jpg",
"img/full/foto1401.jpg",
"img/full/foto1477.jpg",
];
var gallery2 = [
"img/full/foto0712.jpg",
"img/full/foto1391.jpg",
"img/full/foto1395.jpg",
"img/full/foto1513.jpg",
"img/full/foto41.jpg",
"img/full/foto1905.jpg",
"img/full/foto1673.jpg",
"img/full/foto1919.jpg",
"img/full/foto1928.jpg",
"img/full/foto2201.jpg",
"img/full/foto2215.jpg",
"img/full/foto1974.jpg",
];
var gallery3 = [
"img/full/foto2570.jpg",
"img/full/foto2574.jpg",
"img/full/foto2557.jpg",
"img/full/foto2632.jpg",
"img/full/foto2601.jpg",
"img/full/foto2604.jpg",
"img/full/foto2629.jpg",
];
var gallery4 = [
"img/full/foto21.jpg",
"img/full/foto22.jpg",
"img/full/foto23.jpg",
"img/full/foto24.jpg",
"img/full/foto25.jpg",
"img/full/foto26.jpg",
"img/full/foto27.jpg",
"img/full/foto28.jpg",
"img/full/foto0702.jpg",
"img/full/foto0703.jpg",
"img/full/foto0707.jpg",
"img/full/foto0709.jpg",
];
var gallery5 = [
"img/full/foto0162.jpg",
"img/full/foto0163.jpg",
"img/full/foto0166.jpg",
"img/full/foto0296.jpg",
"img/full/foto0308.jpg",
"img/full/foto0314.jpg",
"img/full/foto0319.jpg",
"img/full/foto0296.jpg",
"img/full/foto0319.jpg",
"img/full/foto0421.jpg",
"img/full/foto0422.jpg",
"img/full/foto0423.jpg",
"img/full/foto0424.jpg",
"img/full/foto0425.jpg",
"img/full/foto0426.jpg",
"img/full/foto0427.jpg"
];
var gallery6 = [
"img/full/foto34.jpg",
"img/full/foto33.jpg",
"img/full/foto32.jpg",
"img/full/foto0711.jpg",
"img/full/foto0705.jpg",
];
var galleries = [gallery1, gallery2, gallery3, gallery4, gallery5, gallery6,];
var gallery = null;
var galleryIdx = null;
var slideInterval = null;
var langID = "pl";
function GalleryImageID() {
if (galleryIdx == null)
return "0705";
var img = gallery[galleryIdx];
if (typeof img == "object")
img = img.src;
return img.replace(/^.*\/img\/full\/foto(.+)\.jpg$/, "$1");
}
function GalleryInit() {
var curImg = document.getElementById("CurrentImage");
var curName = curImg.src;
curName = curName.substr(curName.lastIndexOf("/") + 1);
for (var j = 0; j < galleries.length && galleryIdx == null; ++j) {
gallery = galleries[j];
for (var i = 0; i < gallery.length; ++i)
if (gallery[i].indexOf(curName) >= 0) {
galleryIdx = i;
gallery[i] = new Image();
gallery[i].src = curImg.src;
break;
}
}
if (gallery.length == 1) {
document.getElementById("guzik_lewy").disabled = true;
document.getElementById("guzik_prawy").disabled = true;
document.getElementById("panel_lewo").disabled = true;
document.getElementById("panel_slajdy").disabled = true;
document.getElementById("panel_czas").disabled = true;
document.getElementById("panel_prawo").disabled = true;
}
GalleryPreload();
}
function GalleryNext() {
if (galleryIdx != null) {
var i = galleryIdx + 1;
if (i >= gallery.length)
i = 0;
GallerySelect(i);
}
}
function GalleryPreload() {
if (galleryIdx != null) {
var lastIdx = gallery.length - 1;
var i = galleryIdx == lastIdx? 0 : galleryIdx + 1;
var img = new Image();
img.onload = GallerySetPreload;
if (typeof gallery[i] == "string") {
img.src = gallery[i];
gallery[i] = img;
}
else {
i = galleryIdx == 0? lastIdx : galleryIdx - 1;
if (typeof gallery[i] == "string") {
img.src = gallery[i];
gallery[i] = img;
}
else {
var stopIdx = i;
i = galleryIdx + 2;
if (i > lastIdx)
i -= lastIdx + 1;
for (; i != stopIdx; i = i >= lastIdx? 0 : i + 1)
if (typeof gallery[i] == "string") {
img.src = gallery[i];
gallery[i] = img;
break;
}
}
}
}
}
function GalleryPrev() {
if (galleryIdx != null) {
var i = (galleryIdx == 0? gallery.length : galleryIdx) - 1;
GallerySelect(i);
}
}
function GalleryRunSlideshow() {
if (slideInterval == null) {
var msecs = parseInt(document.getElementById("panel_czas").value) * 1000;
slideInterval = window.setInterval("GalleryNext()", msecs);
document.getElementById("panel_slajdy").value = "Stop";
}
else
GalleryStopSlideshow();
}
function GallerySelect(idx) {
var img = document.getElementById("CurrentImage");
if (typeof gallery[idx] == "object")
img.src = gallery[idx].src;
else {
var newImg = new Image();
img.src = newImg.src = gallery[idx];
gallery[idx] = newImg;
}
galleryIdx = idx;
}
function GallerySetInterval() {
if (slideInterval != null) {
GalleryStopSlideshow();
GalleryRunSlideshow();
}
}
function GallerySetLanguage(lang) {
if (lang == "pl" || lang == "en" || lang == "de")
langID = lang;
}
function GallerySetPreload() {
window.setTimeout("GalleryPreload()", 100);
}
function GalleryStopSlideshow() {
if (slideInterval != null) {
window.clearTimeout(slideInterval);
slideInterval = null;
document.getElementById("panel_slajdy").value =
langID == "pl"? "Slajdy" : "Slideshow";
}
}