comparison client/digitallibrary/buttons/fw_menu.js @ 20:d407cb901df4

Initial revision
author robcast
date Thu, 17 Jan 2002 15:29:55 +0100
parents
children
comparison
equal deleted inserted replaced
1:0ff3ede32060 20:d407cb901df4
1 /* fw_menu -- JS library for digilib buttons
2
3 Digital Image Library servlet components
4
5 Copyright (C) 2001, 2002 Christian Luginbuehl (luginbuehl@student.unibe.ch)
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 Please read license.txt for the full details. A copy of the GPL
13 may be found at http://www.gnu.org/copyleft/lgpl.html
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 */
20
21 function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh) {
22 this.version = "990702 [Menu; menu.js]";
23 this.type = "Menu";
24 this.menuWidth = mw;
25 this.menuItemHeight = mh;
26 this.fontSize = fs||12;
27 this.fontWeight = "plain";
28 this.fontFamily = fnt||"arial,helvetica,verdana,sans-serif";
29 this.fontColor = fclr||"#000000";
30 this.fontColorHilite = fhclr||"#ffffff";
31 this.bgColor = "#555555";
32 this.menuBorder = 1;
33 this.menuItemBorder = 1;
34 this.menuItemBgColor = bg||"#cccccc";
35 this.menuLiteBgColor = "#ffffff";
36 this.menuBorderBgColor = "#777777";
37 this.menuHiliteBgColor = bgh||"#000084";
38 this.menuContainerBgColor = "#cccccc";
39 this.childMenuIcon = "arrows.gif";
40 this.items = new Array();
41 this.actions = new Array();
42 this.childMenus = new Array();
43
44 this.hideOnMouseOut = true;
45
46 this.addMenuItem = addMenuItem;
47 this.addMenuSeparator = addMenuSeparator;
48 this.writeMenus = writeMenus;
49 this.FW_showMenu = FW_showMenu;
50 this.onMenuItemOver = onMenuItemOver;
51 this.onMenuItemAction = onMenuItemAction;
52 this.hideMenu = hideMenu;
53 this.hideChildMenu = hideChildMenu;
54
55 if (!window.menus) window.menus = new Array();
56 this.label = label || "menuLabel" + window.menus.length;
57 window.menus[this.label] = this;
58 window.menus[window.menus.length] = this;
59 if (!window.activeMenus) window.activeMenus = new Array();
60 }
61
62 function addMenuItem(label, action) {
63 this.items[this.items.length] = label;
64 this.actions[this.actions.length] = action;
65 }
66
67 function addMenuSeparator() {
68 this.items[this.items.length] = "separator";
69 this.actions[this.actions.length] = "";
70 this.menuItemBorder = 0;
71 }
72
73 // For NS6.
74 function FIND(item) {
75 if (document.all) return(document.all[item]);
76 if (document.getElementById) return(document.getElementById(item));
77 return(false);
78 }
79
80 function writeMenus(container) {
81 if (window.triedToWriteMenus) return;
82
83 if (!container && document.layers) {
84 window.delayWriteMenus = this.writeMenus;
85 var timer = setTimeout('delayWriteMenus()', 250);
86 container = new Layer(100);
87 clearTimeout(timer);
88 } else if (document.all || document.hasChildNodes) {
89 document.writeln('<SPAN ID="menuContainer"></SPAN>');
90 container = FIND("menuContainer");
91 }
92
93 window.fwHideMenuTimer = null;
94 if (!container) return;
95 window.triedToWriteMenus = true;
96 container.isContainer = true;
97 container.menus = new Array();
98 for (var i=0; i<window.menus.length; i++)
99 container.menus[i] = window.menus[i];
100 window.menus.length = 0;
101 var countMenus = 0;
102 var countItems = 0;
103 var top = 0;
104 var content = '';
105 var lrs = false;
106 var theStat = "";
107 var tsc = 0;
108 if (document.layers) lrs = true;
109 for (var i=0; i<container.menus.length; i++, countMenus++) {
110 var menu = container.menus[i];
111 if (menu.bgImageUp) {
112 menu.menuBorder = 0;
113 menu.menuItemBorder = 0;
114 }
115 if (lrs) {
116 var menuLayer = new Layer(100, container);
117 var lite = new Layer(100, menuLayer);
118 lite.top = menu.menuBorder;
119 lite.left = menu.menuBorder;
120 var body = new Layer(100, lite);
121 body.top = menu.menuBorder;
122 body.left = menu.menuBorder;
123 } else {
124 content += ''+
125 '<DIV ID="menuLayer'+ countMenus +'" STYLE="position:absolute;z-index:1;left:10;top:'+ (i * 100) +';visibility:hidden;">\n'+
126 ' <DIV ID="menuLite'+ countMenus +'" STYLE="position:absolute;z-index:1;left:'+ menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;" onMouseOut="mouseoutMenu();">\n'+
127 ' <DIV ID="menuFg'+ countMenus +'" STYLE="position:absolute;left:'+ menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;">\n'+
128 '';
129 }
130 var x=i;
131 for (var i=0; i<menu.items.length; i++) {
132 var item = menu.items[i];
133 var childMenu = false;
134 var defaultHeight = menu.fontSize+6;
135 var defaultIndent = menu.fontSize;
136 if (item.label) {
137 item = item.label;
138 childMenu = true;
139 }
140 menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
141 menu.menuItemIndent = menu.menuItemIndent || defaultIndent;
142 var itemProps = 'font-family:' + menu.fontFamily +';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
143 if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
144 if (document.all)
145 itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
146 else if (!document.layers) {
147 itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
148 }
149 var l;
150 if (lrs) {
151 l = new Layer(800,body);
152 }
153 var dTag = '<DIV ID="menuItem'+ countItems +'" STYLE="position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
154 var dClose = '</DIV>'
155 if (menu.bgImageUp) {
156 menu.menuBorder = 0;
157 menu.menuItemBorder = 0;
158 dTag = '<DIV ID="menuItem'+ countItems +'" STYLE="background:url('+menu.bgImageUp+');position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
159 if (document.layers) {
160 dTag = '<LAYER BACKGROUND="'+menu.bgImageUp+'" ID="menuItem'+ countItems +'" TOP="'+ (i * menu.menuItemHeight) +'" style="' + itemProps +'">';
161 dClose = '</LAYER>';
162 }
163 }
164 var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:1;';
165 if (lrs) {
166 textProps +=itemProps;
167 dTag = "";
168 dClose = "";
169 }
170
171 var dText = '<DIV ID="menuItemText'+ countItems +'" STYLE="' + textProps + 'color:'+ menu.fontColor +';">'+ item +'&nbsp</DIV>\n<DIV ID="menuItemHilite'+ countItems +'" STYLE="' + textProps + 'top:1;color:'+ menu.fontColorHilite +';visibility:hidden;">'+ item +'&nbsp</DIV>';
172 if (item == "separator") {
173 content += ( dTag + '<DIV ID="menuSeparator'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n<DIV ID="menuSeparatorLite'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n' + dClose);
174 } else if (childMenu) {
175 content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" STYLE="position:absolute;left:0;top:3;"><IMG SRC="'+ menu.childMenuIcon +'"></DIV>\n' + dClose);
176 } else {
177 content += ( dTag + dText + dClose);
178 }
179 if (lrs) {
180 l.document.open("text/html");
181 l.document.writeln(content);
182 l.document.close();
183 content = '';
184 theStat += "-";
185 tsc++;
186 if (tsc > 50) {
187 tsc = 0;
188 theStat = "";
189 }
190 status = theStat;
191 }
192 countItems++;
193 }
194 if (lrs) {
195 // focus layer
196 var focusItem = new Layer(100, body);
197 focusItem.visiblity="hidden";
198 focusItem.document.open("text/html");
199 focusItem.document.writeln("&nbsp;");
200 focusItem.document.close();
201 } else {
202 content += ' <DIV ID="focusItem'+ countMenus +'" STYLE="position:absolute;left:0;top:0;visibility:hide;" onClick="onMenuItemAction(null,this);">&nbsp;</DIV>\n';
203 content += ' </DIV>\n </DIV>\n</DIV>\n';
204 }
205 i=x;
206 }
207 if (document.layers) {
208 container.clip.width = window.innerWidth;
209 container.clip.height = window.innerHeight;
210 container.onmouseout = mouseoutMenu;
211 container.menuContainerBgColor = this.menuContainerBgColor;
212 for (var i=0; i<container.document.layers.length; i++) {
213 proto = container.menus[i];
214 var menu = container.document.layers[i];
215 container.menus[i].menuLayer = menu;
216 container.menus[i].menuLayer.Menu = container.menus[i];
217 container.menus[i].menuLayer.Menu.container = container;
218 var body = menu.document.layers[0].document.layers[0];
219 body.clip.width = proto.menuWidth || body.clip.width;
220 body.clip.height = proto.menuHeight || body.clip.height;
221 for (var n=0; n<body.document.layers.length-1; n++) {
222 var l = body.document.layers[n];
223 l.Menu = container.menus[i];
224 l.menuHiliteBgColor = proto.menuHiliteBgColor;
225 l.document.bgColor = proto.menuItemBgColor;
226 l.saveColor = proto.menuItemBgColor;
227 l.onmouseover = proto.onMenuItemOver;
228 l.onclick = proto.onMenuItemAction;
229 l.action = container.menus[i].actions[n];
230 l.focusItem = body.document.layers[body.document.layers.length-1];
231 l.clip.width = proto.menuWidth || body.clip.width + proto.menuItemIndent;
232 l.clip.height = proto.menuItemHeight || l.clip.height;
233 if (n>0) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder;
234 l.hilite = l.document.layers[1];
235 if (proto.bgImageUp) l.background.src = proto.bgImageUp;
236 l.document.layers[1].isHilite = true;
237 if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {
238 l.hilite = null;
239 l.clip.height -= l.clip.height / 2;
240 l.document.layers[0].document.bgColor = proto.bgColor;
241 l.document.layers[0].clip.width = l.clip.width -2;
242 l.document.layers[0].clip.height = 1;
243 l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
244 l.document.layers[1].clip.width = l.clip.width -2;
245 l.document.layers[1].clip.height = 1;
246 l.document.layers[1].top = l.document.layers[0].top + 1;
247 } else if (l.document.layers.length > 2) {
248 l.childMenu = container.menus[i].items[n].menuLayer;
249 l.document.layers[2].left = l.clip.width -13;
250 l.document.layers[2].top = (l.clip.height / 2) -4;
251 l.document.layers[2].clip.left += 3;
252 l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
253 }
254 }
255 body.document.bgColor = proto.bgColor;
256 body.clip.width = l.clip.width +proto.menuBorder;
257 body.clip.height = l.top + l.clip.height +proto.menuBorder;
258 var focusItem = body.document.layers[n];
259 focusItem.clip.width = body.clip.width;
260 focusItem.Menu = l.Menu;
261 focusItem.top = -30;
262 focusItem.captureEvents(Event.MOUSEDOWN);
263 focusItem.onmousedown = onMenuItemDown;
264 menu.document.bgColor = proto.menuBorderBgColor;
265 var lite = menu.document.layers[0];
266 lite.document.bgColor = proto.menuLiteBgColor;
267 lite.clip.width = body.clip.width +1;
268 lite.clip.height = body.clip.height +1;
269 menu.clip.width = body.clip.width + (proto.menuBorder * 3) ;
270 menu.clip.height = body.clip.height + (proto.menuBorder * 3);
271 }
272 } else {
273 if ((!document.all) && (container.hasChildNodes)) {
274 container.innerHTML=content;
275 } else {
276 container.document.open("text/html");
277 container.document.writeln(content);
278 container.document.close();
279 }
280 if (!FIND("menuLayer0")) return;
281 var menuCount = 0;
282 for (var x=0; x<container.menus.length; x++) {
283 var menuLayer = FIND("menuLayer" + x);
284 container.menus[x].menuLayer = "menuLayer" + x;
285 menuLayer.Menu = container.menus[x];
286 menuLayer.Menu.container = "menuLayer" + x;
287 menuLayer.style.zIndex = 1;
288 var s = menuLayer.style;
289 s.top = s.pixelTop = -300;
290 s.left = s.pixelLeft = -300;
291
292 var menu = container.menus[x];
293 menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
294 menuLayer.style.backgroundColor = menu.menuBorderBgColor;
295 var top = 0;
296 for (var i=0; i<container.menus[x].items.length; i++) {
297 var l = FIND("menuItem" + menuCount);
298 l.Menu = container.menus[x];
299 if (l.addEventListener) { // ns6
300 l.style.width = menu.menuItemWidth;
301 l.style.height = menu.menuItemHeight;
302 l.style.top = top;
303 l.addEventListener("mouseover", onMenuItemOver, false);
304 l.addEventListener("click", onMenuItemAction, false);
305 l.addEventListener("mouseout", mouseoutMenu, false);
306 } else { //ie
307 l.style.pixelWidth = menu.menuItemWidth;
308 l.style.pixelHeight = menu.menuItemHeight;
309 l.style.pixelTop = top;
310 }
311 top = top + menu.menuItemHeight+menu.menuItemBorder;
312 l.style.fontSize = menu.fontSize;
313 l.style.backgroundColor = menu.menuItemBgColor;
314 l.style.visibility = "inherit";
315 l.saveColor = menu.menuItemBgColor;
316 l.menuHiliteBgColor = menu.menuHiliteBgColor;
317 l.action = container.menus[x].actions[i];
318 l.hilite = FIND("menuItemHilite" + menuCount);
319 l.focusItem = FIND("focusItem" + x);
320 l.focusItem.style.pixelTop = l.focusItem.style.top = -30;
321 var childItem = FIND("childMenu" + menuCount);
322 if (childItem) {
323 l.childMenu = container.menus[x].items[i].menuLayer;
324 childItem.style.pixelLeft = childItem.style.left = menu.menuItemWidth -11;
325 childItem.style.pixelTop = childItem.style.top =(menu.menuItemHeight /2) -4;
326 //childItem.style.pixelWidth = 30 || 7;
327 //childItem.style.clip = "rect(0 7 7 3)";
328 l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
329 }
330 var sep = FIND("menuSeparator" + menuCount);
331 if (sep) {
332 sep.style.clip = "rect(0 " + (menu.menuItemWidth - 3) + " 1 0)";
333 sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;
334 sep.style.backgroundColor = menu.bgColor;
335 sep = FIND("menuSeparatorLite" + menuCount);
336 sep.style.clip = "rect(1 " + (menu.menuItemWidth - 3) + " 2 0)";
337 sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;
338 sep.style.backgroundColor = menu.menuLiteBgColor;
339 l.style.height = l.style.pixelHeight = menu.menuItemHeight/2;
340 l.isSeparator = true
341 top -= (menu.menuItemHeight - l.style.pixelHeight)
342 } else {
343 l.style.cursor = "hand"
344 }
345 menuCount++;
346 }
347 menu.menuHeight = top-1;
348 var lite = FIND("menuLite" + x);
349 var s = lite.style;
350 s.height = s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
351 s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 2);
352 s.backgroundColor = menu.menuLiteBgColor;
353
354 var body = FIND("menuFg" + x);
355 s = body.style;
356 s.height = s.pixelHeight = menu.menuHeight + menu.menuBorder;
357 s.width = s.pixelWidth = menu.menuItemWidth + menu.menuBorder;
358 s.backgroundColor = menu.bgColor;
359
360 s = menuLayer.style;
361 s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 4);
362 s.height = s.pixelHeight = menu.menuHeight+(menu.menuBorder*4);
363 }
364 }
365 if (document.captureEvents) {
366 document.captureEvents(Event.MOUSEUP);
367 }
368 if (document.addEventListener) {
369 document.addEventListener("mouseup", onMenuItemOver, false);
370 }
371 if (document.layers && window.innerWidth) {
372 window.onresize = NS4resize;
373 window.NS4sIW = window.innerWidth;
374 window.NS4sIH = window.innerHeight;
375 }
376 document.onmouseup = mouseupMenu;
377 window.fwWroteMenu = true;
378 status = "";
379 }
380
381 function NS4resize() {
382 if (NS4sIW < window.innerWidth ||
383 NS4sIW > window.innerWidth ||
384 NS4sIH > window.innerHeight ||
385 NS4sIH < window.innerHeight )
386 {
387 window.location.reload();
388 }
389 }
390
391 function onMenuItemOver(e, l) {
392 FW_clearTimeout();
393 l = l || this;
394 a = window.ActiveMenuItem;
395 if (document.layers) {
396 if (a) {
397 a.document.bgColor = a.saveColor;
398 if (a.hilite) a.hilite.visibility = "hidden";
399 if (a.Menu.bgImageOver) {
400 a.background.src = a.Menu.bgImageUp;
401 }
402 a.focusItem.top = -100;
403 a.clicked = false;
404 }
405 if (l.hilite) {
406 l.document.bgColor = l.menuHiliteBgColor;
407 l.zIndex = 1;
408 l.hilite.visibility = "inherit";
409 l.hilite.zIndex = 2;
410 l.document.layers[1].zIndex = 1;
411 l.focusItem.zIndex = this.zIndex +2;
412 }
413 if (l.Menu.bgImageOver) {
414 l.background.src = l.Menu.bgImageOver;
415 }
416 l.focusItem.top = this.top;
417 l.Menu.hideChildMenu(l);
418 } else if (l.style && l.Menu) {
419 if (a) {
420 a.style.backgroundColor = a.saveColor;
421 if (a.hilite) a.hilite.style.visibility = "hidden";
422 if (a.Menu.bgImageUp) {
423 a.style.background = "url(" + a.Menu.bgImageUp +")";;
424 }
425 }
426 if (l.isSeparator) return;
427 l.style.backgroundColor = l.menuHiliteBgColor;
428 l.zIndex = 1; // magic IE 4.5 mac happy doohicky. jba
429 if (l.Menu.bgImageOver) {
430 l.style.background = "url(" + l.Menu.bgImageOver +")";
431 }
432 if (l.hilite) {
433 l.style.backgroundColor = l.menuHiliteBgColor;
434 l.hilite.style.visibility = "inherit";
435 }
436 l.focusItem.style.top = l.focusItem.style.pixelTop = l.style.pixelTop;
437 l.focusItem.style.zIndex = l.zIndex +1;
438 l.Menu.hideChildMenu(l);
439 } else {
440 return; // not a menu - magic IE 4.5 mac happy doohicky. jba
441 }
442 window.ActiveMenuItem = l;
443 }
444
445 function onMenuItemAction(e, l) {
446 l = window.ActiveMenuItem;
447 // hier wird die action bei menuclick gemacht
448 if (!l) return;
449 hideActiveMenus();
450 if (l.action) {
451 eval("" + l.action);
452 }
453 window.ActiveMenuItem = 0;
454 }
455
456 function FW_clearTimeout()
457 {
458 if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
459 fwHideMenuTimer = null;
460 fwDHFlag = false;
461 }
462 function FW_startTimeout()
463 {
464 fwStart = new Date();
465 fwDHFlag = true;
466 fwHideMenuTimer = setTimeout("FW_doHide()", 1000);
467 }
468
469 function FW_doHide()
470 {
471 if (!fwDHFlag) return;
472 var elapsed = new Date() - fwStart;
473 if (elapsed < 1000) {
474 fwHideMenuTimer = setTimeout("FW_doHide()", 1100-elapsed);
475 return;
476 }
477 fwDHFlag = false;
478 hideActiveMenus();
479 window.ActiveMenuItem = 0;
480 }
481
482 function FW_showMenu(menu, x, y, child) {
483 if (!window.fwWroteMenu) return;
484 FW_clearTimeout();
485 if (document.layers) {
486 if (menu) {
487 var l = menu.menuLayer || menu;
488 l.left = 1;
489 l.top = 1;
490 hideActiveMenus();
491 if (this.visibility) l = this;
492 window.ActiveMenu = l;
493 } else {
494 var l = child;
495 }
496 if (!l) return;
497 for (var i=0; i<l.layers.length; i++) {
498 if (!l.layers[i].isHilite)
499 l.layers[i].visibility = "inherit";
500 if (l.layers[i].document.layers.length > 0)
501 FW_showMenu(null, "relative", "relative", l.layers[i]);
502 }
503 if (l.parentLayer) {
504 if (x != "relative")
505 l.parentLayer.left = x || window.pageX || 0;
506 if (l.parentLayer.left + l.clip.width > window.innerWidth)
507 l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
508 if (y != "relative")
509 l.parentLayer.top = y || window.pageY || 0;
510 if (l.parentLayer.isContainer) {
511 l.Menu.xOffset = window.pageXOffset;
512 l.Menu.yOffset = window.pageYOffset;
513 l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
514 l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
515 if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
516 }
517 }
518 l.visibility = "inherit";
519 if (l.Menu) l.Menu.container.visibility = "inherit";
520 } else if (FIND("menuItem0")) {
521 var l = menu.menuLayer || menu;
522 hideActiveMenus();
523 if (typeof(l) == "string") {
524 l = FIND(l);
525 }
526 window.ActiveMenu = l;
527 var s = l.style;
528 s.visibility = "inherit";
529 if (x != "relative")
530 s.left = s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
531 if (y != "relative")
532 s.top = s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
533 l.Menu.xOffset = document.body.scrollLeft;
534 l.Menu.yOffset = document.body.scrollTop;
535 }
536 if (menu) {
537 window.activeMenus[window.activeMenus.length] = l;
538 }
539 }
540
541 function onMenuItemDown(e, l) {
542 var a = window.ActiveMenuItem;
543 if (document.layers) {
544 if (a) {
545 a.eX = e.pageX;
546 a.eY = e.pageY;
547 a.clicked = true;
548 }
549 }
550 }
551
552 function mouseupMenu(e)
553 {
554 hideMenu(true, e);
555 hideActiveMenus();
556 return true;
557 }
558
559 function mouseoutMenu()
560 {
561 hideMenu(false, false);
562 return true;
563 }
564
565
566 function hideMenu(mouseup, e) {
567 var a = window.ActiveMenuItem;
568 if (a && document.layers) {
569 a.document.bgColor = a.saveColor;
570 a.focusItem.top = -30;
571 if (a.hilite) a.hilite.visibility = "hidden";
572 if (mouseup && a.action && a.clicked && window.ActiveMenu) {
573 if (a.eX <= e.pageX+15 && a.eX >= e.pageX-15 && a.eY <= e.pageY+10 && a.eY >= e.pageY-10) {
574 setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 2);
575 }
576 }
577 a.clicked = false;
578 if (a.Menu.bgImageOver) {
579 a.background.src = a.Menu.bgImageUp;
580 }
581 } else if (window.ActiveMenu && FIND("menuItem0")) {
582 if (a) {
583 a.style.backgroundColor = a.saveColor;
584 if (a.hilite) a.hilite.style.visibility = "hidden";
585 if (a.Menu.bgImageUp) {
586 a.style.background = "url(" + a.Menu.bgImageUp +")";;
587 }
588 }
589 }
590 if (!mouseup && window.ActiveMenu) {
591 if (window.ActiveMenu.Menu) {
592 if (window.ActiveMenu.Menu.hideOnMouseOut) {
593 FW_startTimeout();
594 }
595 return(true);
596 }
597 }
598 return(true);
599 }
600
601 function PxToNum(pxStr)
602 { // pxStr == 27px, we want 27.
603 if (pxStr.length > 2) {
604 n = Number(pxStr.substr(0, pxStr.length-2));
605 return(n);
606 }
607 return(0);
608 }
609
610 function hideChildMenu(hcmLayer) {
611 FW_clearTimeout();
612 var l = hcmLayer;
613 for (var i=0; i < l.Menu.childMenus.length; i++) {
614 var theLayer = l.Menu.childMenus[i];
615 if (document.layers) {
616 theLayer.visibility = "hidden";
617 } else {
618 theLayer = FIND(theLayer);
619 theLayer.style.visibility = "hidden";
620 }
621 theLayer.Menu.hideChildMenu(theLayer);
622 }
623
624 if (l.childMenu) {
625 var childMenu = l.childMenu;
626 if (document.layers) {
627 l.Menu.FW_showMenu(null,null,null,childMenu.layers[0]);
628 childMenu.zIndex = l.parentLayer.zIndex +1;
629 childMenu.top = l.top + l.parentLayer.top + l.Menu.menuLayer.top + l.Menu.menuItemHeight/3;
630 if (childMenu.left + childMenu.clip.width > window.innerWidth) {
631 childMenu.left = l.parentLayer.left - childMenu.clip.width + l.Menu.menuLayer.left + 15;
632 l.Menu.container.clip.left -= childMenu.clip.width;
633 } else {
634 childMenu.left = l.parentLayer.left + l.parentLayer.clip.width + l.Menu.menuLayer.left -5;
635 }
636 var w = childMenu.clip.width+childMenu.left-l.Menu.container.clip.left;
637 if (w > l.Menu.container.clip.width)
638 l.Menu.container.clip.width = w;
639 var h = childMenu.clip.height+childMenu.top-l.Menu.container.clip.top;
640 if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
641 l.document.layers[1].zIndex = 0;
642 childMenu.visibility = "inherit";
643 } else if (FIND("menuItem0")) {
644 childMenu = FIND(l.childMenu);
645 var menuLayer = FIND(l.Menu.menuLayer);
646 var s = childMenu.style;
647 s.zIndex = menuLayer.style.zIndex+1;
648 if (document.all) { // ie case.
649 s.pixelTop = l.style.pixelTop + menuLayer.style.pixelTop + l.Menu.menuItemHeight/3;
650 s.left = s.pixelLeft = (menuLayer.style.pixelWidth) + menuLayer.style.pixelLeft -5;
651 } else { // zilla case
652 var top = PxToNum(l.style.top) + PxToNum(menuLayer.style.top) + l.Menu.menuItemHeight/3;
653 var left = (PxToNum(menuLayer.style.width)) + PxToNum(menuLayer.style.left) -5;
654 s.top = top;
655 s.left = left;
656 }
657 childMenu.style.visibility = "inherit";
658 } else {
659 return;
660 }
661 window.activeMenus[window.activeMenus.length] = childMenu;
662 }
663 }
664
665 function hideActiveMenus() {
666 if (!window.activeMenus) return;
667 for (var i=0; i < window.activeMenus.length; i++) {
668 if (!activeMenus[i]) continue;
669 if (activeMenus[i].visibility && activeMenus[i].Menu) {
670 activeMenus[i].visibility = "hidden";
671 activeMenus[i].Menu.container.visibility = "hidden";
672 activeMenus[i].Menu.container.clip.left = 0;
673 } else if (activeMenus[i].style) {
674 var s = activeMenus[i].style;
675 s.visibility = "hidden";
676 s.left = -200;
677 s.top = -200;
678 }
679 }
680 if (window.ActiveMenuItem) {
681 hideMenu(false, false);
682 }
683 window.activeMenus.length = 0;
684 }
685
686 function MM_findObj(n, d) { //v3.0
687 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
688 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
689 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
690 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
691 }
692 function MM_swapImage() { //v3.0
693 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
694 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
695 }
696 function MM_swapImgRestore() { //v3.0
697 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
698 }
699
700 function MM_preloadImages() { //v3.0
701 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
702 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
703 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
704 }
705
706
707 // additional help for the different buttens. makes a floating window with content given by helpText
708
709 // just to be sure, that no buffer overflow can arrive
710 var semaphor = true;
711
712 function contextHelp(helpText, relX, relY) {
713
714 if (showHelp && semaphor) {
715 semaphor = false;
716 var help = helpText.split("|");
717
718 var helpWindowWidth = 270;
719 var helpWindowHeight = 130;
720
721 var xScreen = relX*(screen.width-helpWindowWidth);
722 var yScreen = relY*(screen.height-helpWindowHeight);
723
724 var helpWindow = window.open("", "ContextHelp", "width=" + helpWindowWidth + ",height=" + helpWindowHeight + ",screenX=" + xScreen + ",screenY=" + yScreen + ",left=" + xScreen + ",top=" + yScreen);
725
726 helpWindow.focus();
727 helpWindow.document.open();
728 helpWindow.document.write('<html><head><title>Context Help</title>');
729 helpWindow.document.write('<style type="text/css">');
730 helpWindow.document.write('.title {font-family: Verdana, sans-serif, Arial; font-size: 12px; font-weight: bold; color: #FFFFFF}');
731 helpWindow.document.write('.text {font-family: Verdana, sans-serif, Arial; font-size: 10px; color: #000000}');
732 helpWindow.document.write('</style></head><body bgcolor="#CCCCCC" leftmargin="7" topmargin="7" marginwidth="7" marginheight="7" onLoad="opener.semaphor = true;">');
733 helpWindow.document.write('<table width="' + (helpWindowWidth-8) + '" border="0" cellspacing="0" cellpadding="3"><tr><td bgcolor="#666666" class="title">');
734 helpWindow.document.write(help[0] + '</tr><tr><td class="text">');
735 helpWindow.document.write(help[1] + '</tr></td></table></body></html>');
736 helpWindow.document.close();
737 }
738
739 // stupid workaround because of netscape 6, that doesen't know the opener property
740 // this workaround is still ok cause netscape 6 has eventbuffer check (no overflow)
741 if ((navigator.appName.toLowerCase() == "netscape") && (parseFloat(navigator.appVersion) >= 5.0)) {
742 semaphor = true;
743 }
744 }