﻿
// -------------------------------------------------
// BANNER - POSITION
// -------------------------------------------------

var __language;


$(document).ready(function() {

    var activechildren = parseInt($(":input.showchildren option:selected").text());
    var children;
    if (activechildren > 0)
        children = $(":input.showchild:gt(" + (activechildren - 1) + ")");
    else {
        $(".children-ages").hide();
        children = $(":input.showchild");
    }
    children.hide();
    $(":input.showchildren").change(function() {
        var showchildren = parseInt($(this).find("option:selected").text());

        $(".children-ages").hide();
        children = $(":input.showchild");
        children.hide();
        if (showchildren > 0) {
            $(".children-ages").show();
            $(":input.showchild:lt(" + showchildren + ")").show();
        }

    });

    
    

    // -------------------------------------------------
    // FRAME FOTOGALLERY
    // -------------------------------------------------


    $(".toggle-fotogallery").click(function() {
        $("#frame-fotogallery").toggle("fast");
    });


    // -------------------------------------------------
    // NEWS
    // -------------------------------------------------


    $("#news .open").click(function() {
        var item = $(this).parent().parent();
        item.find(".container").slideDown(1200);
        item.find(".toggle").fadeOut(1000);
        item.find(".close").fadeIn(1000);
    });

    $("#news .close").click(function() {
        var item = $(this).parent().parent();
        item.find(".container").slideUp(600);
        item.find(".close").fadeOut(1000);
        item.find(".toggle").fadeIn(1000);
    });
    

    // -------------------------------------------------
    // contact - calendar -min/max date
    // -------------------------------------------------
    $('.ca-calendar').each(function() {
        var args = ca_getModuleArgs($(this), "ca-calendar");
        if (args.length > 1) {
            var minDate = getDate(args[0]);
            var maxDate = getDate(args[1]);
            $(this).datepicker({
                showOn: 'button',
                buttonImage: '/media/calendar.gif',
                buttonImageOnly: true,
                minDate: minDate,
                maxDate: maxDate
            });
        }
    });


});


function getDate(rawdate) {
    if (rawdate != null) {
        var parts = rawdate.split("-");
        if (parts.length == 3)
            return new Date(parseInt(parts[0], 10), (parseInt(parts[1], 10) - 1), parseInt(parts[2], 10));
    }
}



// -------------------------------------------------
// print
// -------------------------------------------------
function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function CL_printWindow() {
    window.print();
}



/****************Pop up rooms**********************/


function cu_lookup(title, site) {
    CL_popupDiv('/pages/popup.aspx?__language=' + __language + '&site=' + site + '&title=' + title, 550, 600, null, 100);
}



function cu_doBooking(language) {

    var arrival = $('.arrival').val();
    var departure = $('.departure').val();

    cu_generatePopup('Booking', 'https://www.dirs21.de/(S(im5sxm55gjgmc145nzxac345))/dirs21_book/romantikhotel-stafler/default.aspx?sprache=' + language + '&anreise=' + arrival + '&abreise=' + departure, 800, 640, 'Online Booking DIRS');

    return null;
}


$(document).ready(function() {
    //---------------------------------------------------
    //  ie6 alpha bug
    //---------------------------------------------------
    $('#banner').supersleight();
    $('#col-right').supersleight();
    $('#bottom').supersleight();

});

