$(function(){
    var dates = $('#from_date, #to_date').datepicker({
        showOn: 'button',
        buttonImage: '/content/media/layout_1/images_3/datepicker.jpg',
        buttonImageOnly: true,
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 3,
        dateFormat: "dd.MM.yy",
        minDate: +7,
		onSelect: function(selectedDate) {
            var option = this.id == "from_date" ? "minDate" : "maxDate";
            var instance = $(this).data("datepicker");
            var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }
    });
});

function galleyOverview_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('#galleyOverview-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#galleyOverview-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
}

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#galleryOverview").jcarousel({
        scroll: 1,
		itemFallbackDimension : 75,
        initCallback: galleyOverview_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: "<div>&nbsp;</div>",
        buttonPrevHTML: "<div>&nbsp;</div>"
    });
});

$(document).ready(function(){
    $("a[rel='galleryHotelDetail']").colorbox({
        slideshow:true,
        next : "N�chstes Bild",
        previous : "Vorheriges Bild",
        close: "Beenden"
    });
	
	$("a[rel='sendEMail']").colorbox({
        iframe:true,
        transition: 'fade',
        rel: 'nofollow',
        arrowKey: false,
        scrolling: true,
        opacity: 0.65,
        slideshow: false,
        close: "Schliessen",
        width:450,
        height:510
    });

    $(".tabs").accessibleTabs({
        fx: 'fadeIn',
        tabbody : '.tab-content',
        tabhead : 'h2'
    });

    $("a.hotelInfos").click(function(event) {
        event.preventDefault();
        $selection = $(this).attr("rel");
        $("#" + $selection).slideToggle("slow");
        $(this).parent().parent().toggleClass("buttonDown hotelButtonPaddingDown");
        $(this).text($(this).text() == 'HotelInfos' ? 'schliessen' : 'HotelInfos'); return false;
    });
});
