var CommikFAQ = {
  last_question: "",
  
  generate: function() {
		if($('dynamic-faq')){
      $$('#dynamic-faq div.question').each(function(question){
        Event.observe(question, 'click', function(){
  	  	  CommikFAQ.show_answer(question);
  	  	});				
  		});
    }
  },
  
  show_answer: function(question){
    var answer = question.id.replace(/question/gi, 'answer');
    
    if(this.last_question == answer){
      new Effect.BlindUp(answer, {duration: 0.3, queue: {position: 'end', scope: 'faq', limit: 2}});
      this.last_question = "";
    }else{
      if(this.last_question != ""){
        new Effect.BlindUp(this.last_question, {duration: 0.3, queue: {position: 'end', scope: 'faq2', limit: 2}});
      }
      new Effect.BlindDown(answer, {duration: 0.3, queue: {position: 'end', scope: 'faq', limit: 2}});
      this.last_question = answer;    
    }
  }
  
}

Event.observe(window, 'load', CommikFAQ.generate);
