
var websiteContextMenu = {};

websiteContextMenu._doCommand = function (command) {
  var dispatcher = document.commandDispatcher;
  var controller = dispatcher.getControllerForCommand(command);
  if (controller && controller.isCommandEnabled(command))
    controller.doCommand(command);
}
websiteContextMenu.cut = function () {
  this._doCommand("cmd_cut");
}

websiteContextMenu.copy = function () {
  this._doCommand("cmd_copy");
}

websiteContextMenu.paste = function () {
  this._doCommand("cmd_paste");
}


window.addEventListener("load",function () {
  
  var menu = document.getElementById("context-menu");
  menu.addEventListener("popupshowing",function () {
    
  },false);
  
  var cut = document.getElementById("menu-cut");
  cut.addEventListener("command", function () {
    websiteContextMenu.cut();
  },false);
  
  var copy = document.getElementById("menu-copy");
  copy.addEventListener("command", function () {
    websiteContextMenu.copy();
  },false);
  
  var paste = document.getElementById("menu-paste");
  paste.addEventListener("command", function () {
    websiteContextMenu.paste();
  },false);
  
},false);
