$(document).ready(function() {

  // Message d'alerte : visionnement des PDF impossible depuis la bibliotheque
  $(".internal").attr({href:"#"}).click(function() {
    alert("Le visionnement des fichiers PDF de la Biblioth\u00e8que num\u00e9rique du cin\u00e9ma n'est pas encore disponible depuis ce poste.\nEn attendant, deux postes d\u00e9di\u00e9s vous permettant de les consulter sont mis \u00e0 votre disposition.\nMerci de vous adresser au personnel de la Biblioth\u00e8que pour plus de renseignements.");
    return false
  });

  // Transfomation de rel="external" en target="_blank"
  if(document.getElementsByTagName)for(var b = document.getElementsByTagName("a"), a = 0;a < b.length;a++)if(b[a].getAttribute("href") && b[a].getAttribute("rel") == "external")b[a].target = "_blank";

  // Lancement du slideshow
  $(document).ready(function(){
		$("#cycle").cycle();
  });

  // Initialisation
  $(".note").hide();
  $(".noteLink").before("<div class='arr'></div>").click(function() {
    return false;
  });
  $("a.noteLink").click(function() {
    $(this).parent().next("div").toggle(1,function() {
      if($(this).css("display") == "block") {
        $(this).prev().children("div.arr").css({backgroundPosition:"-506px 0px"});
      } else {
        $(this).prev().children("div.arr").css({backgroundPosition:"-496px 0px"});
      }
    });
    return false
  });
  $("#noteToggleAll").html("<a id='noteShowAll' href=''>Afficher toutes les notices</a><a id='noteHideAll' href=''>Cacher toutes les notices</a>");
  $("#noteHideAll").hide();
  $("#noteShowAll").click(function() {
    $(".noteLink").parent().next("div").show().prev().children("div.arr").each(function() {
      $(this).css({backgroundPosition:"-506px 0px"});
    });
    $("#noteShowAll").hide();
    $("#noteHideAll").show();
    return false;
  });
  $("#noteHideAll").click(function() {
    $(".noteLink").parent().next("div").hide().prev().children("div.arr").each(function() {
      $(this).css({backgroundPosition:"-496px 0px"});
    });
    $("#noteHideAll").hide();
    $("#noteShowAll").show();
    return false;
  });

});

