/**
 * SWFMW
 * 
 * This file is a lesser extension of SWFMacMouseWheel v1.0 (http://blog.pixelbreaker.com/)
 * 
 * SWFMW (c) 2009 Digital Trust, inc. is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * @author	Masahiro Yamada <yamada@dtrust.com>
 * @version	1.0
 */

function SWFMW (so) {
	this.so = so;
	this.init();
}
SWFMW.prototype = {
	handle: function (delta) {
		//document[this.so.getAttribute('id')].externalMouseEvent(delta);
	},
	listen: function(evt) {
		var delta = 0;
		if(typeof(evt)=='undefined') evt = window.event;
		if(evt.wheelDelta) {
			delta = evt.wheelDelta / 40;
		} else if(evt.detail) {
			delta = -evt.detail;
		}
		if(delta != 0) SWFMW.instance.handle(delta);
	},
	init: function() {
		SWFMW.instance = this;
		var ua = navigator.userAgent;
		if(ua.match("Gecko") && !ua.match("Webkit") && !ua.match("Safari")) {
			window.addEventListener('DOMMouseScroll', SWFMW.instance.listen, false);
		} else {
			document.onmousewheel = this.listen;
		}
	}
}
