﻿// initialize sliders

$(
    function() {
    
		$(".question")
		   .addClass("enabled")                                     // class voor juiste cursor weergave
		   .find("dt")
            .each(function(index) {                               // alles inklappen behalve nr.1
               if (index>0) {
                  $(this)
                     .addClass("closed")
                     .next()
                     .hide();
               }
            })
		      .click(slide)                                         // slide event koppelen
		      .end()
		   .find("dd .cta")                                         // cta lijsten
		      .each(function(index) {                               // elke individuele lijst copieren en aanpassingen maken
               $(this)
                  .clone()
                  .find("a")                                      // links in lijst aanpassen
		               .removeClass("button")
                     .click( function(event) {
		                  event.stopPropagation();                  // click-event propagatie voorkomen bij links
		               })
		               .end()
		            .appendTo( $(".question dt:eq(" + index + ")") );  // nieuwe lijst toevoegen aan header
            });

    }
)

var slide = function() {

   if ( this.className == "" ) {
   
      $(this)
         .next()
         .slideUp(
            200, function() {
            // Animation complete.
            $(this)
               .prev()
               .addClass("closed");
         });
      
   } else {
      
      $(this)
         .removeClass("closed")
         .next()
         .slideDown(200);
      
   }

}
