//************************************************************************************************ //* Lightbox //* Skapad av Jimmy Wester //* //* Inkludera denna fil + scriplib.js. //* gör ett onclick event där du startar "setLightbox( Bredd, Höjd, Element);" //* Element = _id('det div-id där du lägger innehållet som ska visas i rutan.'). //************************************************************************************************ function setLightbox(w, h, e, c) { if(_id('Lightbox')) { _id('Lightbox').style.display = 'block'; } else { newE = document.createElement("div"); newE.id = 'Lightbox'; newE.style.position = 'absolute'; newE.style.top = '0px'; newE.style.left = '0px'; newE.style.height = '' + document.documentElement.scrollHeight + 'px'; newE.style.width = '100%'; newE.style.cursor = 'pointer'; newE.style.zIndex = '999'; newE.style.backgroundColor = '#000000'; newE.style.filter = 'alpha(opacity=70)'; newE.style.opacity = '.70'; document.body.insertBefore(newE, document.body.firstChild); } if(_id('LightboxContent')) { e1 = _id('LightboxContent'); e1.style.display = 'block'; e1.style.top = '' + (((document.documentElement.offsetHeight / 2) - parseInt(h / 2)) + document.documentElement.scrollTop) + 'px'; e1.style.left = '' + (((document.documentElement.offsetWidth / 2) - parseInt(w / 2)) - document.documentElement.scrollLeft) + 'px'; } else { newA = document.createElement("div"); newA.id = 'LightboxContent'; newA.style.position = 'absolute'; newA.style.top = '' + (((document.documentElement.offsetHeight / 2) - parseInt(h / 2)) + document.documentElement.scrollTop) + 'px'; newA.style.left = '' + (((document.documentElement.offsetWidth / 2) - parseInt(w / 2)) - document.documentElement.scrollLeft) + 'px'; newA.style.height = '' + h + 'px'; newA.style.width = '' + w + 'px'; newA.style.zIndex = '1001'; //newA.style.backgroundColor = '' + c + ''; ' Bortkommenterad rad, ger js-fel i IE pga att c inte sätts i anropet. // PH 090724 document.body.insertBefore(newA, document.body.firstChild); } _id('LightboxContent').innerHTML = e.innerHTML; if(navigator.appName == "Microsoft Internet Explorer") { _id('Lightbox').attachEvent('onclick', closeLightbox); } else { _id('Lightbox').addEventListener('click', closeLightbox,false); } } function setLightbox1(img, w, h, e, c) { imgPreload = new Image(); imgPreload.src = '' + img + ''; if (imgPreload.width == 0) { setTimeout(function(){setLightbox1(img, w, h, e, c)},40); } else { _id('GImg').src='' + img + ''; setLightbox(w, h, e, c); } } function setLightbox2(img, w, h, e, c) { imgPreload = new Image(); imgPreload.src = '' + img + ''; } function closeLightbox() { document.body.removeChild(_id('LightboxContent')); document.body.removeChild(_id('Lightbox')); }