menu.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. var strActiveItem=null;
  2. var arPreloadedImgs=new Array(32);
  3. var arPreloadedImgNames=new Array(32);
  4. var bImagesLoaded=false;
  5. function showmsg(strMsg)
  6. {
  7. alert(strMsg);
  8. window.status=strMsg;
  9. }
  10. function preloadImages()
  11. {
  12. var numargs = preloadImages.arguments.length;
  13. for (i = 0; i < numargs; i++)
  14. {
  15. arPreloadedImgs[i*3]=new Image;
  16. arPreloadedImgs[i*3].src=document.images[preloadImages.arguments[i]].inact_src;
  17. arPreloadedImgs[i*3+1]=new Image;
  18. arPreloadedImgs[i*3+1].src=document.images[preloadImages.arguments[i]].hover_src;
  19. arPreloadedImgs[i*3+2]=new Image;
  20. arPreloadedImgs[i*3+2].src=document.images[preloadImages.arguments[i]].act_src;
  21. arPreloadedImgNames[i]=preloadImages.arguments[i];
  22. }
  23. bImagesLoaded=true;
  24. }
  25. function getPreloadedImageIndex(strImgName)
  26. {
  27. var i=0;
  28. for(i=0;i<32;i++)
  29. {
  30. if(arPreloadedImgNames[i]==strImgName) return i;
  31. }
  32. return -1;
  33. }
  34. function lightMenuItem(strItemName, bChangeTopMenu, strTopMenuLoc, strTopMenuItemName)
  35. {
  36. var idx=0;
  37. if(bImagesLoaded && document.images[strItemName]!=null && strActiveItem!=strItemName)
  38. {
  39. idx=getPreloadedImageIndex(strItemName);
  40. if(idx>=0) document.images[strItemName].src = arPreloadedImgs[idx*3+1].src;
  41. else document.images[strItemName].src = document.images[strItemName].hover_src;
  42. }
  43. }
  44. function dimMenuItem(strItemName)
  45. {
  46. var idx=0;
  47. if(bImagesLoaded && document.images[strItemName]!=null && strActiveItem!=strItemName)
  48. {
  49. idx=getPreloadedImageIndex(strItemName);
  50. if(idx>=0) document.images[strItemName].src = arPreloadedImgs[idx*3].src;
  51. else document.images[strItemName].src = document.images[strItemName].inact_src;
  52. }
  53. }
  54. function activateMenuItem(strItemName)
  55. {
  56. var idx=0;
  57. if(bImagesLoaded && document.images[strItemName]!=null && strActiveItem!=strItemName)
  58. {
  59. if(strActiveItem!=null)
  60. {
  61. idx=getPreloadedImageIndex(strActiveItem);
  62. if(idx>=0) document.images[strActiveItem].src = arPreloadedImgs[idx*3].src;
  63. else document.images[strActiveItem].src = document.images[strActiveItem].inact_src;
  64. }
  65. idx=getPreloadedImageIndex(strItemName);
  66. if(idx>=0) document.images[strItemName].src = arPreloadedImgs[idx*3+2].src;
  67. else document.images[strItemName].src = document.images[strItemName].act_src;
  68. strActiveItem=strItemName;
  69. }
  70. }
  71. function deactivateMenu()
  72. {
  73. if(bImagesLoaded && document[strActiveItem]!=null) {
  74. if(strActiveItem!=null) document[strActiveItem].src = document[strActiveItem].inact_src;
  75. strActiveItem=null;
  76. }
  77. }