$(document).ready(function(){

    windowHeight = $(window).height();
    pageHeight = $("#page").height();
    headerHeight = $("#header").height();
    topOfPageHeight = $("#topOfPage").height();
    contentHeight = $("#content").height();
    footerHeight = $("#footerClippingMask").height();

    function fillSearchBox(what){
        if (what.val()==""||what.val()=="Zoeken"){
            what.addClass("emptySearchBox");
            what.val("Zoeken");
        }
    };
    function clearSearchBox(what){
        if (what.val()=="Zoeken"){
            what.removeClass("emptySearchBox");
            what.val("");
        };
    };
    fillSearchBox($(".searchinput:empty"));
    $(".searchinput").focus(function(){
        clearSearchBox($(this));
    });
    $(".searchinput").blur(function(){
        fillSearchBox($(this));
    });
    
    /*var postI = 0;
    $("body.home .post").each(function () {
        $(this).css({
            marginTop: (postI*7.2)+"em",
            zIndex: 500-postI
        });
        postI++;
    });*/
 
 /*breng posts naar voren on hover*/   
    var hoverI = 2500;
    $(".post").hoverIntent(
    function(){
        prevZindex = this.style.zIndex;
        this.style.zIndex = $(".post").length + hoverI;
    },
    function(){
        $(this).css({
            zIndex: prevZindex
        });
    });
    
    /*navigation*/   
    $("body.category-kerntaak4 #header ul.categories li.cat-item-8").addClass("selected")
    $("body.s-category-kerntaak4 #header ul.categories li.cat-item-8").addClass("selected")
    $("body.category-kerntaak3 #header ul.categories li.cat-item-3").addClass("selected")
    $("body.s-category-kerntaak3 #header ul.categories li.cat-item-3").addClass("selected")
    $("body.category-kerntaak1 #header ul.categories li.cat-item-5").addClass("selected")
    $("body.s-category-kerntaak1 #header ul.categories li.cat-item-5").addClass("selected")
    $("body.category-kerntaak2 #header ul.categories li.cat-item-6").addClass("selected")
    $("body.s-category-kerntaak2 #header ul.categories li.cat-item-6").addClass("selected")
    
    if($("ul.categories li").hasClass(".selected")){ 
        $("#header ul.categories li").hoverIntent(function(){
            if( !$(this).hasClass(".selected") ){
                $(this).children("a").animate({
                    marginTop: "0px"
                },200);
            };
        },
        function(){
            if( !$(this).hasClass(".selected") ){
                $(this).children("a").animate({
                    marginTop:"-17px"
                },200);
            };
        });
    };
    
    /*category introduction*/
    if ($("body.category-kerntaak3 div.introduction p").size()>2){
        $("body.category-kerntaak3 div.introduction").css({
            marginLeft: (4-$("div.introduction p").size())*228+"px"
        })
    }else if ($("body.category-kerntaak2 div.introduction p").size()>3){
        $("body.category-kerntaak3 div.introduction").css({
            marginLeft: 0
        })
    }

});

