// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function toggle_tag_box() {
  new Effect.toggle('tag_box_body','slide', {
  	duration: 0.5
  });
  $('tag_box_toggle_link').firstChild.nodeValue = Element.visible('tag_box_body') ? 'Show' : 'Hide'
}

function tag_box_submit() {
  q = $F('tag_box_field').strip().toLowerCase()
  self.location = '/tag/' + escape(q)
  return false;
}

function vote(id, rating, div) {
  new Effect.Fade(div, {
  	afterFinish: function() {Element.update(div,'<img src="/images/icons/accept.gif" alt="Rated" title="You have rated this listing" />')}
  });
  
  new Ajax.Request('/listing/vote/'+id+'?r='+rating, {
    method:     'post'
  });

  new Effect.Appear(div, {queue: 'end'})
  
  return false; // Don't follow link
}
