function trim(str)
{
    if (str == null || !str.replace) 
      return "";
    return(str.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1'));
}

function doSearch()
{
  var frm = document.search;
  var engine;
  var text;
  
  text = trim(frm.query.value);
  if (text == "")
  {
    alert('Please enter the text to search for.');
    frm.query.focus();
    return false;
  }

  return true;
}

function getCookie(cookieName, defValue)
{
  if (document.cookie.length > 0)
  {
    var nStart = document.cookie.indexOf(cookieName + "=")
    if (nStart != -1)
    { 
      nStart = nStart + cookieName.length + 1 
      var nEnd = document.cookie.indexOf(";", nStart)
      if (nEnd == -1) nEnd = document.cookie.length
      return unescape(document.cookie.substring(nStart,nEnd))
    } 
  }
  return defValue;
}

function setCookie(cookieName, value, nDays)
{
  var date = new Date();
  date.setTime(date.getTime() + (nDays * 24 * 60 * 60 * 1000));
  document.cookie = cookieName + "=" + escape(value) + "; expires=" + date.toGMTString()+ "; path=/";
}

