iStartIndex = 0; function swapImage(action) { var arrImages = new Array( "anteprima-peschici-2.jpg", "anteprima-peschici-3.jpg", "anteprima-peschici-4.jpg", "anteprima-peschici-1.jpg", "anteprima-peschici-8.jpg", "anteprima-peschici-7.jpg", "anteprima-peschici-5.jpg", "anteprima-immagine-4.jpg", "anteprima-peschici-6.jpg", "anteprima-immagine-5.jpg", "anteprima-immagine-6.jpg", "anteprima-immagine2.jpg"); imagePerBlock = 4; // mostra quattro immagini alla volta var iTotImages = arrImages.length; if (action == 'next') { iStartIndex = iStartIndex + imagePerBlock; } if (action == 'prev') { iStartIndex = iStartIndex - imagePerBlock; } // Visibilità tasti if (iStartIndex > (imagePerBlock - 1)) { // Nascondi tasto prev document.getElementById('divPrev').style.visibility = 'visible'; } else { document.getElementById('divPrev').style.visibility = 'hidden'; } if (iStartIndex >= (iTotImages - imagePerBlock)) { // Nascondi tasto next document.getElementById('divNext').style.visibility = 'hidden'; } else { document.getElementById('divNext').style.visibility = 'visible'; } // blocco immagini document.getElementById('img1').src = 'writable/tn_' + noImage(arrImages[iStartIndex], 'img1'); document.getElementById('img2').src = 'writable/tn_' + noImage(arrImages[iStartIndex + 1], 'img2'); document.getElementById('img3').src = 'writable/tn_' + noImage(arrImages[iStartIndex + 2], 'img3'); document.getElementById('img4').src = 'writable/tn_' + noImage(arrImages[iStartIndex + 3], 'img4'); // blocco link href document.getElementById('link1').href = 'writable/' + arrImages[iStartIndex]; document.getElementById('link2').href = 'writable/' + arrImages[iStartIndex + 1]; document.getElementById('link3').href = 'writable/' + arrImages[iStartIndex + 2]; document.getElementById('link4').href = 'writable/' + arrImages[iStartIndex + 3]; // blocco link title document.getElementById('link1').title = ""; document.getElementById('link2').title = ""; document.getElementById('link3').title = ""; document.getElementById('link4').title = ""; } function noImage(arrValue, idImage) { if (arrValue == undefined) { document.getElementById(idImage).style.visibility = 'hidden'; } else { document.getElementById(idImage).style.visibility = 'visible'; return arrValue; } } function galleryNext() { swapImage('next'); } function galleryPrev() { swapImage('prev'); }