document.f.q.focus();

function DoSelect(obj)
{
  var str = "User\'s name";

  ls = document.getElementById('sel');
  ls.removeAttribute('id');

  var text = '';
  switch (ls.getAttribute('name'))
  {
    case '1': text = 'All'; break;
    case '2': text = "User's Journal"; break;
    case '3': text = 'Communities'; break;
    case '4': text = 'Profiles'; break;
  }
  ls.innerHTML = '<a href="#" onclick="javascript:DoSelect(this)" rel="nofollow">'+text+'</a>';

  var l = obj.parentNode;
  l.id = 'sel';
  switch (l.getAttribute('name'))
  {
    case '1': text = 'All'; break;
    case '2': text = "User's Journal";break;
    case '3': text = 'Communities'; break;
    case '4': text = 'Profiles'; break;
  }
  l.innerHTML = text;

  var sbox = document.getElementById('sbox');
  var input = document.getElementById('q');

  if (l.getAttribute('name') != '2') {
    var p = document.getElementById('param');
    sbox.removeChild(p);
    input.style.width = '445px';
  }
  else {
    input.style.width = '343px';
    var span = document.createElement('span');
    span.id = 'param';
    var width;
    if (navigator.userAgent.indexOf("Opera/8") != -1 || navigator.userAgent.indexOf("Opera/7") != -1)
      width = '96px';
    else
      width = '88px';
    span.innerHTML = '<input type="text" style="color:#aaa;width:'+width+'" id="u" name="u" size="10" maxlength="128" tabindex="2" value="'+str+'" /><label for="u" accesskey="u"></label>';
    sbox.appendChild(span);

    var u = document.f.u;
    var f = function() { u.style.color = '#333'; if (u.value == str) u.value = ''; };
    var b = function() { if (u.value == '') { u.value = str; u.style.color = '#aaa'; } };
    u.onfocus = f;
    u.onblur = b;
  }

  document.f.q.focus();
}

function DoSubmit()
{
  var str = "User\'s name";
  var q = document.f.q;

  var arr = document.f.getElementsByTagName('li');
  for (var i=1; i<4; i++) {
    if (arr[i].id != '') break;
  }

  var name = arr[i].getAttribute('name');
  if (name=='2') {
    var u = document.f.u;
    if (u) {
      if (u.value == str) u.value = '';
      if (u.value != '') {
        if (q.value == '') q.value = 'inurl:'+u.value;
        else {
          var add = 'inurl:'+u.value;
          if (q.value.indexOf(add) == -1) q.value = q.value+' '+add;
        }
        u.value = '';
      }
    }
  }
  else if (name=='3') {
    var add = 'more:communities';
    if (q.value.indexOf(add) == -1) q.value = q.value+' '+add;
  }
  else if (name=='4') {
    var add = 'more:profiles';
    if (q.value.indexOf(add) == -1) q.value = q.value+' '+add;
  }
}

function addEngine() {
  if ((typeof window.external == 'object') && (typeof window.external.AddSearchProvider == 'function'))
    window.external.AddSearchProvider('http://ljsearch.org/ff/ljsearch-org.xml');
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addSearchEngine == 'function'))
    window.sidebar.addSearchEngine('http://ljsearch.org/ff/ljsearch-org.src', '', 'ljsearch-org');
  else alert("You will need a browser which supports OpenSearch or Sherlock to install this plugin.");
}
