navigation.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var at_timeout = 100;
  2. function at_show_aux(parent, child) {
  3. var p = document.getElementById(parent);
  4. var c = document.getElementById(child);
  5. p.className = "active";
  6. var top = (c["at_position"] == "y") ? p.offsetHeight : 0;
  7. var left = (c["at_position"] == "x") ? p.offsetWidth : 0;
  8. for (; p; p = p.offsetParent) {
  9. if (p.style.position != 'absolute') {
  10. left += p.offsetLeft;
  11. top += p.offsetTop;
  12. }
  13. }
  14. c.style.position = "absolute";
  15. c.style.top = top +'px';
  16. c.style.left = left+'px';
  17. c.style.visibility = "visible";
  18. }
  19. function at_hide_aux(parent, child) {
  20. document.getElementById(parent).className = "parent";
  21. document.getElementById(child ).style.visibility = "hidden";
  22. }
  23. function at_show() {
  24. var p = document.getElementById(this["at_parent"]);
  25. var c = document.getElementById(this["at_child" ]);
  26. at_show_aux(p.id, c.id);
  27. clearTimeout(c["at_timeout"]);
  28. }
  29. function at_hide(){
  30. var c = document.getElementById(this["at_child"]);
  31. c["at_timeout"] = setTimeout("at_hide_aux('"+this["at_parent"]+"', '"+this["at_child" ]+"')", at_timeout);
  32. }
  33. function at_attach(parent, child, position) {
  34. p = document.getElementById(parent);
  35. c = document.getElementById(child );
  36. p["at_child"] = c.id;
  37. c["at_child"] = c.id;
  38. p["at_parent"] = p.id;
  39. c["at_parent"] = p.id;
  40. c["at_position"] = position;
  41. p.onmouseover = at_show;
  42. p.onmouseout = at_hide;
  43. c.onmouseover = at_show;
  44. c.onmouseout = at_hide;
  45. }
  46. function dhtmlmenu_build_aux(parent, child, position) {
  47. document.getElementById(parent).className = "parent";
  48. document.write('<div class="vert_menu" id="'+parent+'_child">');
  49. var n = 0;
  50. for (var i in child) {
  51. if (i == '-') {
  52. document.getElementById(parent).href = child[i];
  53. continue;
  54. }
  55. if (typeof child[i] == "object") {
  56. document.write('<a class="parent" id="'+parent+'_'+n+'">'+i+'</a>');
  57. dhtmlmenu_build_aux(parent+'_'+n, child[i], "x");
  58. }
  59. else document.write('<a id="'+parent+'_'+n+'" href="'+child[i]+'">'+i+'</a>');
  60. n++;
  61. }
  62. document.write('</div>');
  63. at_attach(parent, parent+"_child", position);
  64. }
  65. function dhtmlmenu_build(menu){
  66. for (var i in menu) dhtmlmenu_build_aux(i, menu[i], "y");
  67. }