var width = "220px"; var height = "230px"; // Create layer document.write("
" + "
" + "
" + "
"); function TsWebInfo() { // Init this.url = ""; this.timer; this.layer = document.getElementById("ts_layer_webinfo"); this.frame = document.getElementById("ts_frame_webinfo"); this.layerWidth = parseInt(this.layer.style.width); this.layerHeight = parseInt(this.layer.style.height); this.setUrl = function(url) { this.url = url; this.frame.src = "about:blank"; this.frame.src = "http://opendev.thumbshots.org/webinfo/webinfo.aspx?url=" + escape(url); } this.getAbsolutePosition = function(element) { var r = { x: element.offsetLeft, y: element.offsetTop }; if (element.offsetParent) { var tmp = this.getAbsolutePosition(element.offsetParent); r.x += tmp.x; r.y += tmp.y; } return r; } // Show layer at mouse coordinate this.show = function(obj, e) { var x = 0; var y = 0; var mouseX = 0; var mouseY = 0; var offsetX = 10; var offsetY = 10; if (typeof event != 'undefined' && event.clientX) { // IE browsers mouseX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); mouseY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); } else if (typeof e != 'undefined' && e.pageX) { // Other browsers mouseX = e.pageX; mouseY = e.pageY; } // Check if window is large enough. Refer to // http://www.howtocreate.co.uk/tutorials/javascript/browserwindow var clientMaxX = 0; var clientMaxY = 0; if (typeof(window.innerWidth) == 'number') { clientMaxX = window.innerWidth; clientMaxY = window.innerHeight; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { //IE 6+ in 'standards compliant mode' clientMaxX = document.documentElement.clientWidth; clientMaxY = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { clientMaxX = document.body.clientWidth; clientMaxY = document.body.clientHeight; } // Swap left/right half depending on available space if (mouseX + this.layerWidth > clientMaxX) x = mouseX - this.layerWidth - offsetX; else x = mouseX; // Swap upper/lower half depending on available space if (mouseY + this.layerHeight > clientMaxY) y = mouseY - this.layerHeight - offsetY; else y = mouseY; // Tell layer to position at those coordinates this.layer.style.left = (x + offsetX) + 'px'; this.layer.style.top = (y + offsetY) + 'px'; this.showLayer(); } // Show layer this.showLayer = function(url) { // Cancel any pending hide this.cancelHide(); this.layer.style.zIndex = 100; this.layer.style.display = "block"; } // Hide immediately this.hideLayer = function() { this.layer.style.display = "none"; } // Hide with delay this.hide = function(delay) { if (typeof delay == "undefined") delay = 1000; var thisObj = this; this.timer = setTimeout(function() {thisObj.hideLayer();}, delay); } // Cancel Hide this.cancelHide = function() {clearTimeout(this.timer);} } var tsWebInfo = new TsWebInfo();