$(document).ready(function(){

    

    $('.styleswitcher').click(function() {
        $.styleswitcher(this.getAttribute('rel'));
        return false;
    });

    $('a.prev').click(function(){
        var ss = $(this).parents('#slideshowWrapper');
        var imgs=ss.find('#slideshow');
        var image=imgs.find('img.current');
        var previmg=image.prev('img');
        var last_image=imgs.find('img:last-child');

        image.removeClass('current').fadeOut('fast',function(){
            if(image.is('img:first-child')) {
                last_image.addClass('current').fadeIn('normal');
            }
            else {
                previmg.addClass('current').fadeIn('fast');
            }
        });
        return false;
    });

    $("#slideshow img").click(function() {
        var imgs=$(this).parents('#slideshowWrapper').find('#slideshow');
        var image=imgs.find('img.current');
        var nextimg=image.next('img');
        var first_image=imgs.find('img:first-child');

        image.removeClass('current').fadeOut('fast',function() {
            if(image.is('img:last-child')){
                first_image.addClass('current').fadeIn('slow');
            }
            else{
                nextimg.addClass('current').fadeIn('fast');
            }
        });

        return false;
    });

    $('a.next').click(function() {

        var imgs=$(this).parents('#slideshowWrapper').find('#slideshow');
        var image=imgs.find('img.current');
        var nextimg=image.next('img');
        var first_image=imgs.find('img:first-child');

        image.removeClass('current').fadeOut('fast',function() {
            if(image.is('img:last-child')){
                first_image.addClass('current').fadeIn('slow');
            }
            else{
                nextimg.addClass('current').fadeIn('fast');
            }
        });

        return false;
    });



    $("#hidenshow").click(function() {
        if ($(this).hasClass("show")) {
            $("#biggooglemap").slideToggle();
            $(this).removeClass("show");
            $(this).html("Voir la carte");
        } else {
            $(this).addClass("show");
            $("#biggooglemap").slideToggle();
            $(this).html("Cacher la carte");
        }
    });

});


