﻿/**************************************************************************
  Browser Detection:
***************************************************************************/
function isNetscape(v) {
  /*
  ** Check if the browser is Netscape compatible
  **    v  version number
  ** returns  true if Netscape and version equals or greater
  */
  return isBrowser("Netscape", v);
  }
function isMicrosoft(v) {
  /*
  ** Check if the browser is Microsoft Internet Explorer compatible
  **    v  version number
  ** returns  true if MSIE and version equals or greater
  */
  return isBrowser("Microsoft", v);
  }
function isBrowser(b,v) {
  /*
  ** Check if the current browser is compatible
  **  b  browser name
  **  v  version number (if 0 don't check version)
  ** returns true if browser equals and version equals or greater
  */
  browserOk = false;
  versionOk = false;
  browserOk = (navigator.appName.indexOf(b) != -1);
  if (v == undefined) v = 0;
  if (v == 0) versionOk = true;
  else  versionOk = (v <= parseInt(navigator.appVersion));
  //alert('v: ' + v + '  Browser: ' + browserOk + '  Version: ' + versionOk);
  return browserOk && versionOk;
  }
/**************************************************************************/

function DisableKeyboardMouse() {
  if (isMicrosoft()==true) 
  {
    document.onkeydown=null;
    document.onkeyup=null;
    document.onkeypress=null;
    document.onmouseup=null;
    document.oncontextmenu=null;
  }
  else 
  {
    document.captureEvents(Event.KEYUP);
    document.captureEvents(Event.KEYDOWN);
    document.captureEvents(Event.KEYUP);
    document.captureEvents(Event.KEYPRESS);
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=null;
    document.onkeypress=null;
    document.onkeydown=null;
    document.onkeyup=null;
  }
  document.oncontextmenu = SL_MouseEvent;
  document.onkeypress=SL_KeyEvent;
  document.onkeydown=SL_KeyEvent;
  document.onkeyup=SL_KeyEvent;
}

function EnableKeyboardMouse() {
  void(document.onkeydown=null);
  void(document.onkeyup=null);
  void(document.onkeypress=null);
  void(document.oncontextmenu=null);
}

function SL_GetMessageNotAllowed() {
  return 'Sorry, this action is not allowed.';
}

function SL_MouseEvent (e) {
  alert(SL_GetMessageNotAllowed());  
  return false;
}
function SL_KeyEvent (e) {
  var bDisplaymessage = 1;
  /*
  if (isMicrosoft()==true) {
    //if (event.ctrlKey==true) bDisplaymessage = 0;
  } 
  else
  {
  }
  */
  if (bDisplaymessage==1) alert(SL_GetMessageNotAllowed());
  return false;
}

