$(document).ready(function() {
    /* 
    * attach a function to open all links with a class of "external" in a new window 
    * this avoids the use of target="_blank" and allows us to validate as XHTML strict
    */
    $("a[rel^='external']").click( function() {
        window.open(this.href);
        return false;
    });
    
    $("a[rel^='prettyPhoto']").prettyPhoto();
    
    $("#mailChildsProfile").validate({
        invalidHandler: function(e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                $("#errorMessage span").html('The highlighted fields are required.');
                $("#errorMessage").show();
            } else {
                $("#errorMessage").hide();
            }
        },
        rules: {
            parent_name: "required",
            childs_name: "required",
            childs_age: "required",
            email: {
                required: true,
                email: true
            },
            profile_details: "required"
        },
        messages: {
            email: {
                email: "name@domain.com"
            }
        }
    });
    
    //toggle the componenet with class msg_body
    $(".program_head").click(function() {
        $(this).next(".program_body").slideToggle(400);
    });
    
    $("#cs-eval").mouseover(function(){
        $("#cs-eval-img").attr("src","/images/evaluation-hover.gif");
    }).mouseout(function(){
        $("#cs-eval-img").attr("src","/images/evaluation.gif");
    });
    
    $("#cs-social").mouseover(function(){
        $("#cs-social-img").attr("src","/images/sociallinks-hover.gif");
    }).mouseout(function(){
        $("#cs-social-img").attr("src","/images/sociallinks.gif");
    });


    
});
