// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
Ajax.Responders.register({
  onCreate   : function() {
    new Overlay().show($('ajax_table'), { 
                                                      modal : true,
                                                      animate : true,
                                                      opacity : 0.9,
                                                      bckg_opacity : 0.7 });
  },
  onComplete : function(request, transport) {
    var flash;
    text = transport.responseText.match(/var flash = .*;/)[0];
    if (text) {
      flash = text.match(/'.*'/)[0].gsub(/'/, '');
      $('flash').innerHTML = flash;
      $('flash').show();
      setTimeout("Effect.Fade('flash');", 10000);
      // window.scrollTo(0,0);
    }
  }
});

function fade_flash() {
  setTimeout("Effect.Fade('flash');", 4000);
}

function paginate_listed(){
  $$('#listed_pagination .pagination a').each(function(item) {
    item.href = item.href + '#listed';
  });
}


function paginate_purchased(){
  $$('#purchased_pagination .pagination a').each(function(item) {
    item.href = item.href + '#purchased';
  });
}

function paginate_sold(){
  $$('#sold_pagination .pagination a').each(function(item) {
    item.href = item.href + '#sold';
  });
}

function paginate_looking_for(){
  $$('#looking_for_pagination .pagination a').each(function(item) {
    item.href = item.href + '#looking_for';
  });
}