jQuery(function($){
  /* Affiche l'image plus grosse de la promo */
  $('#homepromo .promophoto').hover(function(){
    $(this).parent().find('.bigpromophoto').fadeIn('fast');
  }, function(){
    $(this).parent().find('.bigpromophoto').fadeOut('fast');
  });

  /* Fade l'image des boutons pour voir les logos */
  $('#homeright .animbtn a').hover(function(){
    $theAnimElem = $(this);
    $switchBtnImg = setTimeout(function(){
      $theAnimElem.find('.overimg, .btnlabel').fadeOut('slow');
    }, 200);
  }, function(){
    clearTimeout($switchBtnImg);
    $theAnimElem.find('.overimg, .btnlabel').fadeIn();
  });

  /* Fade le background des boutons en survolant */
  $('#homeright .fadingbtn').hover(function(){
    $(this).find('.btnimg').stop().fadeTo('normal',.6);
    $(this).find('.btnimg').css('cursor','pointer');
    $(this).find('.btnlabel').css('cursor','pointer');
  }, function(){
    $(this).find('.btnimg').stop().fadeTo('normal',1);
  });

  $('#homeright .fadingbtn').click(function(){
    location.href = $(this).find('a').attr('href');
  });

  $('#requestbtns li').hover(function(){
    $(this).find('.btnimg').stop().fadeTo('normal',.6);
  }, function(){
    $(this).find('.btnimg').stop().fadeTo('normal',1);
  });

  /* Ouverture/fermeture du menu rapide */
  $('#quicknav').hover(function(){
    $theAnimElem = $(this);
    $switchBtnImg = setTimeout(function(){
      $theAnimElem.find('.quicktitle span').fadeOut();
      $theAnimElem.find('ul').fadeIn();
    }, 200);
  }, function(){
    clearTimeout($switchBtnImg);
    $theAnimElem.find('ul').fadeOut('normal',function(){
      $theAnimElem.find('.quicktitle span').fadeIn();
    });
  });

  /* Resize le bouton Menu rapide */
  if($('#quicknav ul').width() > 260){
    $('#quicknav .quicktitle').css('width','250px');
  }else{
    $('#quicknav .quicktitle').css('width',$('#quicknav ul').width());
  }

  /* Texte "read More" */
  $('.textMore').hide();
  $('.fr .textMore').after('<p class="readmore"><a href="#">Lire la suite &raquo;</a></p>');
  $('.en .textMore').after('<p class="readmore"><a href="#">Read More &raquo;</a></p>');

  $('div.text > p.readmore a').click(function(){
    $textMore = $(this).parents('.text').find('.textMore');

    if($textMore.length){
      if($('.ie').length){
        $textMore.show();
      }else{
        $textMore.css({opacity: '0'}).slideDown(250).fadeTo(500, 1);
      }

      $(this).parent().hide();
      return false;
    }
  });

  /* Texte d'historique de la page d'accueil */
  $('div.text p.readhisto a').click(function(){
    $histoMore = $('#homeHisto');

    if($histoMore.length){
      if($('.ie').length){
        $histoMore.show();
      }else{
        $histoMore.slideDown(250);
      }

      $(this).parent().hide();
      $histoMore.scrollTo()
      return false;
    }
  });
});

