var Filter = {
    
  submit : function(host, port, base) {
    var parms = "";
    region = this.selected_text($('region_id'));
    if (region.length > 0) {
      parms += "/" + this.prepareParm(region);
      country = this.selected_text($('country_id'));
      if (country.length > 0) {
        parms += "/" + this.prepareParm(country);
        city = this.selected_text($('city_id'));
        if (city.length > 0) {
          parms += "/" + this.prepareParm(city);
        }
      }
    }
    base_url = 'http://' + host
    base_url += port != '80' && port != '443' ? ':' + port : '';
    base_url += base;
    frm = $('frmFilter');
    frm.action = base_url + parms;
    frm.submit();
  },
  
  init : function() {
    var hide_availability = eval(getCookie('hide_availability'));
    if (!hide_availability) {
      this.show();
    }
  },
  
  show : function() {
    Element.show('availability');
    Element.hide('show_availability');
    Element.hide('search1');
    setCookie('hide_availability', 'false', null, '/');
  },
  
  hide : function() {
    Element.hide('availability');
    Element.show('show_availability');
    Element.show('search1');
    setCookie('hide_availability', 'true', null, '/');
  },
  
  selected_text : function(sel) {
    return sel.value > 0 ? sel.options[sel.selectedIndex].text : "";
  },

  prepareParm : function(parm) {
    return escape(parm.replace(/ /g, "_"));
  }  
};
