// all prototype plugins should go here.  (prototype obviously required)

/*
included plugins:
	mousewheel support
*/


/*
mousewheel support
	http://andrewdupont.net/2007/11/07/pseudo-custom-events-in-prototype-16/
usage:
	Event.observe(element_or_id_to_observe, "mouse:wheel", handler_fn);
		'event' 
			passed to handler_fn as a parameter
		'event.stop()' 
			prevents default behavior of the mousewheel
		'event.memo.delta' 
			indicates wheeling up or down with 1 or 0 respectively
example:
	Event.observe(wrapper, "mouse:wheel", function(event){
		event.stop();  
		event.memo.delta>0 ? up.onclick(): down.onclick();
	});	
*/
(function() {
  function wheel(event) {
    var realDelta;

    // normalize the delta
    if (event.wheelDelta) // IE & Opera
      realDelta = event.wheelDelta / 120;
    else if (event.detail) // W3C
      realDelta = -event.detail / 3;

    if (!realDelta) return;

    var customEvent = event.element().fire("mouse:wheel", {
     delta: realDelta });
    if (customEvent.stopped) event.stop();
  }

 document.observe("mousewheel",     wheel);
 document.observe("DOMMouseScroll", wheel);
})();