/*

  No right clicking on images

  Requires:
    jquery.js

  Define elsewhere:
    noRightClickMsg <- Message to show when image is right clicked

  v1.0 18/07/2010, Hayo Baan
       Initial version

  v1.1 27/07/2010, Hayo Baan
       Improved handling of Opera browser
       jQuery adaptations


*/

// Prevent right clicking on an object
function noRightClick(e) {
    if (!e) {
        var e = window.event;
    }
    if (e.button == 2) {
        if (e.type != "mousedown" || navigator.userAgent.search(/Opera/) < 0) {
            if (!noRightClickMsg) {
                alert("Image is Copyrighted.");
            } else {
                alert(noRightClickMsg);
            }
        }
        return false;
    } else {
        return true;
    }
}

// Set no right click handler on all images
$(document).ready(function () {
    $("img").mousedown(noRightClick);
    $("img").mouseup(noRightClick);
});

