$(document).ready(function() {

    // Höhe bei kleinen Fenstern so weit wie möglich reduzieren
    var MIN_HEIGHT = 675; // ohne padding
    var pageHeight = $("#page").outerHeight();
    var windowHeight = $(window).height();
    var newHeight;

    if (windowHeight < pageHeight) {
        newHeight = windowHeight - 108; //padding abziehen
        if (newHeight < MIN_HEIGHT) {
            newHeight = MIN_HEIGHT;
        }
        $("#page").css("height", newHeight + "px");
    }
    

    // Effekt Navigation
    $("#navigation  a:not(.active)").hover(function() {
        $("#navigation ul").css("width", "716px");
    }, function() {
        $("#navigation ul").removeAttr("style");
    })

    // Lightbox
    $("div.content div.gallery a").css("cursor", "pointer").lightBox({
        "txtImage": "Bild",
        "txtOf": "von",
        "imageBtnClose": "/images/background/x.png"
    });

    // modaler Textdialog hat Vorrang vor Kontakt
    $("a.showtext").click(function() {
        $("#layertext").modal({
            "opacity": 85
        });
        return false;
    });

    // modaler Kontaktdialog
    var requiredMsg = "Pflichtfeld, bitte angeben!";
    var messages = {
        "mailer[name]": requiredMsg,
        "mailer[surname]": requiredMsg,
        "mailer[phone]": requiredMsg,
        "mailer[message]": "Bitte Nachricht eintragen!",
        "mailer[email]": "Bitte eine gültige Emailadresse angeben!"
    }

    $("a.more").click(function() {
        $("div.contact").modal({
            "opacity": 80,
            "onShow": function() {
                 $("div.contact form").validate({
                    "messages": messages
                });
            }
        });
        return false;
    });

    // runde Ecken
    if (!$.browser.msie || $.browser.version > 8) {
        $("div.content, div.contact, div#layertext").corner("25px");
    } else {
        var settings = {
          tl: { radius: 25 },
          tr: { radius: 25 },
          bl: { radius: 25 },
          br: { radius: 25 },
          antiAlias: true
        }

        curvyCorners(settings, 'div.content');
        curvyCorners(settings, 'div.contact');
        curvyCorners(settings, 'div#layertext');
        curvyCorners.init();
    }
});
