$(document).ready(function(){
  /* 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(){
    if($('.homebody').length){
      $('.homebody #homedelivery').css('marginLeft','10').animate({
        marginTop:49,
        marginBottom:20
      }, function(){
        $('.homebody #h1container').css({
          width:954,
          float:'none'
        });
        $('.homebody #hometext').css({
          float:'none',
          width:'auto'
        })
        $(this).css('marginTop','0').animate({marginLeft:20}).find('a').animate({width:250});
        $('.homebody .textMore').slideDown();
      });
    }else{  
      $textMore = $(this).parents('.text').find('.textMore');
      
      if($textMore.length){
        if($('.ie').length){
          $textMore.show();
        }else{
          $textMore.css({opacity:0}).slideDown(250, function(){
            $(this).fadeTo(500, 1);
          });
        }
      }
    }
    
    $(this).parent().hide();
    return false;
  });
  
  /* Scrolling btns */
  $allowScroll = 1;
  
  $(window).scroll(function(){
    if($allowScroll){
      $allowScroll = 0;
      
      if($('#topquickbtns .on').css('display') == 'block'){
        $('#topquickbtns .on').animate({right: '-220px'}, 500, function(){
          $('#topquickbtns .on').hide().css('right', '-220px');
        });
    
        $('#topquickbtns .off').show().animate({right: '0'}, 500);
      }
    }
    
    if($(this).scrollTop() >= '196'){
      if(!$('.ie').length){
        $('#topquickbtns').css({
          position: 'fixed',
          top: '10px'
        });
      }else{
        $('#topquickbtns').css({top: ($(this).scrollTop() + 10) + "px"});
      }
    }else{
      $('#topquickbtns').css({
        position: 'absolute',
        top: '206px'
      });
    }
  });
  
  $('#topquickbtns .off a').click(function(){
    $('#topquickbtns .off').animate({right: '-27px'}, 500, function(){
      $('#topquickbtns .off').hide();
    });
    
    $('#topquickbtns .on').show()
      .animate({right: '0'}, 500, function(){
        $(this).blur();
        $allowScroll = 1;
      });
    
    return false;
  });
});
