//////HINT functions//////
var hintcount = 0;
var hintactive = -1;

function look(obj, e) {
  var e = e || window.event;
  if (e) {
    var c = e.keyCode;

    if ((c==40 || c==38) && hintcount>0) {
      if (hintactive >=0 && $('HINT').childNodes[0].childNodes[hintactive])
        $('HINT').childNodes[0].childNodes[hintactive].className = '';

      if (c==40)
        hintactive = (hintactive == hintcount-1) ? 0 : hintactive+1;
      else
        hintactive = (hintactive <= 0) ? hintcount-1 : hintactive-1;

      obj.value = $('HINT').childNodes[0].childNodes[hintactive].innerHTML;
      $('HINT').childNodes[0].childNodes[hintactive].className = 'ac';
      return false;
    }

    if (c==13 || c==27) {
      Hide('HINT');
      removeEvent(document.body,'click',HideHint);
    }

    if (c==13 || c==27 || c==16 || c==17 || c==18 || (c>=35 && c<=40)) return false;
  }

  if (obj.value.trim().length>2)
    loadJS('/hint.php?s='+encodeURIComponent(obj.value));
  else if ($('HINT').style.display != 'none') {
    Hide('HINT');
    removeEvent(document.body,'click',HideHint);
  }
}

function sethint(str, cnt) {
  hintactive = -1;
  hintcount = cnt;

  if (cnt<=0) {
    Hide('HINT');
    removeEvent(document.body,'click',HideHint);
    return 0;
  }

  $('sStR').setAttribute("autocomplete","off");
  $('HINT').style.width = $('sStR').offsetWidth;
  var x = getGlobalPos($('sStR'));
  $('HINT').style.top = x.y+$('sStR').offsetHeight;
  $('HINT').style.left = x.x;

  $('HINT').innerHTML = str;
  if ($('HINT').style.display != '')
    addEvent(document.body,'click',HideHint);
  Show('HINT');
}

function HideHint(e) {
  if (hintcount<=0) return false;

  var e = e || window.event;
  if (e) {
    var t = e.target || e.srcElement;
    if (t.name == 'part') return false;
  }

  Hide('HINT');
  removeEvent(document.body,'click',HideHint);
}

function ReturnHint() {
  if (hintcount<=0) return false;
  Show('HINT');
  addEvent(document.body,'click',HideHint);
}

//Click on hint window
function hCl(e) {
  var e = e || window.event;
  if (e) {
    var t = e.target || e.srcElement;
    if (t.tagName=='LI') {
      $('sStR').value = t.innerHTML;
      _('SForm').submit();
    }
  }
  return false;
}

//overmouser for explorer in hint window
function hOver(n, e) {
  var e = e || window.event;
  if (!e) return;
  var t = e.target || e.srcElement;
  if (t.tagName=='LI') t.style.backgroundColor = (n!=0) ? '#FFFFFF' : '#f2f6ff';
}

