function slideSwitch() {
    
    var $active = $('#slideshow img.active');

    if ( $active.length == 0 ) $active = $('#slideshow img:last');

    var $next = $active.next('img').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');
    });
    
}


// Starting the script on page load
$(document).ready(function(){
    
    // Location page - start fader
    if ($('#slideshow').length > 0) {
        setInterval( "slideSwitch()", 5000 );
    }
    
    // Tour page - initialize carousel
    $(".widget .jCarouselLite").jCarouselLite({
        btnNext: ".widget .next",
        btnPrev: ".widget .prev",
        speed: 800,
        vertical: true,
        visible: 5,
        circular: false,
        scroll: 5,
        easing: "swing"
    });

    $(".widget img").click(function() {
        $(".widget .mid img").attr("src", $(this).attr("src").replace("/tn/", "/lg/"));
    })

    
    // Plans page - load SWF
    $('#plans_swf').flash(
    {
        swf: 'public/swf/plans.swf',
        width: 866,
        height: 685
    }
    );
        
    // Dropdown menu
    $('#nav ul li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
 
        },
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);        
        });

});
