home *** CD-ROM | disk | FTP | other *** search
/ PC Treasures, Inc. / pctreasures.mdf / ICWCON.CAB / icwtutor.exe / HTML / ICW.JS < prev    next >
Text File  |  1999-11-05  |  3KB  |  156 lines

  1. // Set up the events
  2. //======================================================
  3.  
  4. document.oncontextmenu=killcontext;
  5. document.onkeydown=keyhandler;
  6. document.onmousedown=killrightmouse;
  7. window.onload=init;
  8.  
  9. // Kill the Href
  10. //======================================================
  11.  
  12. function doNothing(){
  13.     event.returnValue = false;
  14. }
  15.  
  16. // Init the page
  17. //======================================================
  18. var bLoaded = false;
  19. function init(){
  20.     bLoaded = true;
  21. }
  22.  
  23. // Menu Action
  24. //======================================================
  25.  
  26. var oCurrent;
  27. var iCurrent;
  28. var highColor = "red";
  29. var normColor = "000099";
  30. var iFocus = 1;
  31.  
  32. function selectIt(iItem){
  33.     if (!bLoaded)
  34.         return;
  35.  
  36.     var oItem = document.all["menu_" + iItem];
  37.     var oItemWrap = oItem.parentElement;
  38.         
  39.     if (oCurrent == null) setCurrent();
  40.  
  41.     iCurrent = oCurrent.id.substr(oCurrent.id.indexOf("_") + 1);
  42.     oCurrent.parentElement.style.backgroundImage = "none";
  43.     oCurrent.style.color = normColor;
  44.     oCurrent.style.cursor = "hand";    
  45.     oCurrent.style.textDecoration = "";     
  46.     document.all["content_" + iCurrent].style.display = "none";
  47.  
  48.  
  49.     oItemWrap.style.backgroundImage = "url(toccolor.gif)";
  50.     oItem.style.cursor = "default";
  51.     oItem.style.color = highColor;
  52.     oItem.style.textDecoration = "none";
  53.  
  54.     hzLine.style.top = oItemWrap.offsetTop - 73;
  55.     hzLine.style.visibility = "visible";
  56.  
  57.     try{
  58.         document.all["content_" + iItem].style.display = "inline";
  59.     }catch(e){
  60.         selectIt(iItem);
  61.     }
  62.  
  63.     oCurrent = oItem;
  64.     iFocus = iItem;
  65.     
  66.     if (event != null) event.returnValue = false;
  67. }
  68.  
  69. function setCurrent(){
  70.     try{
  71.         oCurrent = document.all.menu_1;
  72.     }catch(e){
  73.         setCurrent();
  74.     }
  75. }
  76.  
  77. function doNothing(){
  78.     event.returnValue = false;    
  79. }
  80.  
  81. // Key handler
  82. //====================================================
  83.  
  84. // general purpose key handler
  85. function keyhandler()
  86. {
  87.     var iMenuCount = 5;
  88.     var iKey = window.event.keyCode;
  89.  
  90.     //up, down and tab keys for toc
  91.     switch(iKey){
  92.         case 0x26:{
  93.             iFocus = iFocus - 1;
  94.             if (iFocus < 1) iFocus = iMenuCount;
  95.             document.all["menu_" + iFocus].focus();
  96.             break;
  97.         }
  98.         case 0x28:{
  99.             iFocus = iFocus + 1;
  100.             if (iFocus > iMenuCount) iFocus = 1;
  101.             document.all["menu_" + iFocus].focus();
  102.  
  103.             break;
  104.         }
  105.         
  106.     }
  107.  
  108.  
  109.     // Function key f5
  110.     if (iKey == 0x74) {
  111.         window.event.cancelBubble = true;
  112.         window.event.returnValue  = false;
  113.         return false;
  114.     }
  115.  
  116.     //control hotkeys
  117.     if(window.event.ctrlKey) {
  118.         switch(iKey) {
  119.  
  120.             case 0x35:  // 5
  121.             case 0x65:  // keypad 5
  122.  
  123.             case 0x41:    // A
  124.             case 0x46:  // F
  125.             case 0x4e:  // N
  126.             case 0x4f:  // O
  127.             case 0x50:  // P
  128.  
  129.                {    
  130.                 window.event.cancelBubble = true;
  131.                 window.event.returnValue  = false;
  132.                 return false;
  133.             }
  134.          }
  135.     }
  136.         
  137.     //test for escape key and bail if appropriate
  138.     if(window.event.keyCode == 0x1b) {
  139.         self.close();
  140.     }
  141. }
  142.  
  143. // kill the context menu 
  144. function killcontext()
  145. {
  146.     window.event.returnValue = false;
  147. }
  148.  
  149. //kill the right mouse
  150. function killrightmouse(){
  151.     window.event.returnValue = false;
  152.     window.event.cancelBubble = true;
  153.     return false;    
  154. }
  155.  
  156.