// McHugh Estate Agents -- Javascript to support the property searches. (jeremy.jones@s1now.com)

function MchughSearch () { ; }

function rememberMe ( f )
{
    var cs = new MchughSearch ();
    cs.priceLo   = f.priceLo.value;
    cs.priceHi   = f.priceHi.value;
    cs.Location  = f.Location.options[f.Location.selectedIndex].value
    cs.minBeds   = f.minBeds.options[f.minBeds.selectedIndex].value
    cs.propType  = f.propType.options[f.propType.selectedIndex].value;
    if (f.keywords) cs.keywords  = f.keywords.value;
    else cs.keywords = "";

    navigator.mchughSearch = cs;
}


function presetForm (f)
{
   if (navigator.mchughSearch)
   {
      var j;
      if (j = navigator.mchughSearch.priceLo)  f.priceLo.value = j
      if (j = navigator.mchughSearch.priceHi)  f.priceHi.value = j
      if (j = navigator.mchughSearch.keywords) if (f.keywords) f.keywords.value = j;

      var ps = new Array ('Location','minBeds','propType');

      for (var i=0; i < ps.length; ++i)
         for (var k=0; k < f[ps[i]].options.length; ++k)
            if (f[ps[i]].options[k].value == navigator.mchughSearch[ps[i]] && (! f[ps[i]].options[k].text.match(/^-+$/) ))
                f[ps[i]].selectedIndex = k;
   }
}