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

$('input.deactivate, input.activate').click(function(el){
  // $(this).hide()
})
  
time = 500;
$(document).ready(function(){
  
  $('body div').hide()
  $('body div').fadeIn(1000);
  
  $('.answer').hide();
  $('.answer:first').show();
  
  answers = $('.answer')
  i = 0;
  max = answers.length;

  
  $('.answer .next').click(function(){
    i += 1;
    if (i == answers.length){i = 0;}
    show_answer(this, i);
  })
  
  $('.answer .previous').click(function(){
    if (i == 0){i = answers.length;}
    i -= 1;
    show_answer(this, i);
  })
})

show_answer = function(el, i){
  // Hide this element
  $(el).parents('.answer').fadeOut(time);
  // Wait #{time}ms and show the #{i}th element
  setTimeout(function(){
    $($('.answer')[i]).fadeIn(time);
  }, time)
}