3 // Overlay.js, adapted from Floating image II on dynamicdrive.com
7 <script LANGUAGE="JavaScript1.2" src="overlay.js"></script>
10 <body onload="overlaySetup(corner)">
11 <div id="overlayDiv" STYLE="position:absolute;visibility:visible;">
17 var overlayNS4 = document.layers ? 1 : 0;
18 var overlayIE = document.all ? 1 : 0;
19 var overlayNS6 = document.getElementById && !document.all ? 1 : 0;
23 var overlayDelay = 60;
25 var overlayCorner = 'ur'; // ul, ll, ur, lr, uc, lc, cl, cr
27 function overlayRefresh() {
37 var links = document.getElementsByTagName("body")[0];
40 overlayLx = document.body.clientWidth;
41 overlayLy = document.body.clientHeight;
43 if (document.body.parentElement) {
45 overlayLx = document.body.parentElement.clientWidth;
46 overlayLy = document.body.parentElement.clientHeight;
49 overlayH = overlayDiv.offsetHeight;
50 overlayW = body.offsetWidth; // overlayDiv.offsetWidth;
51 contentH = body.offsetHeight;
52 } else if (overlayNS4) {
53 overlayLy = window.innerHeight;
54 overlayLx = window.innerWidth;
55 overlayH = document.overlayDiv.clip.height;
56 overlayW = body.clip.width; // document.overlayDiv.clip.width;
57 contentH = body.clip.height;
58 } else if (overlayNS6) {
59 var odiv = document.getElementById('overlayDiv');
61 overlayLy = window.innerHeight;
62 overlayLx = window.innerWidth;
63 overlayH = odiv.offsetHeight;
64 overlayW = odiv.offsetWidth; // body.offsetWidth;
65 contentH = odiv.offsetHeight;
68 if (overlayCorner == 'ul') {
69 overlayX = overlayPadX;
70 overlayY = overlayPadY;
71 } else if (overlayCorner == 'cl') {
72 overlayX = overlayPadX;
73 overlayY = (overlayLy - overlayH) / 2;
74 } else if (overlayCorner == 'll') {
75 overlayX = overlayPadX;
76 overlayY = (overlayLy - overlayH) - overlayPadY;
77 } else if (overlayCorner == 'ur') {
78 overlayX = (overlayLx - overlayW) - overlayPadX;
79 overlayY = overlayPadY;
80 } else if (overlayCorner == 'cr') {
81 overlayX = (overlayLx - overlayW) - overlayPadX;
82 overlayY = (overlayLy - overlayH) / 2;
83 } else if (overlayCorner == 'lr') {
84 overlayX = (overlayLx - overlayW) - overlayPadX;
85 overlayY = (overlayLy - overlayH) - overlayPadY;
86 } else if (overlayCorner == 'uc') {
87 overlayX = (overlayLx - overlayW) / 2;
88 overlayY = overlayPadY;
89 } else { // overlayCorner == 'lc'
90 overlayX = (overlayLx - overlayW) / 2;
91 overlayY = (overlayLy - overlayH) - overlayPadY;
95 overlayDiv.style.left=overlayX;
96 overlayDiv.style.top=overlayY+document.body.scrollTop;
98 if (contentH > overlayLy) {
99 overlayDiv.style.visibility = "hidden";
101 } else if (overlayNS4) {
102 document.overlayDiv.pageX=overlayX;
103 document.overlayDiv.pageY=overlayY+window.pageYOffset;
104 document.overlayDiv.visibility="visible";
106 if (contentH > overlayLy) {
107 document.overlayDiv.style.visibility = "hidden";
109 } else if (overlayNS6) {
110 var div = document.getElementById("overlayDiv");
111 var leftpx = overlayX;
112 var toppx = overlayY+window.pageYOffset;
113 var widthpx = overlayW;
115 div.style.left = leftpx + "px";
116 div.style.top = toppx + "px";
117 div.style.width = widthpx + "px";
119 if (contentH > overlayLy) {
120 div.style.visibility = "hidden";
122 div.style.visibility = "visible";
131 function loopfunc() {
133 setTimeout('loopfunc()',overlayDelay);
136 function overlaySetup(corner) {
137 overlayCorner = corner;
139 if (overlayIE || overlayNS4 || overlayNS6) {