home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / include / layersmenu.js < prev    next >
Encoding:
JavaScript  |  2008-01-28  |  4.1 KB  |  124 lines

  1. // PHP Layers Menu 1.0.7 (c) 2001, 2002 Marco Pratesi <pratesi@telug.it>
  2. // several "var"s inserted by CPKS to silence errors
  3.  
  4. var DOM = (document.getElementById) ? 1 : 0;
  5. var NS4 = (document.layers) ? 1 : 0;
  6. var IE4 = (document.all) ? 1 : 0;
  7. var loaded = 0;    // to avoid stupid errors of Microsoft browsers
  8. var Konqueror = (navigator.userAgent.indexOf("Konqueror") > -1) ? 1 : 0;
  9. // We need to explicitly detect Konqueror
  10. // because Konqueror 3 sets IE4 = 1 ... AAAAAAAAAARGHHH!!!
  11. var Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1 || navigator.userAgent.indexOf("Opera 6") > -1 || navigator.userAgent.indexOf("Opera/6") > -1) ? 1 : 0;
  12.  
  13. // it works with NS4, Mozilla, NS6, Opera 5 and 6, IE
  14. var currentY = -1;
  15. function grabMouse(e) {
  16.     if ((DOM && !IE4) || Opera5) {
  17.         currentY = e.clientY;
  18.     } else if (NS4) {
  19.         currentY = e.pageY;
  20.     } else {
  21.         currentY = event.y;
  22.     }
  23.     if (DOM && !IE4 && !Opera5 && !Konqueror) {
  24.         currentY += window.pageYOffset;
  25.     } else if (IE4 && DOM && !Opera5 && !Konqueror) {
  26.         currentY += document.body.scrollTop;
  27.     }
  28. }
  29.  
  30. // Replace deprecated captureEvents with addEventListener 
  31. // by phppp since XOOPS 2.0.17
  32. if (document.addEventListener){
  33.   document.addEventListener('mousemove', grabMouse, false); 
  34. } else if (document.attachEvent){
  35.   document.attachEvent('onmousemove', grabMouse);
  36. }
  37.  
  38. function popUp(menuName,on) {
  39.     if (loaded) {    // to avoid stupid errors of Microsoft browsers
  40.         if (on) {
  41. //            moveLayers();
  42.             if (DOM) {
  43.                 document.getElementById(menuName).style.visibility = "visible";
  44.                 document.getElementById(menuName).style.zIndex = 1000;
  45.             } else if (NS4) {
  46.                 document.layers[menuName].visibility = "show";
  47.                 document.layers[menuName].zIndex = 1000;
  48.             } else {
  49.                 document.all[menuName].style.visibility = "visible";
  50.                 document.all[menuName].style.zIndex = 1000;
  51.             }
  52.         } else {
  53.             if (DOM) {
  54.                 document.getElementById(menuName).style.visibility = "hidden";
  55.             } else if (NS4) {
  56.                 document.layers[menuName].visibility = "hide";
  57.             } else {
  58.                 document.all[menuName].style.visibility = "hidden";
  59.             }
  60.         }
  61.     }
  62. }
  63.  
  64. function setleft(layer,x) {
  65.     if (DOM) {
  66.         document.getElementById(layer).style.left = x + 'px';
  67.     } else if (NS4) {
  68.         document.layers[layer].left = x;
  69.     } else {
  70.         document.all[layer].style.pixelLeft = x;
  71.     }
  72. }
  73.  
  74. function settop(layer,y) {
  75.     if (DOM) {
  76.         document.getElementById(layer).style.top = y + 'px';
  77.     } else if (NS4) {
  78.         document.layers[layer].top = y;
  79.     } else {
  80.         document.all[layer].style.pixelTop = y;
  81.     }
  82. }
  83.  
  84. function setwidth(layer,w) {
  85.     if (DOM) {
  86.         document.getElementById(layer).style.width = w;
  87.         document.getElementById(layer).style.width = w + 'px';
  88.     } else if (NS4) {
  89. //        document.layers[layer].width = w;
  90.     } else {
  91.         document.all[layer].style.pixelWidth = w;
  92.     }
  93. }
  94.  
  95. function moveLayerY(menuName, ordinata, e) {
  96.     if (loaded) {    
  97.     // to avoid stupid errors of Microsoft browsers
  98.     //alert (ordinata);
  99.     // Konqueror: ordinata = -1 according to the initialization currentY = -1
  100.     // Opera: isNaN(ordinata), currentY is NaN, it seems that Opera ignores the initialization currentY = -1
  101.         if (ordinata != -1 && !isNaN(ordinata)) {    // The browser has detected the mouse position
  102.             if (DOM) {
  103.                 // attenzione a "px" !!!
  104.                 if (e && e.clientY) { // just use the pos of the mouseOver event if we have it
  105.                     document.getElementById(menuName).style.top = e.clientY + 'px';
  106.                 } else {
  107.                     appoggio = parseInt(document.getElementById(menuName).style.top);
  108.                     if (isNaN(appoggio)) appoggio = 0;
  109.                     if (Math.abs(appoggio + ordinata_margin - ordinata) > thresholdY)
  110.                         document.getElementById(menuName).style.top = (ordinata - ordinata_margin) + 'px';
  111.                 }
  112.  
  113.             } else if (NS4) {
  114.                     if (Math.abs(document.layers[menuName].top + ordinata_margin - ordinata) > thresholdY)
  115.                         document.layers[menuName].top = ordinata - ordinata_margin;
  116.             } else {
  117.                 if (Math.abs(document.all[menuName].style.pixelTop + ordinata_margin - ordinata) > thresholdY)
  118.                     document.all[menuName].style.pixelTop = ordinata - ordinata_margin;
  119.             }
  120.         }
  121.     }
  122. }
  123.  
  124.