1 |
|
---|
2 |
/* ==================================================================== */ |
---|
3 |
/* check the browser. */ |
---|
4 |
/* ==================================================================== */ |
---|
5 |
var browser =""; |
---|
6 |
var version = ""; |
---|
7 |
var xpos; |
---|
8 |
if (navigator.appName == "Netscape") |
---|
9 |
{ |
---|
10 |
browser = "netscape"; |
---|
11 |
if ( navigator.appVersion[0] <= 4) |
---|
12 |
version = 4; |
---|
13 |
else |
---|
14 |
version = 5; |
---|
15 |
} |
---|
16 |
else |
---|
17 |
{ |
---|
18 |
browser = "ie"; |
---|
19 |
} |
---|
20 |
|
---|
21 |
/* ==================================================================== */ |
---|
22 |
/* function FindImage(szImageName) */ |
---|
23 |
/* */ |
---|
24 |
/* ==================================================================== */ |
---|
25 |
|
---|
26 |
function FindImage(szImageName) |
---|
27 |
{ |
---|
28 |
var oImage; |
---|
29 |
if (browser == "netscape" ) |
---|
30 |
{ |
---|
31 |
if (arguments.length == 2 ) |
---|
32 |
{ |
---|
33 |
oImage = document.layers[arguments[1]].document.images[szImageName]; |
---|
34 |
} |
---|
35 |
else |
---|
36 |
{ |
---|
37 |
oImage = document.images[szImageName]; |
---|
38 |
} |
---|
39 |
} |
---|
40 |
else //IE |
---|
41 |
{ |
---|
42 |
oImage = document.getElementById(szImageName); |
---|
43 |
} |
---|
44 |
return oImage; |
---|
45 |
} |
---|
46 |
|
---|
47 |
/* ==================================================================== */ |
---|
48 |
/* function FindObjectPos(obj) */ |
---|
49 |
/* */ |
---|
50 |
/* Finds the position of an object on the page */ |
---|
51 |
/* Returns the top left x, y coordinates of an object */ |
---|
52 |
/* NOTE: */ |
---|
53 |
/* - obj is the name/id of any html object, images work well */ |
---|
54 |
/* - NN4 If obj is in a layer, please use the second function */ |
---|
55 |
/* - Uses function FindObjectPosX(obj) */ |
---|
56 |
/* and function FindObjectPosY(obj)to find the position for */ |
---|
57 |
/* Netscape 5+ and IE */ |
---|
58 |
/* ==================================================================== */ |
---|
59 |
|
---|
60 |
function FindObjectPos(oElement) |
---|
61 |
{ |
---|
62 |
var aPos = new Array(2); |
---|
63 |
aPos[0] = FindObjectPosX( oElement ); |
---|
64 |
//alert(aPos[0]); |
---|
65 |
aPos[1] = FindObjectPosY( oElement ); |
---|
66 |
//alert(aPos[1]); |
---|
67 |
|
---|
68 |
if (arguments.length == 2 && browser == "netscape" && version == 4) |
---|
69 |
{ |
---|
70 |
var oLayer = UTLGetLayer( arguments[1] ); |
---|
71 |
|
---|
72 |
aPos[0] = aPos[0] + oLayer.left; |
---|
73 |
aPos[1] = aPos[1] + oLayer.top; |
---|
74 |
} |
---|
75 |
return aPos; |
---|
76 |
} |
---|
77 |
|
---|
78 |
/* ==================================================================== */ |
---|
79 |
/* function FindObjectPosX(obj) */ |
---|
80 |
/* function FindObjectPosY(obj) */ |
---|
81 |
/* */ |
---|
82 |
/* Returns the left x coordinate of an object on the page */ |
---|
83 |
/* Returns the top y coordinate of an object on the page */ |
---|
84 |
/* NOTE: */ |
---|
85 |
/* - obj is the name/id of any html object, images work well */ |
---|
86 |
/* ==================================================================== */ |
---|
87 |
|
---|
88 |
function FindObjectPosX(obj) |
---|
89 |
{ |
---|
90 |
var curleft = 0; |
---|
91 |
|
---|
92 |
if (browser == "netscape") //Netscape 4+ |
---|
93 |
{ |
---|
94 |
curleft += obj.x; |
---|
95 |
} |
---|
96 |
else //IE |
---|
97 |
{ |
---|
98 |
while (obj.offsetParent) |
---|
99 |
{ |
---|
100 |
curleft += obj.offsetLeft; |
---|
101 |
obj = obj.offsetParent; |
---|
102 |
} |
---|
103 |
} |
---|
104 |
return curleft; |
---|
105 |
} |
---|
106 |
|
---|
107 |
|
---|
108 |
function FindObjectPosY(obj) |
---|
109 |
{ |
---|
110 |
var curtop = 0; |
---|
111 |
if (browser == "netscape") // Netscape 4+ |
---|
112 |
{ |
---|
113 |
curtop += obj.y; |
---|
114 |
} |
---|
115 |
else // IE |
---|
116 |
{ |
---|
117 |
while (obj.offsetParent) |
---|
118 |
{ |
---|
119 |
curtop += obj.offsetTop; |
---|
120 |
obj = obj.offsetParent; |
---|
121 |
} |
---|
122 |
} |
---|
123 |
return curtop; |
---|
124 |
} |
---|
125 |
|
---|
126 |
|
---|
127 |
/* ==================================================================== */ |
---|
128 |
/* SetLayerPos(layerName) */ |
---|
129 |
/* */ |
---|
130 |
/* Dynamically positions a layer in the page */ |
---|
131 |
/* NOTE: */ |
---|
132 |
/* - layerName is the id of any DIV type layer */ |
---|
133 |
/* - hspc and vspc may contain values that are the left x */ |
---|
134 |
/* and top y cordinates of an object in the page if used in */ |
---|
135 |
/* concert with function FindObjectPos(obj) */ |
---|
136 |
/* ==================================================================== */ |
---|
137 |
|
---|
138 |
function SetLayerPos(layerName, x, y) |
---|
139 |
{ |
---|
140 |
var oLayer = UTLGetLayer(layerName); |
---|
141 |
|
---|
142 |
if (oLayer != null) |
---|
143 |
{ |
---|
144 |
oLayer.left=x; |
---|
145 |
oLayer.top=y; |
---|
146 |
} |
---|
147 |
else |
---|
148 |
alert( "layer " + layerName + " doesn't exist" ); |
---|
149 |
} |
---|
150 |
|
---|
151 |
function SetLayerVis(layerName, bVisible) |
---|
152 |
{ |
---|
153 |
var oLayer = UTLGetLayer(layerName); |
---|
154 |
if (browser == "netscape" && version == 4) |
---|
155 |
{ |
---|
156 |
if (bVisible) |
---|
157 |
oLayer.visibility = "show"; |
---|
158 |
else |
---|
159 |
oLayer.visibility = "hide"; |
---|
160 |
} |
---|
161 |
else |
---|
162 |
{ |
---|
163 |
if (bVisible) |
---|
164 |
oLayer.visibility = "visible"; |
---|
165 |
else |
---|
166 |
oLayer.visibility = "hidden"; |
---|
167 |
} |
---|
168 |
} |
---|
169 |
|
---|
170 |
|
---|
171 |
/* ==================================================================== */ |
---|
172 |
/* function UTLGetLayer(name) */ |
---|
173 |
/* function UTLGetLayerForContents(name) */ |
---|
174 |
/* */ |
---|
175 |
/* Returns the browser specific layer handle for accessing the */ |
---|
176 |
/* style or the contents of a layer */ |
---|
177 |
/* NOTE: */ |
---|
178 |
/* - name is the name/id of any layer */ |
---|
179 |
/* ==================================================================== */ |
---|
180 |
|
---|
181 |
function UTLGetLayerForContents(name) |
---|
182 |
{ |
---|
183 |
var layer; |
---|
184 |
if (browser == "netscape") |
---|
185 |
{ |
---|
186 |
if (version == "4") |
---|
187 |
{ |
---|
188 |
return document.layers[name]; |
---|
189 |
} |
---|
190 |
else |
---|
191 |
{ |
---|
192 |
if (eval('document.getElementById("' + name + '")') != null) |
---|
193 |
{ |
---|
194 |
layer = eval('document.getElementById("' + name + '")'); |
---|
195 |
return layer; |
---|
196 |
} |
---|
197 |
else |
---|
198 |
{ |
---|
199 |
return null; |
---|
200 |
} |
---|
201 |
} |
---|
202 |
} |
---|
203 |
else if (browser == "ie") |
---|
204 |
{ |
---|
205 |
if (eval('document.all.' + name) != null) |
---|
206 |
{ |
---|
207 |
layer = eval('document.all.' + name); |
---|
208 |
return layer; |
---|
209 |
} else |
---|
210 |
{ |
---|
211 |
return null; |
---|
212 |
} |
---|
213 |
} |
---|
214 |
} |
---|
215 |
|
---|
216 |
|
---|
217 |
function UTLGetLayer(name) |
---|
218 |
{ |
---|
219 |
var layer; |
---|
220 |
if (browser == "netscape") |
---|
221 |
{ |
---|
222 |
if (version == "4") |
---|
223 |
return document.layers[name]; |
---|
224 |
else |
---|
225 |
{ |
---|
226 |
if (eval('document.getElementById("' + name + '")') != null) |
---|
227 |
{ |
---|
228 |
layer = eval('document.getElementById("' + name + '").style'); |
---|
229 |
return layer; |
---|
230 |
} |
---|
231 |
else |
---|
232 |
{ |
---|
233 |
return null; |
---|
234 |
} |
---|
235 |
} |
---|
236 |
} |
---|
237 |
else if (browser == "ie") |
---|
238 |
{ |
---|
239 |
if (eval('document.all.' + name) != null) |
---|
240 |
{ |
---|
241 |
layer = eval('document.all.' + name + '.style'); |
---|
242 |
return layer; |
---|
243 |
} else |
---|
244 |
{ |
---|
245 |
return null; |
---|
246 |
} |
---|
247 |
} |
---|
248 |
} |
---|
249 |
|
---|
250 |
|
---|
251 |
/* ========================================================================= */ |
---|
252 |
/* function PositionLayer( szLayer, szImage [, position, xoffset, yoffset] ) */ |
---|
253 |
/* */ |
---|
254 |
/* ========================================================================= */ |
---|
255 |
|
---|
256 |
function PositionLayer( szLayer, szImage ) |
---|
257 |
{ |
---|
258 |
var oLayer = UTLGetLayer( szLayer ); |
---|
259 |
var oImage = FindImage( szImage ); |
---|
260 |
var szPosition; |
---|
261 |
var aPos; |
---|
262 |
var x, y; |
---|
263 |
|
---|
264 |
//If no position specified then put the layer to the top left |
---|
265 |
if (arguments.length > 2) |
---|
266 |
szPosition = arguments[2]; |
---|
267 |
else |
---|
268 |
szPosition = "tl"; |
---|
269 |
|
---|
270 |
//Are there offsets set? |
---|
271 |
if (arguments.length == 5) |
---|
272 |
{ |
---|
273 |
nXOffset = arguments[3]; |
---|
274 |
nYOffset = arguments[4]; |
---|
275 |
} |
---|
276 |
else |
---|
277 |
{ |
---|
278 |
nXOffset = 0; |
---|
279 |
nYOffset = 0; |
---|
280 |
} |
---|
281 |
|
---|
282 |
//Get the Image position |
---|
283 |
aPos = FindObjectPos( oImage ); |
---|
284 |
x = aPos[0] + nXOffset;; |
---|
285 |
y = aPos[1] + nYOffset; |
---|
286 |
|
---|
287 |
if (szPosition == "tr" ) //top right |
---|
288 |
{ |
---|
289 |
x = x + oImage.width; |
---|
290 |
} |
---|
291 |
else if (szPosition == "bl" ) //bottom left |
---|
292 |
{ |
---|
293 |
y = y + oImage.height; |
---|
294 |
} |
---|
295 |
else if (szPosition == "br" ) //bottom right |
---|
296 |
{ |
---|
297 |
x = x + oImage.width; |
---|
298 |
y = y + oImage.height; |
---|
299 |
} |
---|
300 |
|
---|
301 |
oLayer.left = x; |
---|
302 |
oLayer.top = y; |
---|
303 |
|
---|
304 |
} |
---|
305 |
|
---|
306 |
|
---|
307 |
/* ==================================================================== */ |
---|
308 |
/* function ShowContents(szLayerName,szContents) */ |
---|
309 |
/* */ |
---|
310 |
/* Writes the HTML contents to the specified layer */ |
---|
311 |
/* style or the contents of a layer */ |
---|
312 |
/* NOTE: */ |
---|
313 |
/* - szLayerName is the name of the layer to modify */ |
---|
314 |
/* - szContents is the HTML to place in the layer */ |
---|
315 |
/* ==================================================================== */ |
---|
316 |
|
---|
317 |
function ShowContents(szLayerName,szContents) |
---|
318 |
{ |
---|
319 |
var oLayer = UTLGetLayerForContents(szLayerName); |
---|
320 |
if (browser == "netscape" && version == 4) |
---|
321 |
{ |
---|
322 |
oLayer.document.open(); |
---|
323 |
oLayer.document.write(szContents); |
---|
324 |
oLayer.document.close(); |
---|
325 |
} |
---|
326 |
else |
---|
327 |
{ |
---|
328 |
oLayer.innerHTML = szContents; |
---|
329 |
} |
---|
330 |
} |
---|
331 |
|
---|
332 |
|
---|
333 |
function CreateLayer( szLayerName, szContents, width, height, visible ) |
---|
334 |
{ |
---|
335 |
var vis; |
---|
336 |
var str; |
---|
337 |
var end; |
---|
338 |
if (browser == "netscape" && version == 4) |
---|
339 |
{ |
---|
340 |
str = '<layer id="' + szLayerName + '" left=0 top=0' + |
---|
341 |
' width=' + width + ' height=' + height + |
---|
342 |
' visibility=' + (visible ? '"show"' : '"hide"') + '>'; |
---|
343 |
end = "</layer>"; |
---|
344 |
} |
---|
345 |
else |
---|
346 |
{ |
---|
347 |
str = '<div id="' + szLayerName + '" name="' + szLayerName + |
---|
348 |
'" style="position:absolute; overflow:none; left:0px; top:0px; ' + |
---|
349 |
'width:' + width + 'px; height:' + height + |
---|
350 |
'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') + '">'; |
---|
351 |
end = "</div>"; |
---|
352 |
} |
---|
353 |
document.writeln(str); |
---|
354 |
document.writeln(szContents); |
---|
355 |
document.writeln(end); |
---|
356 |
|
---|
357 |
//alert( str + szContents + '</div>' ); |
---|
358 |
} |
---|
359 |
|
---|
360 |
|
---|
361 |
/************************************************************************************************/ |
---|
362 |
/* */ |
---|
363 |
/* @function : PositionDynLayer( layerName, imageName, position, xOffset, yOffset, visible ) */ |
---|
364 |
/* @purpose : Places a layer [top,bottom,left,right] under an image for use with ShiftLayer */ |
---|
365 |
/* @example : PositionDynLayer( 'container', 'mapimage', 'top', 0, 0, true ) */ |
---|
366 |
/* */ |
---|
367 |
/************************************************************************************************/ |
---|
368 |
function PositionDynLayer( layerName, imageName, position, xOffset, yOffset, visible ) |
---|
369 |
{ |
---|
370 |
|
---|
371 |
SetLayerVis(layerName, visible); |
---|
372 |
|
---|
373 |
//Get Handles on Objects |
---|
374 |
var oLayer = UTLGetLayer( layerName ); |
---|
375 |
var oImage = FindImage( imageName ); |
---|
376 |
|
---|
377 |
//Set Local Vars |
---|
378 |
var x, y; |
---|
379 |
var imgWidth = oImage.width; |
---|
380 |
var imgHeight = oImage.height; |
---|
381 |
|
---|
382 |
//Get the Image position |
---|
383 |
aPos = FindObjectPos( oImage ); |
---|
384 |
x = aPos[0]; |
---|
385 |
y = aPos[1]; |
---|
386 |
|
---|
387 |
//If LEFT then shift it left but keep it beneath image |
---|
388 |
if( position == "left" ) |
---|
389 |
{ |
---|
390 |
var layerWidth = parseInt(oLayer.width); |
---|
391 |
var xoff = imgWidth - layerWidth; |
---|
392 |
x = x + xoff; |
---|
393 |
} |
---|
394 |
|
---|
395 |
//If BOTTOM then shift it down but keep it hidden beneath image |
---|
396 |
if( position == "bottom" ) |
---|
397 |
{ |
---|
398 |
var layerHeight = parseInt(oLayer.height); |
---|
399 |
var yoff = imgHeight - layerHeight; |
---|
400 |
y = y + yoff; |
---|
401 |
} |
---|
402 |
|
---|
403 |
//Apply the Offsets |
---|
404 |
x = x + xOffset; |
---|
405 |
y = y + yOffset; |
---|
406 |
|
---|
407 |
//Apply new coords to the Layer |
---|
408 |
oLayer.left = x; |
---|
409 |
oLayer.top = y; |
---|
410 |
|
---|
411 |
} |
---|
412 |
|
---|
413 |
/************************************************************************************************/ |
---|
414 |
/* */ |
---|
415 |
/* @function : ShiftDynLayer(layerName, position, method, offset, visible) */ |
---|
416 |
/* @purpose : Shifts Layer as set by PositionDynLayer */ |
---|
417 |
/* @example : PositionDynLayer( 'container', 'left, 'pop', 0, true ) */ |
---|
418 |
/* */ |
---|
419 |
/************************************************************************************************/ |
---|
420 |
function ShiftDynLayer(layerName, position, method, offset, visible, direction) |
---|
421 |
{ |
---|
422 |
|
---|
423 |
SetLayerVis(layerName, visible); |
---|
424 |
|
---|
425 |
//Get Handle on Object |
---|
426 |
var oLayer = UTLGetLayer( layerName ); |
---|
427 |
|
---|
428 |
var x, y; |
---|
429 |
|
---|
430 |
var layerWidth = parseInt(oLayer.width); |
---|
431 |
var layerHeight = parseInt(oLayer.height); |
---|
432 |
y = parseInt(oLayer.top); |
---|
433 |
x = parseInt(oLayer.left); |
---|
434 |
|
---|
435 |
if( method == "pop" ) |
---|
436 |
{ |
---|
437 |
|
---|
438 |
if ( position == "left" ) |
---|
439 |
{ |
---|
440 |
x = x + (layerWidth + offset); |
---|
441 |
} |
---|
442 |
else if ( position == "right" ) |
---|
443 |
{ |
---|
444 |
x = x - (layerWidth - offset); |
---|
445 |
} |
---|
446 |
else if ( position == "bottom" ) |
---|
447 |
{ |
---|
448 |
y = y + (layerHeight + offset); |
---|
449 |
} |
---|
450 |
else if ( position == "top" ) |
---|
451 |
{ |
---|
452 |
y = y - (layerHeight - offset); |
---|
453 |
} |
---|
454 |
|
---|
455 |
SetLayerPos( layerName, x, y ); |
---|
456 |
|
---|
457 |
} |
---|
458 |
else |
---|
459 |
{ |
---|
460 |
SlideDynLayer(layerName, position, 5, 15, offset, direction); |
---|
461 |
} |
---|
462 |
|
---|
463 |
} |
---|
464 |
|
---|
465 |
/************************************************************************************************/ |
---|
466 |
/* */ |
---|
467 |
/* @function : SlideDynLayer(layerName, position, increment, speed, offset, direction) */ |
---|
468 |
/* @purpose : Animates PositionDynLayer layer (used as stand alone or with ShiftDynLayer */ |
---|
469 |
/* @example : SlideDynLayer('container', 'left', 10, 20, 0, 'out') */ |
---|
470 |
/* */ |
---|
471 |
/************************************************************************************************/ |
---|
472 |
function SlideDynLayer(layerName, position, increment, speed, offset, direction) |
---|
473 |
{ |
---|
474 |
|
---|
475 |
//Layer Visibility |
---|
476 |
if( direction == "out" ) |
---|
477 |
SetLayerVis( layerName, true ); |
---|
478 |
|
---|
479 |
var oLayer = UTLGetLayer( layerName ); |
---|
480 |
|
---|
481 |
//Set global vars for called functions |
---|
482 |
slideLayer = UTLGetLayer( layerName ); |
---|
483 |
layerIncrement = increment; |
---|
484 |
layerSpeed = speed; |
---|
485 |
|
---|
486 |
if( position == "left" ) //move the layer to the right |
---|
487 |
{ |
---|
488 |
var x = parseInt( oLayer.left ); |
---|
489 |
var layerWidth = parseInt( oLayer.width ); |
---|
490 |
if( direction == "out" ) |
---|
491 |
{ |
---|
492 |
layerEP = x + layerWidth + offset; |
---|
493 |
objectRightPos = x; |
---|
494 |
ShiftRight(); |
---|
495 |
} |
---|
496 |
else |
---|
497 |
{ |
---|
498 |
layerEP = x - layerWidth - offset; |
---|
499 |
objectLeftPos = x; |
---|
500 |
ShiftLeft(); |
---|
501 |
} |
---|
502 |
} |
---|
503 |
else if( position == "right" ) //move the layer to the left |
---|
504 |
{ |
---|
505 |
var x = parseInt( oLayer.left ); |
---|
506 |
var layerWidth = parseInt( oLayer.width ); |
---|
507 |
if( direction == "out" ) |
---|
508 |
{ |
---|
509 |
layerEP = x - layerWidth - offset; |
---|
510 |
objectLeftPos = x; |
---|
511 |
ShiftLeft(); |
---|
512 |
} |
---|
513 |
else |
---|
514 |
{ |
---|
515 |
layerEP = x + layerWidth + offset; |
---|
516 |
objectRightPos = x; |
---|
517 |
ShiftRight(); |
---|
518 |
} |
---|
519 |
|
---|
520 |
} |
---|
521 |
else if( position == "top" ) //move the layer to the bottom |
---|
522 |
{ |
---|
523 |
var y = parseInt( oLayer.top ); |
---|
524 |
var layerHeight = parseInt( oLayer.height ); |
---|
525 |
alert( 'this direction not yet ready' ); |
---|
526 |
if( direction == "out" ) |
---|
527 |
{ |
---|
528 |
layerEP = y + layerWidth + offset; |
---|
529 |
objectTopPos = y; |
---|
530 |
ShiftDown(); |
---|
531 |
} |
---|
532 |
else |
---|
533 |
{ |
---|
534 |
layerEP = y - layerWidth - offset; |
---|
535 |
objectBottomPos = y; |
---|
536 |
ShiftUp(); |
---|
537 |
} |
---|
538 |
} |
---|
539 |
else //move the layer to the top |
---|
540 |
{ |
---|
541 |
var y = parseInt( oLayer.top ); |
---|
542 |
var layerHeight = parseInt( oLayer.height ); |
---|
543 |
alert( 'this direction not yet ready' ); |
---|
544 |
if( direction == "out" ) |
---|
545 |
{ |
---|
546 |
layerEP = y + layerWidth + offset; |
---|
547 |
objectBottomPos = y; |
---|
548 |
ShiftUp(); |
---|
549 |
} |
---|
550 |
else |
---|
551 |
{ |
---|
552 |
layerEP = y - layerWidth - offset; |
---|
553 |
objectTopPos = y; |
---|
554 |
ShiftDown(); |
---|
555 |
} |
---|
556 |
} |
---|
557 |
|
---|
558 |
} |
---|
559 |
|
---|
560 |
function ShiftRight() |
---|
561 |
{ |
---|
562 |
if ( objectRightPos < layerEP ) |
---|
563 |
{ |
---|
564 |
objectRightPos += layerIncrement; |
---|
565 |
slideLayer.left = objectRightPos; |
---|
566 |
setTimeout( "ShiftRight()", layerSpeed ); |
---|
567 |
} |
---|
568 |
} |
---|
569 |
|
---|
570 |
function ShiftLeft() |
---|
571 |
{ |
---|
572 |
if ( objectLeftPos > layerEP ) |
---|
573 |
{ |
---|
574 |
objectLeftPos = objectLeftPos - layerIncrement; |
---|
575 |
slideLayer.left = objectLeftPos; |
---|
576 |
setTimeout( "ShiftLeft()", layerSpeed ); |
---|
577 |
} |
---|
578 |
} |
---|
579 |
|
---|
580 |
function ShiftDown() |
---|
581 |
{ |
---|
582 |
alert('function not complete'); |
---|
583 |
} |
---|
584 |
|
---|
585 |
function ShiftUp() |
---|
586 |
{ |
---|
587 |
alert('function not complete'); |
---|
588 |
} |
---|