//capture the keypress for netscape
  function getKeyNetscape(e){
    var cancelKeypress=true;
  if(navigator.appName== 'Netscape'){
    //if alt-left/alt-right/ctrl-N/backspace/F1-F12, cancel action.
    if((isAltLeftOrRight(e))||(isInvalidControlKey(e))||(isBackspace(e))||(isFunctionKey(e))){
      cancelKeypress=false;
    }
  }
  return cancelKeypress;  
  }  


//if key pressed is alt-left or alt-right  
  function isAltLeftOrRight(e){
    if(e.altKey)
    if(e.keyCode==37 || e.keyCode==39)
        return true;
    return false;
  }
  
//if Ctrl+any key (except for "F","C","V"). works only for Netscape
  function isInvalidControlKey(e){
    if(e.ctrlKey){
      //102:Ctrl-F; 99:Ctrl-C; 118:Ctrl-V
      if((e.charCode!=102)&&(e.charCode!=99)&&(e.charCode!=118)){
        e.returnValue = false;
    e.cancelBubble = true;
    e.keyCode = 0;
        return true;
      }
    }
    return false;
  }
  
  //if Ctrl+any key (except for "F","C","V"). works only for IE
  function isInvalidIEControlKey(e){
    if(e.ctrlKey){
      //70:Ctrl-F; 67:Ctrl-C; 86:Ctrl-V
      if((e.keyCode!=70)&&(e.keyCode!=67)&&(e.keyCode!=86)){
        e.returnValue = false;
        e.cancelBubble = true;
        /* Added try-catch to remove javascript error in file input */
        try {
          e.keyCode = 0;
        } catch(e){}
        return true;
      }
    }
    return false;
  }
  
//if backspace is pressed
  function isBackspace(e){
    if(e.keyCode==8){
      //catch backspace on readonly
      if (e.target.type == 'text' && e.target.getAttribute("readOnly")) 
        return true;
      if((e.target.type!='text')&&(e.target.type!='file')&&(e.target.type!='textarea')&&(e.target.type!='password'))
        return true;
    }    
    return false; 
  }


//if F1-F12 is pressed (for Netscape only)
  function isFunctionKey(e){
    if((e.keyCode>111) && (e.keyCode<124)){
      return true;
    }    
    return false; 
  }
  
//if F1-F12 is pressed (for IE only)
  function isFunctionKeyIE(e){
    if((e.keyCode>111)&&(e.keyCode<124)){
      /* Added try-catch to remove javascript error in file input */
      try {
        if (e.keyCode==112) {
          window.onhelp = function(){return false;}
          document.onhelp = function(){return false;}
        }
        e.keyCode=0;
      } catch(e){}
      return true;
    }
    return false;
  }
  
//is Enter
  function isEnter(e){
    if(e.keyCode==13){
    if(document.activeElement.type!='textarea') return true;
    }
    return false;
  }
   
// capture the keypress for IE
  function getKeyIE(){
    if(isIE()){
      //if alt-left or alt-right
      if(isAltLeftOrRight(event)){
        return false;
      }
      //if invalid ctrl-key
    if(isInvalidIEControlKey(event)){
      return false;
    }
    //if function key
      if(isFunctionKeyIE(event)){
        return false;
      }
      //if backspace
      if(event.keyCode==8){

      if((document.activeElement.type!='text')&&(document.activeElement.type!='file')&&(document.activeElement.type!='textarea')&&(document.activeElement.type!='password'))
        return false;
      //catch backspace on readonly
      if (document.activeElement.type == 'text' && document.activeElement.getAttribute("readOnly")) 
        return false;
      }
      //if enter
      if(event.keyCode==13){
      if((document.activeElement.type=='password')||(document.activeElement.type=='text'))
        return false;
      }
  }
  }
  
  // capture the mousewheel to prevent scrolling through previous pages
  function captureMouseWheel(e){
    return (!e.shiftKey);
  }


  //set capture events for netscape
  if(!isIE()){
    document.onkeypress=getKeyNetscape;
  } 