script type="text/javascript"> var obj = document.getElementById("img1"); $("#close").click(function() { $("#img1").hide(); }); var ggRoll = { roll: obj, speed: 16, statusX: document.documentElement.clientWidth - document.body.clientWidth, statusY: document.documentElement.clientHeight - document.body.clientHeight, x: 0, y: 0, winW: document.body.clientWidth - obj.offsetWidth, winH: window.innerHeight - obj.offsetHeight, Go: function() { this.roll.style.left = this.x + 'px'; this.roll.style.top = this.y + 'px'; this.x = this.x + (this.statusX ? -1 : 1); if (this.x < 0) { this.statusX = 0; } if (this.x > this.winW) { this.statusX = 1; } this.y = this.y + (this.statusY ? -1 : 1); if (this.y < 0) { this.statusY = 0; } if (this.y > this.winH) { this.statusY = 1; } } } var intervaly = setInterval("ggRoll.Go()", ggRoll.speed); ggRoll.roll.onmouseover = function() { clearInterval(intervaly); }; ggRoll.roll.onmouseout = function() { intervaly = setInterval("ggRoll.Go()", ggRoll.speed); }; function closediv() { clearInterval(intervaly); obj.style.display = "none"; obj.parentNode.removeChild(obj); }