if (window.Event)
  document.captureEvents(Event.MOUSEUP);

function nocontextmenu() {
//  alert(event.srcElement.childNodes.length);
  var childObject = event.srcElement.childNodes;
  if (event.srcElement.tagName == 'IMG' || childObject.length > 0 && childObject.item(0).tagName == 'IMG') {
    event.cancelBubble = true, event.returnValue = false;
    return false;
  }
}

function norightclick(e) {
  if (window.Event) {
    if (e.which == 2 || e.which == 3) return false;
  }
  else if ((event.button == 2 || event.button == 3)) {
    if (event.srcElement.tagName == 'IMG') {
      event.cancelBubble = true, event.returnValue = false;
      return false;
    }
  }
}

if (document.layers)
  document.captureEvents(Event.MOUSEDOWN);

document.oncontextmenu = nocontextmenu;
document.onmousedown = norightclick;
document.onmouseup = norightclick;

document.ondragstart = nocontextmenu;
document.ondrag = nocontextmenu;
document.ondragend = nocontextmenu;