function expand(element){
  if(jQuery(element).is(':hidden')){
    jQuery(element).show();
    jQuery(element).prev().css({'background-image':'url(' + imagecollapse + ')'});
  }
}

function collapse(element){
  if(jQuery(element).is(':visible')){
    jQuery(element).hide();
    jQuery(element).prev().css({'background-image':'url(' + imageexpand + ')'});
  }
}

jQuery(document).ready(function(){

  jQuery('.yz_video_play').click(function(){
   jQuery(this).find("img").attr("src",imageplay);
  });

  jQuery('.yz_chapitre').click(function(){
    if(jQuery(this).next().is(':visible')){
      collapse(jQuery(this).next());
    }else{
      expand(jQuery(this).next());
    }
  });

  jQuery('#yz_expandall').click(function(){
    jQuery('.yz_listevideos').each(function(){
      collapse(this);
    });
  });

  jQuery('#yz_collapseall').click(function(){
    jQuery('.yz_listevideos').each(function(){
      expand(this);
    });
  });

  jQuery("#yz_boutontablematieres").addClass('yz_actif');
  jQuery("#yz_tablematieres").show();
  jQuery("#yz_fichiersexemple").hide();
  jQuery("#yz_description").hide();
  jQuery("#yz_formateur").hide();

  jQuery("#yz_boutontablematieres").click(function(){
    jQuery(this).addClass('yz_actif');
    jQuery("#yz_boutonfichiersexemple").removeClass('yz_actif');
    jQuery("#yz_boutondescription").removeClass('yz_actif');
    jQuery("#yz_boutonformateur").removeClass('yz_actif');
    jQuery("#yz_tablematieres").show();
    jQuery("#yz_fichiersexemple").hide();
    jQuery("#yz_formateur").hide();
    jQuery("#yz_description").hide();
  });

  jQuery("#yz_boutonfichiersexemple").click(function(){
    jQuery(this).addClass('yz_actif');
    jQuery("#yz_boutontablematieres").removeClass('yz_actif');
    jQuery("#yz_boutondescription").removeClass('yz_actif');
    jQuery("#yz_boutonformateur").removeClass('yz_actif');
    jQuery("#yz_tablematieres").hide();
    jQuery("#yz_fichiersexemple").show();
    jQuery("#yz_formateur").hide();
    jQuery("#yz_description").hide();
  });

  jQuery("#yz_boutondescription").click(function(){
    jQuery(this).addClass('yz_actif');
    jQuery("#yz_boutontablematieres").removeClass('yz_actif');
    jQuery("#yz_boutonfichiersexemple").removeClass('yz_actif');
    jQuery("#yz_boutonformateur").removeClass('yz_actif');
    jQuery("#yz_tablematieres").hide();
    jQuery("#yz_fichiersexemple").hide();
    jQuery("#yz_formateur").hide();
    jQuery("#yz_description").show();
  });
  
  jQuery("#yz_boutonformateur").click(function(){
    jQuery(this).addClass('yz_actif');
    jQuery("#yz_boutontablematieres").removeClass('yz_actif');
    jQuery("#yz_boutondescription").removeClass('yz_actif');
    jQuery("#yz_boutonfichiersexemple").removeClass('yz_actif');
    jQuery("#yz_tablematieres").hide();
    jQuery("#yz_fichiersexemple").hide();
    jQuery("#yz_formateur").show();
    jQuery("#yz_description").hide();
  });
  
});