var utils = {};

/**
 * Controls native scroll behaviour
 * @return {Object} => {disable, enable}
 */
utils.scroll = (function() {
  // 37 - left arror, 38 - up arrow, 39 right arrow, 40 down arrow
  var keys = [38, 40];

  function preventDefault(e) {
    e = e || window.event;
    e.preventDefault();
    e.returnValue = false;  
  }

  function wheel(e) {
    preventDefault(e);
  }

  function keydown(e) {
    for (var i = keys.length; i--;) {
      if (e.keyCode === keys[i]) {
          preventDefault(e);
          return;
      }
    }
  }

  function disableScroll() {
    if (window.addEventListener) {
        window.addEventListener('DOMMouseScroll', wheel, false);
    }
  	window.onmousewheel = document.onmousewheel = wheel;
  	document.onkeydown = keydown;
  }

  function enableScroll() {            
  	if (window.removeEventListener) {
        window.removeEventListener('DOMMouseScroll', wheel, false);
    }
    window.onmousewheel = document.onmousewheel = document.onkeydown = null; 
  }	

  return {
  	disable : disableScroll,
  	enable  : enableScroll
  };

})();