$j = jQuery.noConflict();

jQuery(document).ready(function($){
  
  // remove authenticity token from foxycart forms
  // otherwise they show up as custom attributes
  $(".foxycart input[name=authenticity_token]").remove()
  
  $(".toggler").click(function(){
    $("#" + $(this).attr("rel")).toggle();
    return false;
  });

  $(".toggler").each(function(){
    $("#" + $(this).attr("rel")).hide();
  });
  
  

  $().iconoline({
    defaultSetsPath: '/iconoline/icons/'
  });


  // $('a[rel*=facebox]').facebox() 

  // turn links into video and sound players
  // $("a.video").media({ width: 280, height: 210 });
  // $("a.sound").media({ width: 280, height: 20 });

  // helper functions for Ajaxifying standard links and forms, and evaluating returned Javascript
    // $("a.rjs").click( function() {
    //   $.ajax({
    //       url: this.href,
    //       dataType: "script"
    //   });
    //   return false;
    // });
    // 
    // // AJAX Forms
    // $("form.rjs").ajaxForm({
    //   dataType: 'script',
    //   resetForm: true
    // });
    // 
    // // delete links using button_to
    // // PROBLEM - AJAX created items will not be deletable via this method
    // // may need livequery or listen plugin
    // $('input[name=_method][value=delete]')
    // .siblings('[class=rjs]')
    // .parents('form.button-to')
    // .ajaxForm({
    //     dataType: 'script'
    // })
    // 

  
});

jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept",
    "text/javascript")} 
});

jQuery(document).ajaxSend(function(event, request, settings) {
  if (typeof(AUTH_TOKEN) == "undefined") return;
  // settings.data is a serialized string like "foo=bar&baz=boink" (or null)
  settings.data = settings.data || "";
  settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
});