/* Litebox JS by Alexander Shabuniewicz - http://aether.ru 2006-08-18 inspired by Lightbox JS - Lokesh Dhakar - http://www.huddletogether.com and portfolio script of Cameron Adams - http://portfolio.themaninblue.com */ var imgNext; var imgPrev; var nLiteboxActive = 0; function showBox(theTarget) { if ( nLiteboxActive == 1 ) { return; } else { nLiteboxActive = 1; } var theBody = document.getElementsByTagName('body')[0]; var pageCoords = getPageCoords(); var theShadow = document.createElement('div'); theShadow.id = 'shadow'; theShadow.style.height = (pageCoords[1] + 'px'); theShadow.className = 'on'; selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "hidden"; } theBody.insertBefore(theShadow, theBody.firstChild); var theLoading = document.createElement('div'); theLoading.id = 'loading'; theLoading.style.top = parseInt(pageCoords[2] + (pageCoords[0] - 55) / 2) + 'px'; theLoading.onclick = function() { closeBox(); } theShadow.appendChild(theLoading); var imgPreload = new Image(); imgPreload.onload = function() { var theBox = document.createElement('div'); theBox.id = 'litebox'; theBox.style.width = imgPreload.width + 10 + 'px'; theBox.style.marginTop = parseInt(pageCoords[2] + (pageCoords[0] - imgPreload.height - 50) / 2) + 'px'; var theImage = document.createElement('img'); theImage.src = theTarget.href; theImage.alt = theTarget.title; theImage.width = imgPreload.width; theImage.onclick = function() { closeBox(); } theImage.title = "Click to close this image"; var theCaption = document.createElement('p'); theCaption.innerHTML = (theImage.alt) ? theImage.alt : ''; theCaption.innerHTML += "Нажмите ESC или кликните на изображении для выхода"; var allThumbs = new Array(); var allLinks = document.getElementsByTagName('a'); var linkLen = allLinks.length; for (i=0,j=0; i test2) { coords[1] = document.body.scrollHeight; } else { coords[1] = document.body.offsetHeight; } if (coords[1] < coords[0]) coords[1] = coords[0]; return coords; } function closeBox() { var theBody = document.getElementsByTagName('body')[0]; var theBox = document.getElementById('litebox'); if (theBox) theBox.style.display = 'none'; var theShadow = document.getElementById('shadow'); if (theShadow) theShadow.style.display = 'none'; theBody.removeChild(theShadow); selects = document.getElementsByTagName('select'); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = 'visible'; } document.onkeypress = ''; imgPrev = imgNext = ''; nLiteboxActive = 0; return false; } function getKey(e) { var arrowImg; if (!e) var e = window.event; var keycode = e.keyCode ? e.keyCode : e.which; switch (keycode) { case 27: // esc case 32: // spacebar closeBox(); break; case 37: // <- arrowImg = imgPrev ? imgPrev : ''; break; case 39: // -> arrowImg = imgNext ? imgNext : ''; } if (arrowImg) { closeBox(); showBox(arrowImg); } return false; } function initLitebox() { if (!document.getElementsByTagName) { return; } var anchors = document.getElementsByTagName('a'); for (i=0,len=anchors.length; i