(function($) {
    $(document).ready(function() {
        var name = "Nachname";
        var betreff = "Betreff";
        var email = "E-Mail Adresse";
        var nachricht = "Nachricht";

        auto_fill($("#name"), name);
        auto_fill($("#betreff"), betreff);
        auto_fill($("#email"), email);
        auto_fill($("#nachricht"), nachricht);

        function auto_fill(id, v){
            fill_empty(id, v);
            set_default(id, v);

            $(id).focus(function(){
                if($(this).val()==v){
                    $(this).val("").css({
                        color: "#333"
                    });
                }
            }).blur(function(){
                fill_empty(id,v);
            });

        }
        function set_default(id, v){
            if($(id).val() == v) {
                switch ($(id).attr('id')) {
                    case "name":
                        $(id).css({
                            color: "#010101"
                        });
                        break;
                    case "betreff":
                        $(id).css({
                            color: "#010101"
                        });
                        break;
                    case "email":
                        $(id).css({
                            color: "#010101"
                        });
                        break;
                    case "nachricht":
                        $(id).css({
                            color: "#010101"
                        });
                        break;
                    default:
                        $(id).css({
                            color: "#010101"
                        });
                        break;
                }
            }
        }
        function fill_empty(id,v){
            if($(id).val()==""){
                // Pflichtfelder
                switch ($(id).attr('id')) {
                    case "name":
                        $(id).css({
                            color: "#010101"
                        }).val(v);
                        break;
                    case "betreff":
                        $(id).css({
                            color: "#010101"
                        }).val(v);
                        break;
                    case "email":
                        $(id).css({
                            color: "#010101"
                        }).val(v);
                        break;
                    case "nachricht":
                        $(id).css({
                            color: "#010101"
                        }).val(v);
                        break;
                    default:
                        $(id).css({
                            color: "#b2adad"
                        }).val(v);
                        break;
                }

            }

        }







        var offset = $("#booking").offset();
        var topPadding = 15;
        $(window).scroll(function() {

            if ($(window).scrollTop() > offset.top) {
                $("#booking").stop().animate({
                    marginTop: $(window).scrollTop() - offset.top + topPadding
                });
            } else {
                $("#booking").stop().animate({
                    marginTop: 0
                });
            }
        });






        $(".fancybox").fancybox({
            'type' : 'iframe',
            'height' : 466,
            'width': 812,
            'scrolling': 'no',
            'autoScale': false,
            'autoDimensions':false,
            'titleShow' : false
        });
        /*$("a[href=galerie/]").bind("click", function() {
            $.ajax({
                url     : "http://villaflorentina.gekko-management.com/galerie/",
                success: function(html) {
                    $.fancybox(html);
                }
            });
            return false;
        });
*/

    });
})(jQuery);


