// Script to update the shopbot search form

// p: possible input of search form
// v: value
function kk_updateSearchForm(p, v) {
  v=unescape(v);
  if(p)
  {
    if (p.type == 'text' || p.type == 'hidden')
    {
      p.value = kk_decodeParams(v);
    }
    else
      if (p.type == 'select-one')
      {
        for( i = 0; i < p.length; i++)
        {
          if (p.options[i].value == v)
            p.selectedIndex = i;
        }
      }
      else if (p.type == 'checkbox')
      {
        p.checked = true;
      }
      else if (p[0])
      {
        for( i = 0; i < p.length; i++ )
        {
          if (p[i].value == v)
            p[i].checked=true;
        }
      }
  }
}

function kk_decodeParams(v) {
  var q = v;
  while (q.indexOf("&#39;") > -1) q = q.replace("&#39;", "'");
  while (q.indexOf("&quot;") > -1) q = q.replace("&quot;", "\"");
  while (q.indexOf("&#34;") > -1) q = q.replace("&#34;", "\"");
  while (q.indexOf("&amp;") > -1) q = q.replace("&amp;", "&");
  return q;
}
