$(document).ready(function() {
    if ($("#noFlash").length > 0) {
        var so = new SWFObject("anim.swf?t=" + new Date().getTime(), "homePaintura", "532", "200", "6");
        so.addParam("flashVars", "sort=1");
        so.useExpressInstall("expressinstall.swf");
        so.write("noFlash");
    }
    
    contactFormValidation();

    $(".menuitem").hover(
        function() {
            $(this).children(".invisible").attr("class", "visible");
            $(this).children(".normal").attr("class", "selected");
        },
        function() {
            $(this).children(".visible").attr("class", "invisible");
            $(this).children(".selected").attr("class", "normal");
        }
    );

    $(function() {
        $('#ctl00_cphBody_dlFotos a').lightBox();
    });

    $('#slideshow').innerfade({
        animationtype: 'fade',
        speed: 1500,
        type: 'random'
    });
});

function contactFormValidation() {
    $("#aspnetForm").validate({
        rules: {
            ctl00$cphBody$txtNaam: {
                required: true
            },
            ctl00$cphBody$txtPostcode: {
                required: true
            },
            ctl00$cphBody$txtPlaats: {
                required: true
            },
            ctl00$cphBody$txtEmail: {
                required: true,
                email: true
            },
            ctl00$cphBody$txtCommentaar: {
                required: true
            }
        },

        messages: {
            ctl00$cphBody$txtNaam: {
                required: "Verplicht veld"
            },
            ctl00$cphBody$txtPostcode: {
                required: "Verplicht veld"
            },
            ctl00$cphBody$txtPlaats: {
                required: "Verplicht veld"
            },
            ctl00$cphBody$txtEmail: {
                required: "Verplicht veld",
                email: "Ongeldig formaat"
            },
            ctl00$cphBody$txtCommentaar: {
                required: "Verplicht veld"
            }
        },

        errorPlacement: function(error, element) {
            element.parent().children("em").html(error);
            element.parent().children("input").attr("class", "TextBoxError");
            element.parent().children("textarea").attr("class", "TextBoxLargeError");
        },

        success: function(label) {
            label.html("<img src=\"images/ok.png\" alt=\"ok\" />");
            var bijhorendeElement = "#" + $(label).attr("htmlFor");
            if (($(bijhorendeElement).attr("class") == "TextBoxError") || ($(bijhorendeElement).attr("class") == "TextBox")) {
                $(bijhorendeElement).attr("class", "TextBox");
            }
            else {
                $(bijhorendeElement).attr("class", "TextBoxLarge");
            }

            //$(bijhorendeElement).html("");
        },

        highlight: function(element, errorClass) {

        }
    });
}
