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

// var $j = jQuery.noConflict();

jQuery(document).ready(function($){

  // $("#ended_at_unavailable").click(function(){
  //   if($(this).attr("checked")){
  //     $("#event_ended_at").hide();
  //   } else {
  //     $("#event_ended_at").show();
  //   }
  // });
  
  $('.gallery a').lightBox({
			imageLoading:			'/images/lightbox-ico-loading.gif',
			imageBtnPrev:			'/images/lightbox-btn-prev.gif',
			imageBtnNext:			'/images/lightbox-btn-next.gif',
			imageBtnClose:		'/images/lightbox-btn-close.gif',
			imageBlank:				'/images/lightbox-blank.gif'
   });

  $(".toggler").click(function(){
    $("#" + $(this).attr("rel")).toggle();
    if($(this).attr("tagName") == "A"){
      return false;
    }
  });
  
  $(".toggler").each(function(){
    // Hide unless current
    if( !$("#" + $(this).attr("rel")).hasClass('current')){
      $("#" + $(this).attr("rel")).hide();
    }
    // For pages that return an error, make sure we show items that were toggled open
    if($(this).attr('checked') == true){
      $("#" + $(this).attr("rel")).show();
    }
  });
  
});

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);
});