/*
plugin che inibisce la selezione del testo e il menu contestuale.
un po' grezzo, ma sembra funzionare (pochi test fatti)...
*/


(function($) {
  $.fn.nocopy = function() {
    
    return this.each(function() {
      var $this = $(this);
      $this.rightClick( function(e) {
    		window.alert("Testi e immagini di questo sito sono proprieta' esclusiva di Just Italia S.r.l.");
    	});
      $this.mousedown(function() {return false;});
      $this.bind('selectstart', function() {return false;});
      $this.css({'MozUserSelect':'none','cursor':'default'}).attr("unselectable","on");
    }
    )
  };

$.fn.rightClick = function(handler) {
	$(this).each( function() {
		$(this).mousedown( function(e) {
			var evt = e;
			$(this).mouseup( function() {
				$(this).unbind('mouseup');
				if( evt.button == 2 ) {
					handler.call( $(this), evt );
					return false;
				} else {
					return true;
				}
			});
		});
		$(this)[0].oncontextmenu = function() {
			return false;
		}
	});
	return $(this);
}
})(jQuery);



