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');
    });
}

$(function() {

    // banner slider
    setInterval( "slideSwitch()", 5000 );

    // lightbox
    $('a[@rel*=lightbox]').lightBox();

    //datepicker
    Date.format = 'yyyy-mm-dd';

    $('#checkin')
        .datePicker({inline:true})
        .bind(
                'dateSelected',
                function(e, selectedDate, $td)
                {
                        $('#checkin_date').val(selectedDate.asString());
                        $('#checkout').dpSetStartDate(selectedDate.addDays(1).asString());
                        $('#checkout').dpSetSelected(selectedDate.asString());
                }
        );

    $('#checkout')
        .datePicker({inline:true})
        .bind(
                'dateSelected',
                function(e, selectedDate, $td)
                {
                        $('#checkout_date').val(selectedDate.asString());
                }
        );

});
