﻿var now = new Date();
var prettyDate = new String;
if (now.getDate() < 10) {
    prettyDate = ('0' + now.getDate() + '.' + (now.getMonth() + 1) + '.' + now.getFullYear());
} else {
    prettyDate = (now.getDate() + '.' + (now.getMonth() + 1) + '.' + now.getFullYear());
}

$(document).ready(function () {

    if ($('#angebotsfeld').length > 0) {
        $('#angebotsfeld').cycle({
            fx: 'fade',
            speed: 1500,
            timeout: 5500
        });
    }

    $("#angebotsfeld a").hover(
      function () {
          $(this).children().attr('src', 'App_Themes/arr5.png')
      },
      function () {
          $(this).children().attr('src', 'App_Themes/arr4.png')
      }
    );

    if ($(".slideshow_640 a").length > 0) {
          $('.slideshow_640 a').overlay({
              target: '#gallery',
              expose: {
                  maskId: 'exposeMask',
                  color: '#533524',
                  opacity: 0.95
              }
          }).gallery({
              speed: 800
          });
    }


    $('.thickbox').trigger('click');

    if ($(".pauschale").length > 0) {

        $(".pauschale").each(function (i) {
            if ($('.pauschale_preis', this).height() > 18) {
                var newheight = $('.pauschale_links', this).height() + ($('.pauschale_preis', this).height() - 18)
                $('.pauschale_links', this).css('min-height', newheight + 'px');
                //$('.pauschale_rechts', this).css('min-height', newheight + 'px');
            }
        });

    }

    $('#ddl_gutscheinwert, #ddl_gutscheinanzahl').change(function () {
        changer();
    });


    if ($('#DatePickerDate').length > 0) {
        if ($('#DatePickerDate').val() != '') {
            var str = $('#DatePickerDate').val().split(",");
            $('#date').DatePickerSetDate([str[0], str[1]], 1);
        }
    }

    setTimeout(function () {
        $("#angebotsfeld").fadeIn("slow");
    }, 500);
    setTimeout(function () {
        $("#widgets").fadeIn();
    }, 900);

});

function changer() {
    var gesamtwert = $("#ddl_gutscheinwert option:selected").text()
    gesamtwert = gesamtwert.replace("€", "");
    gesamtwert = parseInt(gesamtwert) * parseInt($("#ddl_gutscheinanzahl option:selected").text());
    $("#gesamtwert").html('Gesamtsumme: <strong style="color:#fff;font-weight:bold;">' + gesamtwert + ' €</strong><br /><br />');
}

$(function() {
if ($('.scroll-pane-arrows').length > 0) {
    $('.scroll-pane-arrows').jScrollPane(
		{
		    showArrows: true,
		    horizontalGutter: 10
		}
	);
}
});


function releaseEvent(fu) {
    if ($('.' + fu).is(":visible")) {
        $('.' + fu).delay(10000).fadeOut(100);
        $('#noevent').delay(11500).fadeIn(100);
    };
}


/* BEGIN jquery color */
  (function(jQuery) {
      jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i, attr) {
          jQuery.fx.step[attr] = function(fx) {
              if (!fx.colorInit) { fx.start = getColor(fx.elem, attr); fx.end = getRGB(fx.end); fx.colorInit = true; }
              fx.elem.style[attr] = "rgb(" + [Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)].join(",") + ")";
          } 
      }); function getRGB(color) {
          var result; if (color && color.constructor == Array && color.length == 3)
              return color; if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
              return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])]; if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
              return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55]; if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
              return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)]; if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
              return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)]; if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
              return colors['transparent']; return colors[jQuery.trim(color).toLowerCase()];
      }
      function getColor(elem, attr) {
          var color; do {
              color = jQuery.curCSS(elem, attr); if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body"))
                  break; attr = "backgroundColor";
          } while (elem = elem.parentNode); return getRGB(color);
      }; var colors = { aqua: [0, 255, 255], azure: [240, 255, 255], beige: [245, 245, 220], black: [0, 0, 0], blue: [0, 0, 255], brown: [165, 42, 42], cyan: [0, 255, 255], darkblue: [0, 0, 139], darkcyan: [0, 139, 139], darkgrey: [169, 169, 169], darkgreen: [0, 100, 0], darkkhaki: [189, 183, 107], darkmagenta: [139, 0, 139], darkolivegreen: [85, 107, 47], darkorange: [255, 140, 0], darkorchid: [153, 50, 204], darkred: [139, 0, 0], darksalmon: [233, 150, 122], darkviolet: [148, 0, 211], fuchsia: [255, 0, 255], gold: [255, 215, 0], green: [0, 128, 0], indigo: [75, 0, 130], khaki: [240, 230, 140], lightblue: [173, 216, 230], lightcyan: [224, 255, 255], lightgreen: [144, 238, 144], lightgrey: [211, 211, 211], lightpink: [255, 182, 193], lightyellow: [255, 255, 224], lime: [0, 255, 0], magenta: [255, 0, 255], maroon: [128, 0, 0], navy: [0, 0, 128], olive: [128, 128, 0], orange: [255, 165, 0], pink: [255, 192, 203], purple: [128, 0, 128], violet: [128, 0, 128], red: [255, 0, 0], silver: [192, 192, 192], white: [255, 255, 255], yellow: [255, 255, 0], transparent: [255, 255, 255] };
  })(jQuery);
/* END jquery color */

/* BEGIN highlight */
jQuery(function() {
    $.fn.highlight = function(options) {
    options = (options) ? options : { start_color: "#fff", end_color: "#ff0", delay: 300 };
        $(this).each(function() {
        $(this).stop().css({ "background-color": options.start_color }).animate({ "background-color": options.end_color }, options.delay).animate({ "background-color": options.start_color }, options.delay);
        });
    }
});
/* END highlight */

function DateDiff() {
    var d2 = $('.datepickerContainer table td').next().next().next().find('.datepickerMonth span').html().split(' ');
    var today = now.getDate();
    switch (d2[0]) {
        case "J%E4nner":
            futuredate = '1,' + today + ',' + d2[1]; break;
        case "Februar":
            if (now.getDate() > 28) { today = 28; }
            futuredate = '2,' + today + ',' + d2[1]; break;
        case "M%E4rz":
            futuredate = '3,' + today + ',' + d2[1]; break;
        case "April":
            if (now.getDate() > 30) { today = 30; }
            futuredate = '4,' + today + ',' + d2[1]; break;
        case "Mai":
            futuredate = '5,' + today + ',' + d2[1]; break;
        case "Juni":
            if (now.getDate() > 30) { today = 30; }
            futuredate = '6,' + today + ',' + d2[1]; break;
        case "Juli":
            futuredate = '7,' + today + ',' + d2[1]; break;
        case "August":
            futuredate = '8,' + today + ',' + d2[1]; break;
        case "September":
            if (now.getDate() > 30) { today = 30; }
            futuredate = '9,' + today + ',' + d2[1]; break;
        case "Oktober":
            futuredate = '10,' + today + ',' + d2[1]; break;
        case "November":
            if (now.getDate() > 30) { today = 30; }
            futuredate = '11,' + today + ',' + d2[1]; break;
        case "Dezember":
            futuredate = '12,' + today + ',' + d2[1]; break;
    }

        var f2 = new Date(futuredate);
        var t2 = f2.getTime();
        var t1 = now.getTime();
        var dates = parseInt((t2 - t1) / (24 * 3600 * 1000));

        if (dates <= 0) { $('.datepickerGoPrev a').hide(); } else { $('.datepickerGoPrev a').show(); }
        if (dates >= 365) { $('.datepickerGoNext a').hide(); } else { $('.datepickerGoNext a').show(); }
}

