currentInput = null;

function setFocusEvent(inp)
{
  inp.onfocus = function()
  {
    currentInput = this;
  }

  inp.onblur = function()
  {
    currentInput = null;
  }
}

var inputs = document.getElementsByTagName('input');

for (var i = 0; i < inputs.length; i ++) if (inputs[i].type == 'text' || inputs[i].type == 'file') setFocusEvent(inputs[i]);

inputs = document.getElementsByTagName('textarea');

for (var i = 0; i < inputs.length; i++) setFocusEvent(inputs[i]);

document.onkeydown = function (e)
{
  if (!currentInput)
  {
    if (!e)
    {
      e = window.event;
    }

    if (e.ctrlKey)
    {
      var code = e.keyCode ? e.keyCode : (e.which ? e.which : 0);
      var arrow = code == 37 ? document.getElementById('prev_page') : (code == 39 ? document.getElementById('next_page') : 0);

      if (arrow)
      {
        location.href = arrow.href
      }
    }
  }
}