effects = new Object(); effects.setElementOpacity = function (elem, nOpacity) { var opacityProp = effects.getOpacityProperty(); if (!elem || !opacityProp) return; if (opacityProp=="filter") { nOpacity *= 100; var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha; if (oAlpha) oAlpha.opacity = nOpacity; else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; } else elem.style[opacityProp] = nOpacity; } effects.getOpacityProperty = function() { if (typeof document.body.style.opacity == 'string') return 'opacity'; else if (typeof document.body.style.MozOpacity == 'string') return 'MozOpacity'; else if (typeof document.body.style.KhtmlOpacity == 'string') return 'KhtmlOpacity'; else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) return 'filter'; return false; } modal = new Object(); modal.getPageSize = function(){ var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } SY = window.scrollY ? window.scrollY : Body.scrollTop; // Gecko / IE,Opera SX = window.scrollX ? window.scrollX : Body.scrollLeft; if (self.innerHeight) { if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight, SX, SY) return arrayPageSize; } modal.hideBody = function() { this.pageSize = this.getPageSize(); this.shadowDiv = document.createElement("DIV"); this.shadowDiv.style.position = 'absolute'; this.shadowDiv.style.top = '0px'; this.shadowDiv.style.left = '0px'; this.shadowDiv.style.width = this.pageSize[0]+'px'; this.shadowDiv.style.height = this.pageSize[1]+'px'; this.shadowDiv.style.backgroundColor = 'black'; this.shadowDiv.onclick = closeImage; document.body.appendChild(this.shadowDiv); effects.setElementOpacity(this.shadowDiv, 0.6); } modal.close = function() { this.modalDiv.style.display = 'none'; this.shadowDiv.style.display = 'none'; } modal.showImage = function(text, dWidth, dHeight) { Body = document.getElementsByTagName((document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY")[0]; pageSize = this.getPageSize(); this.hideBody(); if (!dWidth) dWidth = 640; if (!dHeight) dHeight = 480; this.modalDiv = document.createElement("DIV"); document.body.appendChild(this.modalDiv); this.modalDiv.id = 'modal_image'; this.modalDiv.style.position = 'absolute'; oLeft = Math.round((pageSize[2]/2) - (dWidth/2)) + pageSize[4]; oTop = Math.round((pageSize[3]/2) - (dHeight/2)) + pageSize[5]; this.modalDiv.style.left = oLeft + 'px'; this.modalDiv.style.top = oTop + 'px'; this.modalDiv.style.width = dWidth + 'px'; this.modalDiv.style.height = dHeight + 'px'; this.modalDiv.innerHTML = text; } function showImage(img, iWidth, iHeight) { modal.showImage('Click to close', iWidth, iHeight); return false; } function closeImage() { modal.close(); return false; }