/*****************************************
 *             noScroll.js               *
 *        by David "Sp0ng3h" Amey        *
 *    Prevents browser scrolling with    *
 *    mousewheel over certain elements   *
 *****************************************/

function cancelEvent(e)
{
	e = e ? e : window.event;
	if(e.stopPropagation)
		e.stopPropagation();
	if(e.preventDefault)
		e.preventDefault();
	e.cancelBubble = true;
	e.cancel = true;
	e.returnValue = false;
	return false;
}

function hookEvent(element, eventName, callback)
{
	if (typeof(element) == "string")
		element = document.getElementById(element);

	if (element == null)
		return;

	if (element.addEventListener)
	{
		if (eventName == 'mousewheel')
		{
			element.addEventListener('DOMMouseScroll', callback, false);  
		}
		element.addEventListener(eventName, callback, false);
	}
	else if (element.attachEvent)
	{
		element.attachEvent("on" + eventName, callback);
	}
}

function noScroll(id)
{
	hookEvent(id, 'mousewheel', cancelEvent);
}