function test(obj) {
  obj.s.value = obj.s.value.replace(/^\s+/, '').replace(/\s+$/, '');
  obj.s.value = obj.s.value.replace('  ', ' ');

  if (obj.s.value.length < 3) {
    alert('Error! Search string too short. Minimu 3 and maximum 30 symbols.');
    obj.s.focus();
    return false;
  } else if (obj.s.value.length > 30) {
    alert('Error! Search string too long. Minimu 3 and maximum 30 symbols.');
    obj.s.focus();
    return false;
  }
  return true;
}


var searchInputIsActive = false;
var CtrlUp = false;

function Init() {
  if (document.getElementById) {
    if (document.forms['Sform'].s) {
      document.Sform.s.onfocus = function () {
        searchInputIsActive = true;
        if (document.Sform.s.select && CtrlUp) { document.Sform.s.select(); }
      };

      document.Sform.s.onblur = function () { searchInputIsActive = false; CtrlUp = false; };
      document.onkeydown = KeyHook;
    }
  }
}

function KeyHook(e) {
  var code;
  if (!e) var e = window.event;
  if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;

  if ((code == 13) && (e.ctrlKey == true)) document.Sform.submit();

  if (!searchInputIsActive) {
    if ((code == 37) && (e.ctrlKey == true)) {
      var dest = document.getElementById('prev');
      if (dest) location.href = dest.href;
    }
    if ((code == 39) && (e.ctrlKey == true)) {
      var dest = document.getElementById('next');
      if (dest) location.href = dest.href;
    }
  }

  if ((code == 38) && (e.ctrlKey == true) && document.Sform.s) {
    CtrlUp = true;
    document.Sform.s.focus();
  }
}


function testN(event, obj) {
  if (((event.keyCode<48) || (event.keyCode>57)) && (event.keyCode!=13))
    event.returnValue=false;
}


