﻿var _selectedQ = null;

$(document).ready(function(){
  // hide all the answers and bind the links
  $('#faq').find('dd').hide().end().find('dt').click(function(){
  
    var _this = $(this);
    var answer = _this.next();

    $("#faq dd:visible").not(answer).slideUp();

    answer.slideToggle();

    if (_selectedQ && (_this.get(0) == _selectedQ)){
    
      _this.animate({color: "#6a6746"}, 600 );
      _selectedQ = null;
      
    } else {
    
      if (_selectedQ != null){
        $(_selectedQ).animate({color: "#6a6746"}, 600 ); 
      }

      _this.animate({color: "#ee9258"}, 600 ); 
      _selectedQ = _this.get(0);
    }
  });
});