function $(id) {return document.getElementById(id);}

function request() {
  var ajax=null;
  try {ajax=new XMLHttpRequest();}
  catch(e) {
    try {ajax=new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e) {ajax=new ActiveXObject("Microsoft.XMLHTTP");}
  }
  return ajax;
}

function suggest(field) {
  if (field.value == 'Search...') {
    field.value = '';	
  }
  else {
    if (field.value.length >= 2) {
      var ajax=request();
      ajax.onreadystatechange = function() {
        if(ajax.readyState == 4 && ajax.status == 200) {
          $('suggest_container').innerHTML=ajax.responseText;
          field.style.backgroundImage = '';
          $('suggest_container').style.display = 'block';
        }
        if(ajax.readyState > 0 && ajax.readyState < 4) {field.style.backgroundImage = 'url(/images/loading.gif)';}
      }
      ajax.open("GET","/Suggest/"+field.value+'/'+Math.random(),true);
      ajax.send(null);
    }
    else {$('suggest_container').style.display = 'none';}
  }
}

function hide_suggest() {setTimeout(function() {$('suggest_container').style.display = 'none';},500);}

function c(id) {top.location.href = id.firstChild.href;}

function e(id) {window.open(id.href); return false;}