var carrousel={nbSlide:0,nbCurrent:1,elemCurrent:null,elem:null,timer:null,init:function(elem){this.nbSlide=elem.find('#InterSlideshow li').length;$('.remove').remove();elem.find('#InterSlideshow li, .title, .link').hide();for(var i=1;i<=this.nbSlide;i++){elem.find('#Numbers').append('<li><a href="" onclick="return false;">'+i+'</a></li>');}
elem.find('#Numbers li').click(function(){carrousel.gotoSlide($(this).text());});this.elem=elem;elem.find('#InterSlideshow li:first, .title:first, .link:first').show();this.elemCurrent=elem.find('#InterSlideshow li:first');this.elem.find('#Numbers li:first').addClass('active');carrousel.play();elem.mouseover(carrousel.stop);elem.mouseout(carrousel.play);},gotoSlide:function(num){if(num==this.nbCurrent){return false;}
var sens=1;if(num<this.nbCurrent){sens=-1}
var cssDeb={'left':sens*this.elem.width()};var cssFin={'left':-sens*this.elem.width()};this.elem.find('#slide'+num).show().css(cssDeb);this.elem.find('#slide'+num).animate({'top':0,'left':0},500);this.elemCurrent.animate(cssFin,500);this.elem.find('#Numbers li').removeClass('active');this.elem.find('#Numbers li:eq('+(num-1)+')').addClass('active');this.elem.find('.title').hide();this.elem.find('#title'+(num-1)).hide();this.elem.find('#title'+num).fadeIn();this.elem.find('.link').hide();this.elem.find('#link'+(num-1)).hide();this.elem.find('#link'+num).fadeIn();this.nbCurrent=num;this.elemCurrent=this.elem.find('#slide'+num);},next:function(){var num=this.nbCurrent+1;if(num>this.nbSlide){num=1;}
this.gotoSlide(num);},stop:function(){window.clearInterval(carrousel.timer);},play:function(){window.clearInterval(carrousel.timer);carrousel.timer=window.setInterval('carrousel.next()',5000);}}
$(document).ready(function(){carrousel.init($('#Slideshow'));});

$(document).ready(function() {
    
    $('a.zoombox').zoombox({
        gallery : false
    });
    
    $('.infoBulle').tipsy({gravity : 's'});
    
    $('a.internal').attr('target', '_blank');
    
    $('.boutonPartage a').click(function() {
        $(this).parent().parent().find('.bulle').fadeIn();
        $(this).parent().parent().find('.partage').fadeIn();
        return false;
    });
    
    $('.partage span a').click(function() {
        $('.bulle, .partage').fadeOut();
        return false;
    });
    
    $('.partage').mouseleave(function() {
        $('.bulle, .partage').fadeOut();
    });
    
    /*$('#Connexion a').click(function() {
        $('#ModuleConnexion').animate({
            'top' : 0
        }, 500);
        return false;
    });
    
    $('#ModuleConnexion a').click(function() {
        $('#ModuleConnexion').animate({
            'top' : '-200px'
        }, 500);
        return false;
    });*/
    
    $('#BoutonFacebookFooter').each(function() {
        lien = $(this).html();
        $(this).replaceWith('<li><iframe src="http://www.facebook.com/plugins/like.php?href=' + lien + '&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></li>').fadeIn();
    });
    
    $('#BoutonTwitterFooter').each(function() {
        lien = $(this).html();
        $(this).replaceWith('<li><a href="http://twitter.com/RockYourLifeFR" class="twitter-follow-button" data-show-count="false" data-lang="fr">Suivre @RockYourLifeFR</a></li>').fadeIn();
    });
    
    $('.boutonFacebook').each(function() {
        lien = $(this).html();
        $(this).replaceWith('<iframe src="http://www.facebook.com/plugins/like.php?href=' + lien + '&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>').fadeIn();
    });
    
    $('.facebook-commentaires').each(function() {
        lien = $(this).html();
        $(this).replaceWith('<iframe class="iframe-facebook" src="http://www.facebook.com/plugins/like.php?href=' + lien + '&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>').fadeIn();
    });
    
    $('.boutonTwitter').each(function() {
        lien = $(this).find('.twitterLien').html();
        titre = $(this).find('.twitterTitre').html();
        titre = titre.replace(/\"/g, '&quot;');
        $(this).replaceWith('<a href="http://twitter.com/share" class="twitter-share-button" data-url="' + lien + '" data-text="' + titre + '" data-count="horizontal" data-via="RockYourLifeFR" data-related="RockYourLifeFR" data-lang="fr">Tweet</a>')
    });
    
    $('.twitter-commentaires').each(function() {
        lien = $(this).find('.twitter-lien').html();
        titre = $(this).find('.twitter-titre').html();
        titre = titre.replace(/\"/g, '&quot;');
        $(this).replaceWith('<div class="iframe-twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-url="' + lien + '" data-text="' + titre + '" data-count="horizontal" data-via="RockYourLifeFR" data-related="RockYourLifeFR" data-lang="en">Tweet</a></div>')
    });
    
    $('.boutonGoogle').each(function() {
        lien = $(this).html();
        $(this).replaceWith('<g:plusone size="medium" href="' + lien + '"></g:plusone>');
    });
    
    $('.google-commentaires').each(function() {
        lien = $(this).html();
        $(this).replaceWith('<div class="iframe-google"><g:plusone size="medium" href="' + lien + '"></g:plusone></div>');
    });
    
});
