// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(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);
});

$(function() {
   $("a.rjs").livequery('click', function() {
       $.ajax({ url: this.href, dataType: "script"});
       return false;
   });
	 $("form.rjs").livequery(function() {
      $(this).ajaxForm({ dataType: 'script'});
   });
});

function init_roadie(){

	$('#how_we_did').click(function() {
		if($('#bg_howto').css("display") == "none"){
			$('#bg_howto').toggle();
			$.scrollTo("#bg_howto", {duration:1500});
		} else {
			$('#bg_howto').toggle();
			$.scrollTo("#bg_header", {duration:1500});
		}
		return false;
	});
	
	$('#search_button').click(function() {
		$('#loader').fadeIn();
		$('#search_button').hide();
		$('#results').fadeOut();
	});
	
	$('#import_btn').click(function() {
		$('#loader2').fadeIn();
		$('#import_btn').hide();
	});
	
	$('#show_import').click(function() {
		$('#import').show("slow");
		return false;
	});
}

