$(document).ready(function(){
  //Debut
  $(".peliculle_suivante").click(function() {
    if ($(".peliculle_active").is("#derniere_peliculle") == false) {
      $(".peliculle_active").hide(1, function() {
        $(".peliculle_active").next("ul").show();
        $(".peliculle_active").next("ul").attr("class", "peliculle_thematiques clear peliculle_active")
        $(this).attr("class", "peliculle_thematiques clear")
      });
         }
    return false;
  });


  $(".peliculle_precedente").click(function() {
    if ($(".peliculle_active").is("#premiere_peliculle") == false) {
      $(".peliculle_active").hide(1, function() {
        $(".peliculle_active").prev().show();
        $(".peliculle_active").prev().attr("class", "peliculle_thematiques clear peliculle_active")
        $(this).attr("class", "peliculle_thematiques clear")
      });
      }
      return false;
  });

  $(".article #options li").click(function() {
    var click_on_id = $(this).attr("id");
    if (click_on_id == "onglet_voir_aussi") {
      ul_class = "focus_sur_articles"
      display_content_tab = "contenu_vente_croisee";
    } else if (click_on_id == "onglet_commentaires") {
      ul_class = "focus_sur_commentaires"
      display_content_tab = "contenu_commentaires";
    } else if (click_on_id == "onglet_infos_complementaires") {
      ul_class = "focus_sur_infos_complementaire"
      display_content_tab = "contenu_extra";
    }
    $(this).parent().attr("class", ul_class);
    $(".active").hide(1, function() {
      $(this).removeClass("active")
      $("." + display_content_tab).show();
      $("." + display_content_tab).addClass("active")
    });
    return false;
  });

  $(".article #btn_voir_zone_commentaire").click(function() {
    $("#ajout_commentaire").show();
    return false;
  });

  $(".article #fermer_commentaire a").click(function() {
    $("#ajout_commentaire").hide();
    return false;
  });

  $(".article #annuler").click(function() {
    $("#ajout_commentaire").hide();
    return false;
  });
  
	// Onglets page accueil
   $("#plus_sur_les_produits li a").click(function() {
     // Changes the focus of tab
     var tab_class = $(this).attr("class")
     var tab_index = $("#t1 ul li a").index(this)
     $(this).parent().parent().attr("class", "focus_" + tab_class + " clear")

     // Changes the focus of content tab
     $("#t1 div:visible").css("display", "none")
     var clicked_div = $("#t1 div")[tab_index]
     $(clicked_div).attr("style", "")
     return false;
   });
  //Fin
});

function switcher(block_width, nb_block_to_show)
{
  switcher_width = block_width * nb_block_to_show
  $("#switcher p a").click(function () {
    var link_class = $(this).attr("class");
    var ul_position = $("#slider ul").css("left");
    ul_position = parseInt(ul_position)
    var end = block_width * ($("#slider ul li").size() - nb_block_to_show)
    if (link_class == "suivant" && ul_position != -end) {
      ul_position -= switcher_width
      $("#slider ul").animate({
        left: ul_position + "px"
      }, "slow" );
    } else if (link_class == "precedent" && ul_position != 0) {
      ul_position += switcher_width
      $("#slider ul").animate({
        left: ul_position + "px"
      }, "slow" );
    }
    return false;
  })
 }

