init(); function init() { var oldOnLoad = window.onload; window.onload = function() { if (oldOnLoad) oldOnLoad(); addMattesAndShadows(); } } function addMattesAndShadows() { var imgs = document.getElementsByTagName("img"); for (var i = 0; i < imgs.length; i++) { var thisImg = imgs[i]; var isShadow = false; var extraWidth = 10; if (thisImg.className) { var classTokens = thisImg.className.split(' '); for (var j = 0; j < classTokens.length; j++) { var thisToken = classTokens[j]; if (thisToken == "shadow") isShadow = true; if (thisToken == "nomatte") extraWidth = 0; } if (isShadow) { var shadowDiv = document.createElement('div'); shadowDiv.className = 'shadow'; shadowDiv.style.width = (thisImg.width + extraWidth) + "px"; shadowDiv.appendChild(thisImg.cloneNode(false)); var topLeft = document.createElement('div'); topLeft.className = "topleft"; shadowDiv.appendChild(topLeft); var topRight = document.createElement('div'); topRight.className = "topright"; shadowDiv.appendChild(topRight); var bottomLeft = document.createElement('div'); bottomLeft.className = "bottomleft"; shadowDiv.appendChild(bottomLeft); var bottomRight = document.createElement('div'); bottomRight.className = "bottomright"; shadowDiv.appendChild(bottomRight); thisImg.parentNode.replaceChild(shadowDiv, thisImg); } } } }