var StoreFinder = Class.create({
  initialize: function(element){
    this.element = $(element);

    this.element.observe("submit", this.submit_event.bind(this));
  },

  submit_event: function(event){
    event.stop();
    
    new Ajax.Request(this.element.action, {
      method: 'get',
      onSuccess: this.requestResponse.bind(this),
      parameters: this.element.serialize()
    });
  },

  requestResponse: function(transport){
    $('store_finder_result').update(transport.responseText).highlight({restorecolor: '#ffffff'});
  }
});


document.observe("dom:loaded", function(){
  if( $('store_finder') ){ new StoreFinder($('store_finder')) }

  $('q').observe("focus", function(event){ this.value = ""; });
});

