$(document).ready(function () {

    $(".more").hide();

    $(".showLink").click(function () {

        $(this).parent().parent().find('div').slideDown();

    });

    $(".showless").click(function () {

        $(this).parent().parent().slideUp(1200);

    });

    /* Fade Slideshow Code for All Trips*/

    function slideSwitch() {
        var $active = $('#slideshow IMG.active');

        if ($active.length == 0) $active = $('#slideshow IMG:last');

        var $next = $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

        $active.addClass('last-active');

        $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function () {
            $active.removeClass('active last-active');
        });
    }

    var slide = 1;

    $(function () {
        var numberSlides = $("#slideshow-nav li").length;
        var mySlideshow = setInterval(function () {
            slide++;

            /* The number after > should designate the number of slides in the slideshow.*/
            if (slide > numberSlides)
                slide = 1;
            slideSwitch();
            $("#slideshow-nav li").removeClass('selected');
            $("#slideshow-nav li#" + slide).addClass('selected');
        }, 7000);

        $("#slideshow").click(function () {
            clearInterval(mySlideshow);
        });

        $("#slideshow-nav li").click(function () {

            clearInterval(mySlideshow);
            $("#slideshow-nav li").removeClass('selected');
            $(this).addClass('selected');
            var show = $(this).attr('id');

            var $active = $('#slideshow IMG.active');

            if ($active.length == 0) $active = $('#slideshow IMG:last');

            var $next = $("#slideshow img." + show);

            $active.addClass('last-active');

            $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function () {
            $active.removeClass('active last-active');
        });
           /* $("#slideshow img").fadeOut();
            $("#slideshow img." + show).fadeIn();*/
        });
    });


});
