/*
**  Utilisation de la librairie jQuery
**  http://docs.jquery.com/Downloading_jQuery#Download_jQuery
*/

jQuery.noConflict();
jQuery(function($) {


    var langue = $('html').attr('lang');

    var newsletter = '';
    if(langue == 'fr')
    {
      newsletter = 'Votre email';
    }
    else
    {
      newsletter = 'Your email';
    }
    
    $("#emailFormNewsletter").attr('value',newsletter);

    $("#emailFormNewsletter").attr('value',newsletter).focus(function () {
        if (this.value == newsletter) this.value = '';
    }).blur(function () {
        if (this.value == '') this.value = newsletter;
    });
    
    // GESTION DU MENU DEROULANT
    
    $('#aside>.menu>ul>li').hover(function() {
    
        var jHover = $(this);
        
        /*if ($('#aside>.menu>ul>li.jHover').length < 3){
            jHover.addClass('jHover').find('.sousMenu ul').css('left','-120px').animate({"left": "+=120px"}, "normal", function () {  });
        }*/

        jHover.addClass('jHover').find('.sousMenu ul').show();
        
    }, function() {

        var jHover = $(this);
        
        /*if (jHover.find('.sousMenu ul').length){
            jHover.find('.sousMenu ul').animate({"left": "-=120px"}, "normal", function () {jHover.removeClass('jHover');$(this).css('left','0px');});
        } else {
            jHover.removeClass('jHover');
        }*/
        jHover.removeClass('jHover').find('.sousMenu ul').hide();
        
    });
    
    $('#aside>.menu>ul>li>a').focus(function() {
        $('#aside>.menu>ul>li').removeClass('jHover');
        $(this).parent().addClass('jHover');
    });
    
    // GESTION DU MENU AGENDA
    
    
    $("#content .colMain ul.outilsListe li.agenda  a").click(function(){
        $(this).parent().toggleClass('agendaOpen').find('div').slideToggle();
    });
    
    // AJOUTS DEV
    $("#participOui").click(function(){
      $("#telechargementFichier").show();
      $(".displayForm").hide();
    });

    $("#participNon").click(function(){
      $(".displayForm").show();
      $("#telechargementFichier").hide();
    });

    $(".detailExposant").click(function(){
      $(this).parent().next().toggle();
    });

        /**
    // Appelle le plugin carousel slide
    **/
    $('.carousel').carouselSlide({
        manual: true,
        auto: true,
        speed: 1000,
        frequency: 5000
    });

  var flashvars = {
    xmlPath: "/assets/videos.xml"
  };
    /*var flashvars = {
      xmlPath: "assets/partenaires.xml"
    };*/
    swfobject.embedSWF("/swf/SliderVideo.swf", "SliderVideo", "583", "87", "9.0.0", "/swf/expressInstall.swf", flashvars);

  function loadVideo(pId, pKey){
    if ($("#ajaxVideo").length) {
      $("#ajaxVideo").html($.ajax({
        type: "POST",
        url: "/ajaxVideo.php",
        data: {id: pId, key: pKey},
        async: false
       }).responseText);
    }
  }


  // GESTION DES ONGLETS

  $("#content .colMain .blocCarousels .carousel:not(:first)").hide();
  $("#content .colMain .blocCarousels .ongletsPhoto a:first").addClass("current");



  $("#content .colMain .blocCarousels .ongletsPhoto a::not(.current)").live("click", function() {
  
   $("#content .colMain .blocCarousels .ongletsPhoto a").removeClass("current");
   $("#content .colMain .blocCarousels .carousel:visible").hide();

   $("#content .colMain .blocCarousels .carousel:eq("+$(this).addClass("current").index()+")").show();

   this.blur();
   return false;
  });

  $('#blocVideos .medias:not(:first)').hide();

  $('#content .colMain .carousel .item a').click(function(){
    $('#blocVideos .medias:visible').hide();
    var idVideo = $(this).attr('href');
    $(idVideo).show();
    return false;
  });

  $('#photoSlide').click(function(){
    loadSlideShowPro();
    $('#videoCarouselSalonImage').hide();
    $('#photos').show();
    
  });
  
  $('#videoSlide').click(function(){
    $('#videoCarouselSalonImage').show();
    $('#photos').hide();
  });


    function loadSlideShowPro(){
      //if ($("#ajaxVideo").length) $("#ajaxVideo").html("");

      var flashparams = {
        bgcolor: "#ffffff",
        allowFullScreen: "true",
        wmode: "transparent"
      };
      var flashvars = {
        xmlPath:"/galerie/images.php?album=7"
      };
      if ($("#flashSlider").length) {
        swfobject.embedSWF("/swf/SliderImage.swf", "flashSlider", "450", "288", "9.0.0", "/swf/expressInstall.swf", flashvars, flashparams);
      }
    }

    // GESTION DES LIGHTBOX

    $(".btLightbox").click(function(){
        $("#overlayLightbox").show();
        $("#"+$(this).attr('id')+"box").show();
        this.blur();
        return false;
    });

    $(".lightBox .fermer a").click(function(){
        $("#overlayLightbox").hide();
        $(this).parent().parent().hide();
        this.blur();
        return false;
    });    
    
});
