function pageLoad() {
    var manager = Sys.WebForms.PageRequestManager.getInstance();    
    manager.add_endRequest(endRequest);
    manager.add_beginRequest(OnBeginRequest);   
}

function OnBeginRequest(sender, args) {
    $('body').addClass('wait');
    //$get('body').className = 'blue wait';
}

function endRequest(sender, args) {
    $('body').removeClass('wait');
    //$get('body').className = 'blue';
}   

function CheckBoxValidatorEvaluateIsValid(val) {
    var control = document.getElementById(val.controltovalidate);
    var mustBeChecked = Boolean(val.mustBeChecked == 'true');

    return control.checked == mustBeChecked;
}
function ReloadJQuery() {      
        //$(".content_grey_bar_fade_premium").prepend($(".wrapper_bkg_premium_assignment_footer").html()).addClass("fBreadcrumb"); 
        
        $(".wrapper_bkg_premium_assignment_footer:last").clone().insertBefore(".content_grey_bar_fade_premium").addClass("fBreadcrumb");        
        
        //$(".interim_resume_exclude_from_print:first").after($(".interim_resume_exclude_from_print:last").html().    ('<div class="interim_resume_exclude_from_print fBreadcrumb"></div>'));         
        
        $(".interim_resume_exclude_from_print:last").clone().insertAfter(".interim_resume_exclude_from_print:first").addClass("fBreadcrumb");
        
        
        
        
         if ($("#content_zone_left_zoekopdracht", "#content_zone_right").length) {
            $("#content_zone_left #content_zone_left_zoekopdracht table").hide();
            $("#content_zone_right #content_zone_left_zoekopdracht table").show();                    
            $("#content_zone_left").css("z-index", "100"); 
            $("#content_zone_right").css("z-index", "110");

            $("#content_zone_left #content_zone_left_zoekopdracht").css("height", "145px");
            if ($.browser.msie && $.browser.version.substr(0, 1) < 8) {
                $("#content_zone_left #content_zone_left_zoekopdracht").css("height", "150px");
            }
            $("#content_zone_right #content_zone_left_zoekopdracht table").css("display", "block");         
        } else {        
            $("#content_zone_left #content_zone_left_zoekopdracht table").show();
            $("#content_zone_left #content_zone_left_zoekopdracht").css("height", "auto");
            $("#content_zone_left").css("z-index", "110"); 
            $("#content_zone_right").css("z-index", "100");         
            $("#content_zone_right #content_zone_left_zoekopdracht table").hide();
        }

        $(".extOpleiding").each(function(){
            var extOpleidingHTML = $(this).text();
            if(extOpleidingHTML.length < 5){
                $(this).hide();
            }
        });
        
        $(".textarea_medium:first", ".werkervaring ").css("height", "200px");
        
        $(".werkervaring").each(function(){
            //alert($(".textarea:last", this).height());
            if($(".textarea:last", this).height() > 150)
            {
                $(".extOpleiding:contains('Taak of verantwoordelijkheid verwijderen'):first", this).hide();      
            }
        });
        
          


        $(".content_block_half_page:odd").css("margin-right", "0px");
        $(".content_block_rectangle:odd").css("margin-right", "0px");
        $(".content_block_home:odd").css("margin-right", "0px");
        
        $(".content_block_home").show();
                
        //$(".content_block_half_page:odd").css("margin-right", "0px");


        $('.dp').datepicker({ dateFormat: 'dd-mm-yy', changeMonth: true, changeYear: true, showOn: 'both', buttonImage: 'https://planetinterim.nl/images/icon_calendar.gif', buttonImageOnly: true });
        $('.dp').datepicker({ onSelect: function() { } });

        $('input').each(function() {
            if ($(this).attr('type') == "text" || $(this).attr('type') == "password") {
                $(this).focus(function() {
                    $(this).addClass("activeInput");
                }).blur(function() {
                    $(this).removeClass("activeInput");                    
                });
            }
            if ($(this).attr('type') == "radio") {
                $(this).focus(function() {
                  
                }).blur(function() {
                    $(this).removeClass("activeInput");
                  
                });
            }
        });
        $('.ddlTitle').focus(function() {
            $(this).addClass("activeInput");
            
        }).blur(function() {
            $(this).removeClass("activeInput");
            
        });

        $('.dropdown_profiel_aanmaken_dag, .dropdown_profiel_aanmaken_maand, .dropdown_profiel_aanmaken_jaar').focus(function() {
            
            $(this).addClass("activeInput");
        }).blur(function() {
            $(this).removeClass("activeInput");
            
        });
        $('textarea').focus(function() {
            $(this).addClass("activeInput");
            
        }).blur(function() {
            $(this).removeClass("activeInput");
            
        });

        $('input', '.form_radiobuttons').click(function() {
            var tav = $(this).val();
            if (tav == 'rdbGenderMale') {
                $('.tav').text('de heer');
            } else {
                $('.tav').text('mevrouw');
            }
        });
        $(".count").each(function(){
            var parent = $(this).parent();                       
            
        });
        $(".content_block_home").each(function(){
             $("a:first", this).attr("href", $("a:eq(2)", this).attr("href"));      
        });        
    
    $("#vdIP").click(function(){
        $('.vdOP').hide();        
        $('.vdIP').show();
        
        $(".btn_teaser_text","#vdIP").css("text-decoration","underline");        
        $(".btn_teaser_text","#vdOP").css("text-decoration","none");
        
    });
    $("#vdOP").click(function(){
        $('.vdIP').hide();
        $('.vdOP').show();        
        
        $(".btn_teaser_text","#vdOP").css("text-decoration","underline");        
        $(".btn_teaser_text","#vdIP").css("text-decoration","none");
    });    
    
    $('.ro').mouseover(function(){
        $(this).addClass("mo");        
    }).mouseout(function(){
        $(this).removeClass("mo");        
    });    
    
    $('.jobListItem').css("border-bottom", "1px solid #EEE");
     
    $('.jobListItem:first').before('<div class="assignment_search_result_title"><table cellpadding="0" cellspacing="0" border="0"><tr><td width="245" valign="top">Opdracht</td><td width="130" valign="top">Sector</td><td width="60" align="left" valign="top">Tarief (&euro;)</td><td width="10" valign="top">&nbsp;</td><td width="100" valign="top">Regio</td><td width="60" valign="top">Opleiding</td></tr></table></div>');
    
    $("a", ".news_title").each(function(){          
               $(this).attr("href", $(this).attr("href").replace("%0d%0a", ''));      
        });        
    $(".nawRequestLinkSet").attr("href", $(".nawRequestLink").attr("href"));    
        
    var charCount700count = 0;
    
    $(".charCount700").each(function()
    {       
        var charCountText = $(this).val().replace(/\n/g, "  ");
        $(this).after('<span class="countChars"><span class="charCount'+charCount700count+'">'+charCountText.length+'</span> / <span class="charMax">700</span> tekens</span><br/><br/>');    
        $(this).keyup(function()
        {  
            charCountText = $(this).val().replace(/\n/g, "  ");
            $(".charCount"+$(".charCount700").index(this)).text(charCountText.length);
            if(charCountText.length > 700){
                $(this).addClass("borderError");       
                $(".countChars", $(this).parent()).addClass("red");                           
            }else{
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");  
            }                                            
        });
         charCount700count++;
    });
    var charCount1000count = 0;
    $(".charCount1000").each(function()
    {   
       
        var charCountText1000 = $(this).val().replace(/\n/g, "  ");
        $(this).after('<span class="countChars"><span class="charCount'+charCount1000count+'">'+charCountText1000.length+'</span> / <span class="charMax">1000</span> tekens</span><br/><br/>');    
        $(this).keyup(function()
        {  
            charCountText1000 = $(this).val().replace(/\n/g, "  ");
            $(".charCount"+$(".charCount1000").index(this)).text(charCountText1000.length);
            if(charCountText1000.length > 1000){
                $(this).addClass("borderError");       
                $(".countChars", $(this).parent()).addClass("red");                           
            }else{
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");  
            }                                            
        });
         charCount1000count++;   
    });
    
    var charCount2000count = 0;
    $(".charCount2000:first", ".werkervaring ").each(function()
    {   
        var charCountText2000 = $(this).val().replace(/\n/g, "  ");        
        $(this).after('<span class="countChars"><span class="charCount'+charCount2000count+'">'+charCountText2000.length+'</span> / <span class="charMax">2000</span> tekens</span><br/><br/>');    
        
        $(this).keyup(function()
        {  
            charCountText2000 = $(this).val().replace(/\n/g, "  ");
            //alert($(".charCount2000:first", ".werkervaring ").index(this));
            $(".charCount"+$(".charCount2000:first", ".werkervaring ").index(this)).text(charCountText2000.length);
            if(charCountText2000.length > 2000){
                $(this).addClass("borderError");       
                $(".countChars", $(this).parent()).addClass("red");                           
            }else{
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");  
            }                                            
        });
        charCount2000count++
    });

    var charCount40000count = 0;
    $(".charCount40000:first", ".werkervaring ").each(function() {
        var charCountText40000 = $(this).val().replace(/\n/g, "  ");
        $(this).after('<span class="countChars"><span class="charCount' + charCount40000count + '">' + charCountText40000.length + '</span> / <span class="charMax">40000</span> tekens</span><br/><br/>');

        $(this).keyup(function() {
            charCountText40000 = $(this).val().replace(/\n/g, "  ");
            //alert($(".charCount40000:first", ".werkervaring ").index(this));
            $(".charCount" + $(".charCount40000:first", ".werkervaring ").index(this)).text(charCountText40000.length);
            if (charCountText40000.length > 40000) {
                $(this).addClass("borderError");
                $(".countChars", $(this).parent()).addClass("red");
            } else {
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");
            }
        });
        charCount40000count++
    });

    var toolBar = $(".charCount40000").attr("id");
    edToolbar(toolBar);
    
    var charCountOpdracht2000count = 0;
    $(".charCountOpdracht2000").each(function()
    {   
        var charCountText2000 = $(this).val().replace(/\n/g, "  ");        
        $(this).after('<span class="countChars"><span class="charCount'+charCountOpdracht2000count+'">'+charCountText2000.length+'</span> / <span class="charMax">2000</span> tekens</span><br/><br/>');    
        
        $(this).keyup(function()
        {  
            charCountText2000 = $(this).val().replace(/\n/g, "  ");
            //alert($(".charCountOpdracht2000:first", ".werkervaring ").index(this));
            $(".charCount"+$(".charCountOpdracht2000").index(this)).text(charCountText2000.length);
            if(charCountText2000.length > 2000){
                $(this).addClass("borderError");       
                $(".countChars", $(this).parent()).addClass("red");                           
            }else{
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");  
            }                                            
        });
        charCountOpdracht2000count++
    });
      
    var charCount300count = 0;
    $(".charCount300").each(function()
    {
    
        var charCountText300 = $(this).val().replace(/\n/g, "  ");
        
        $(this).after('<span class="countChars"><span class="charCount'+charCount300count+'">'+charCountText300.length+'</span> / <span class="charMax">300</span> tekens</span><br/><br/>');    
        $(this).keyup(function()
        {  
            charCountText300 = $(this).val().replace(/\n/g, "  ");
            $(".charCount"+$(".charCount300").index(this)).text(charCountText300.length);
            if(charCountText300.length > 300){
                $(this).addClass("borderError");       
                $(".countChars", $(this).parent()).addClass("red");                           
            }else{
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");  
            }                                            
        });
        charCount300count++;
    });

    var charCount140count = 0;
    $(".charCount140").each(function() {

        var charCountText140 = $(this).val().replace(/\n/g, "  ");

        $(this).after('<span class="countChars"><span class="charCount' + charCount140count + '">' + charCountText140.length + '</span> / <span class="charMax">140</span> tekens</span><br/><br/>');
        $(this).keyup(function() {
            charCountText140 = $(this).val().replace(/\n/g, "  ");
            $(".charCount" + $(".charCount140").index(this)).text(charCountText140.length);
            if (charCountText140.length > 140) {
                $(this).addClass("borderError");
                $(".countChars", $(this).parent()).addClass("red");
            } else {
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");
            }
        });
        charCount140count++;
    });

    var charCount70count = 0;
    $(".charCount70").each(function() {

        var charCountText70 = $(this).val().replace(/\n/g, "  ");

        $(this).after('<span class="countChars"><span class="charCount' + charCount70count + '">' + charCountText70.length + '</span> / <span class="charMax">70</span> tekens</span><br/><br/>');
        $(this).keyup(function() {
            charCountText70 = $(this).val().replace(/\n/g, "  ");
            $(".charCount" + $(".charCount70").index(this)).text(charCountText70.length);
            if (charCountText70.length > 70) {
                $(this).addClass("borderError");
                $(".countChars", $(this).parent()).addClass("red");
            } else {
                $(this).removeClass("borderError");
                $(".countChars", $(this).parent()).removeClass("red");
            }
        });
        charCount70count++;
    });
    
    $('#navi_main_left_top a[href^="/"]').each(function() {    	    
            var curHref = $(this).attr('href');            
            var checkHttps = location.href.indexOf("https");
            if (checkHttps!=-1){               
                $(this).attr("href", "http://planetinterim.nl"+curHref);
            }
    });
    
    /* zoek javascript voor uitklapt checkboxen divs */
    
    $(".ddlExt input:checkbox").each(function(){
          $(this).click(function(){                              
                //$(this).attr("checked", "checked");
                var parentObject = $(this).parentsUntil('.pR').parent();                       
                if(countCheckboxes(parentObject)>0){
                    $(".ddlTextCount", parentObject).text("("+countCheckboxes(parentObject)+")");
                }else{
                     $(".ddlTextCount", parentObject).text("");
                }
                //$(".ddlExt").css("visibility", "visible");
            });
        });

// Added by AP team toolBar validate field of expertise
        $(".ddlExpCount input:checkbox").each(function() {
            $(this).click(function() {
                //$(this).attr("checked", "checked");
                var parentObject = $(this).parentsUntil('.pR').parent();
                if (countCheckboxes(parentObject) > 0) {
                if (countCheckboxes(parentObject) < 4) {
                        $(".ddlTextCount", parentObject).text("(" + countCheckboxes(parentObject) + ")");
                    }
                    else {
                        alert('max. 3 opties toegestaan.');
                        $(this).attr("checked", "");
                        $(".ddlTextCount", parentObject).text("(" + countCheckboxes(parentObject) + ")");
                    }
                } else {
                    $(".ddlTextCount", parentObject).text("");
                }
                //$(".ddlExt").css("visibility", "visible");
            });
        });
        // Added by AP team toolBar validate function group
        $(".ddlfuncgroupcount input:checkbox").each(function() {
            $(this).click(function() {
                //$(this).attr("checked", "checked");
                var parentObject = $(this).parentsUntil('.pR').parent();
                if (countCheckboxes(parentObject) > 0) {
                    if (countCheckboxes(parentObject) < 11) {
                        $(".ddlTextCount", parentObject).text("(" + countCheckboxes(parentObject) + ")");
                    }
                    else {
                        alert('max. 10 functiegroepen per vakgebied toegestaan.');
                        $(this).attr("checked", "");
                        $(".ddlTextCount", parentObject).text("(" + countCheckboxes(parentObject) + ")");
                    }
                } else {
                    $(".ddlTextCount", parentObject).text("");
                }
                //$(".ddlExt").css("visibility", "visible");
            });
        });
        // Added by AP team toolBar validate function group in registration page
        $(".ddlfuncgroupcountreg input:checkbox").each(function() {
            $(this).click(function() {
                //$(this).attr("checked", "checked");
                var parentObject = $(this).parentsUntil('.pR').parent();
                if (countCheckboxes(parentObject) > 0) {
                    if (countCheckboxes(parentObject) < 31) {
                        $(".ddlTextCount", parentObject).text("(" + countCheckboxes(parentObject) + ")");
                    }
                    else {
                        alert('max. 30 functiegroepen per vakgebied toegestaan.');
                        $(this).attr("checked", "");
                        $(".ddlTextCount", parentObject).text("(" + countCheckboxes(parentObject) + ")");
                    }
                } else {
                    $(".ddlTextCount", parentObject).text("");
                }
                //$(".ddlExt").css("visibility", "visible");
            });
        });
    $(".ddlExt .closeDdl").click(function() {
        $(this).parent().parent().toggle();
    });
    $(".ddlExt .closeDdlFOE").click(function() {
        $(this).parent().parent().toggle();
        //alert('$($get("ctl00_ucProductSearchControl_btnfieldepertiseclick")).click();');
        //$($get("ctl00_ucProductSearchControl_btnfieldepertiseclick")).click();
        //$('#<%= ctl00_ucProductSearchControl_btnfieldepertiseclick.ClientID %>').click();
        //window.document.forms[0].elements['<%=ctl00_ucProductSearchControl_btnfieldepertiseclick.ClientID %>'].click();
        closefieldofexpertise();
    });
     
     function countCheckboxes(parentObject){        
        var countChecked = 0;
        $("input:checked", parentObject).each(function()
        {                                                  
            countChecked++;	                                                
        });       
        return countChecked;
     }
      
     $(".toggleDivEducation, .divEducationCount").click(function()
     {        
        $("option", this).toggle();         
        $(".divRegion").hide();
        $(".divSector").hide();
        
        var parentObject = $(this).parent();         
        $(parentObject).css("z-index", 1000-$(".pR").index(parentObject));
        $(".divEducation:last").toggle();
        $(".divEducation:last input:checkbox:last").focus()
     });
     $(".toggleDivRegion, .divRegionCount").click(function() {
         $("option", this).toggle();

         $(".divSector").hide();
         $(".divEducation").hide();

         var parentObject = $(this).parent();
         $(parentObject).css("z-index", 1000 - $(".pR").index(parentObject));
         $(".divRegion:last", parentObject).toggle();
         $(".divRegion:last input:checkbox:last", parentObject).focus()
     }); 
     $(".toggleDivSector, .divSectorCount").click(function()
     {        
        $("option", this).toggle();
        var parentObject = $(this).parent();         
        $(".divRegion").hide();
        $(".divEducation").hide();                
        $(parentObject).css("z-index", 1000-$(".pR").index(parentObject));
        $(".divSector:last").toggle();
        $(".divSector:last input:checkbox:last").focus()
    });
    $(".toggleDivExpertise, .divExpertiseCount").click(function() {
        $("option", this).toggle();
        var parentObject = $(this).parent();
        $(".divRegion").hide();
        $(".divEducation").hide();
        $(parentObject).css("z-index", 1000 - $(".pR").index(parentObject));
        $(".divExpertise:last").toggle();
        $(".divExpertise:last input:checkbox:last").focus()
        if ($(".divExpertise:last").is(":visible") == false) {
            closefieldofexpertise();
        }
    });
    $(".toggleDivFunctionGroup, .divFunctionGroupCount").click(function() {
        $("option", this).toggle();
        var parentObject = $(this).parent();
        $(".divRegion").hide();
        $(".divEducation").hide();
        $(parentObject).css("z-index", 1000 - $(".pR").index(parentObject));
        $(".divFunctionGroup:last").toggle();
        $(".divFunctionGroup:last input:checkbox:last").focus()
    }); 
     
     var userAgent = navigator.userAgent.toLowerCase();
 
    // Figure out what browser is being used
    jQuery.browser = {
	    version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1],
	    chrome: /chrome/.test( userAgent ),
	    safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
	    opera: /opera/.test( userAgent ),
	    msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
	    mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
    };  
     
     
    $(".pR input:checkbox").addClass("checkBox");
    $(".divSector td").attr("valign", "top");
    $("table", ".ddlExt").addClass("ieTable");
      
    if ($.browser.safari) 
    {
        $(".ddlText").addClass("safari");
    }
    else if ($.browser.msie) 
    {         
        if($.browser.version == "7.0"){      
            $(".ddlText").addClass("ie7");      
            $(".ddlExt").addClass("ie7");      
        }
        if($.browser.version == "8.0"){
            $(".ddlText").addClass("ie8");      
            $(".ddlExt").addClass("ie8");      
        }
        $('<option value="" style="display:none"></option>').appendTo('.toggleDivEducation');
        $('<option value="" style="display:none"></option>').appendTo('.toggleDivSector');
        $('<option value="" style="display:none"></option>').appendTo('.toggleDivRegion');
        $('<option value="" style="display:none"></option>').appendTo('.toggleDivExpertise');
        $('<option value="" style="display:none"></option>').appendTo('.toggleDivFunctionGroup');
    }
    else if ($.browser.mozilla) 
    {
        $(".ddlText").addClass("ff");    
    }
    else if ($.browser.webkit) 
    {
        $(".ddlText").addClass("chrome");   
    }
    $("h6").each(function(){
        $(this).hide();
    }); 
    
    $("h5").each(function(){
        $(this).click(function()
        {   
            $("h6:gt("+$("h5").index(this)+")").hide();      
            $("h6:lt("+$("h5").index(this)+")").hide();                  
            $("h6:gt("+$("h5").index(this)+")").removeClass("active");
            $("h6:lt("+$("h5").index(this)+")").removeClass("active");   
            $("h6:eq("+$("h5").index(this)+")").toggle();
            
            if($(this).hasClass("active")){
                $(this).removeClass("active");
            }else{
                $(this).addClass("active");
            }
        });     
    }); 
     
    $('#wrapper_content_zone a[href^="http://"]').each(function() {    	    
            var chk = ($(this).attr('href').indexOf("planetinterim.nl"));            
            if (chk==-1){               
                $(this).attr("href", "/outgoing.aspx?url=" + $.URLEncode($(this).attr("href")));
                $(this).attr("target", "_blank");
            }
          });
    
    if($("#tt_linkedin_message").text().length>10){
        $("#tt_linkedin_message").delay(200).fadeIn("normal");
    }
          
    if($("#tt_linkedin_message").text().length>10){
        $("#tt_linkedin_message").delay(4000).fadeOut("normal");
    }
    if($(".hiddenAppl input").val() =="true"){
        $(".interim_resume_exclude_from_print").remove();    
    }
    
    if($("#navi_main_right").height() > 111)
    {
        $("#wrapper_content_zone").css("min-height", $("#navi_main_right").height() - 110);
    }

    $(".textfield_content_zone_left_zoekopdracht:first").blur(function()
    {
        if ($(this).val() != "Zoek op trefwoord")
        {
            var zoekTekst = $(this).val();
            $(this).val(zoekTekst.replace(" ", '+'));
        }
    });

    $(".textfield_content_zone_left_zoekopdracht:first").each(function()
    {
        if ($(this).val() != "Zoek op trefwoord")
        {
            var zoekTekst = $(this).val();
            $(this).val(zoekTekst.replace(" ", '+'));
        }
    });

    /*collapse region's */
    $(".divRegion table").each(function()
    {
        $(this).hide();
    });
    $(".divRegion table input[type=checkbox]").each(function()
    {
        $(this).addClass("regionCheckboxTable");
    });

    $(".content_zone_left_zoekopdracht .divRegion .nl").show();
    
    $("h2", "#content_zone_left_zoekopdracht .multi .divRegion").each(function() {
        $(this).before('<input type="checkbox" id="chb_region_' + $("h2").index(this) + '" class="regionCheckbox">');

        $(this).click(function() {
        var parentDiv = $(this).parent();
            
            //console.log(parentDiv.html());            
            $("table:gt(" + $("#content_zone_left_zoekopdracht .divRegion:last h2").index(this) + ")", parentDiv).hide();
            $("table:lt(" + $("#content_zone_left_zoekopdracht .divRegion:last h2").index(this) + ")", parentDiv).hide();
            $("h2:gt(" + $("#content_zone_left_zoekopdracht .divRegion:last h2").index(this) + ")", parentDiv).removeClass("active");
            $("h2:lt(" + $("#content_zone_left_zoekopdracht .divRegion:last h2").index(this) + ")", parentDiv).removeClass("active");
            $("table:eq(" + $("#content_zone_left_zoekopdracht .divRegion:last h2").index(this) + ")", parentDiv).toggle();
            //$("h2", ".divRegion").removeClass("active");
            if ($(this).hasClass("active")) {
                $(this).removeClass("active");
            } else {
                $(this).addClass("active");
            }
        });
    });

    $(".form_content_left .divRegion .nl").show();

    $("h2", ".form_content_left .multi .divRegion").each(function()
    {
        $(this).before('<input type="checkbox" id="chb_region_' + $("h2").index(this) + '" class="regionCheckbox">');

        $(this).click(function()
        {
            var parentDiv = $(this).parent();
            //alert($(".form_content_left .divRegion h2").index(this));

            $("table:gt(" + $(".form_content_left .divRegion h2").index(this) + ")", parentDiv).hide();
            $("table:lt(" + $(".form_content_left .divRegion h2").index(this) + ")", parentDiv).hide();
            $("h2:gt(" + $(".form_content_left .divRegion h2").index(this) + ")", parentDiv).removeClass("active");
            $("h2:lt(" + $(".form_content_left .divRegion h2").index(this) + ")", parentDiv).removeClass("active");
            $("table:eq(" + $(".form_content_left .divRegion h2").index(this) + ")", parentDiv).toggle();
            //$("h2", ".divRegion").removeClass("active");
            if ($(this).hasClass("active"))
            {
                $(this).removeClass("active");
            } else
            {
                $(this).addClass("active");
            }
        });
    });

    $(".divRegion table input[type=radio]").each(function() {
        $(this).addClass("regionRadioTable");
    });

    $(".formAanmelden .divRegion .nl").show();

    $("h2", ".formAanmelden .single .divRegion").each(function() {
        //$(this).before('<input type="checkbox" id="chb_region_' + $("h2").index(this) + '" class="regionRadio">');

        $(this).click(function() {
            var parentDiv = $(this).parent();
            
            $("table:gt(" + $(".formAanmelden .divRegion h2").index(this) + ")", parentDiv).hide();
            $("table:lt(" + $(".formAanmelden .divRegion h2").index(this) + ")", parentDiv).hide();
            $("h2:gt(" + $(".formAanmelden .divRegion h2").index(this) + ")", parentDiv).removeClass("active");
            $("h2:lt(" + $(".formAanmelden .divRegion h2").index(this) + ")", parentDiv).removeClass("active");
            $("table:eq(" + $(".formAanmelden .divRegion h2").index(this) + ")", parentDiv).toggle();
            //$("h2", ".divRegion").removeClass("active");
            if ($(this).hasClass("active")) {
                $(this).removeClass("active");
            } else {
                $(this).addClass("active");
            }
        });
    });

    $("input[type=radio]:checked", ".formAanmelden .single .divRegion").each(function() {
        //console.log($("label:eq(" + $("input[type=radio]").index(this) + ")", ".formAanmelden .single .divRegion").text());
        $(".regioValue").text($("label:eq(" + $("input[type=radio]").index(this) + ")", ".formAanmelden .single .divRegion").text());     
    });
    
    
    
    $("input[type=radio]", ".formAanmelden .single .divRegion").each(function() {
        $(this).click(function() {        
            var parentDiv = $(this).parent();
            //console.log($("label:eq(" + $("input[type=radio]").index(this) + ")", ".formAanmelden .single .divRegion").text());
            $(".regioValue").text($("label:eq(" + $("input[type=radio]").index(this) + ")", ".formAanmelden .single .divRegion").text());            
        });
    });   
    
    
    $("#content_zone_left_zoekopdracht .divRegion").each(function()
    {
        $(this).hide();
    });
    $(".form_content_left .divRegion").each(function()
    {
        $(this).hide();
    });

    $("#content_zone_left_zoekopdracht .regionCheckbox").click(function()
    {
        var parentCheckbox = $(this);
        //alert($("input.regionCheckbox").index(this));
        $("#content_zone_left_zoekopdracht .divRegion table:eq(" + $("input.regionCheckbox").index(this) + ") input[type=checkbox]").each(function()
        {
            $(this).attr("checked", $(parentCheckbox).attr("checked"));
        });
        var countCheckedRegions = 0;
        $("#content_zone_left_zoekopdracht .regionCheckbox:checked").each(function()
        {
            countCheckedRegions++;
        });
        if (countCheckedRegions > 0)
        {
            $("#content_zone_left_zoekopdracht .regionCheckbox:not(:checked)").attr("disabled", "disabled")
        } else
        {
            $("#content_zone_left_zoekopdracht .regionCheckbox:not(:checked)").removeAttr("disabled")
        }
        var countCheckBox = 0;
        $("#content_zone_left_zoekopdracht .regionCheckboxTable:checked").each(function()
        {
            countCheckBox++;
        });

        //$(this).attr("checked", "checked");
        if (countCheckBox > 0)
        {
            $("#content_zone_left_zoekopdracht .divRegionCount .ddlTextCount").text("(" + countCheckBox + ")");
        } else
        {
            $("#content_zone_left_zoekopdracht .divRegionCount .ddlTextCount").text("(0)");
        }

        var countCheckedRegionsTable = 0;
        $("#content_zone_left_zoekopdracht .regionCheckboxTable:checked").each(function()
        {
            countCheckedRegionsTable++;
        });
        if (countCheckedRegionsTable > 4)
        {
            $("#content_zone_left_zoekopdracht .regionCheckboxTable:not(:checked)").attr("disabled", "disabled");
        } else
        {
            $("#content_zone_left_zoekopdracht .regionCheckboxTable:not(:checked)").removeAttr("disabled");
        }

    });

    $(".form_content_left .regionCheckbox").click(function()
    {
        var parentCheckbox = $(this);
        //alert($("input.regionCheckbox").index(this));
        $(".form_content_left .divRegion table:eq(" + $(".form_content_left .divRegion input.regionCheckbox").index(this) + ") input[type=checkbox]").each(function()
        {
            $(this).attr("checked", $(parentCheckbox).attr("checked"));
        });
        var countCheckedRegions = 0;
        $(".form_content_left .regionCheckbox:checked").each(function()
        {
            countCheckedRegions++;
        });
        if (countCheckedRegions > 0)
        {
            $(".form_content_left .regionCheckbox:not(:checked)").attr("disabled", "disabled")
        } else
        {
            $(".form_content_left .regionCheckbox:not(:checked)").removeAttr("disabled")
        }
        var countCheckBox = 0;
        $(".form_content_left .regionCheckboxTable:checked").each(function()
        {
            countCheckBox++;
        });

        //$(this).attr("checked", "checked");
        if (countCheckBox > 0)
        {
            $(".form_content_left .divRegionCount .ddlTextCount").text("(" + countCheckBox + ")");
        } else
        {
            $(".form_content_left .divRegionCount .ddlTextCount").text("(0)");
        }

        var countCheckedRegionsTable = 0;
        $(".form_content_left .regionCheckboxTable:checked").each(function()
        {
            countCheckedRegionsTable++;
        });
        if (countCheckedRegionsTable > 4)
        {
            $(".form_content_left .regionCheckboxTable:not(:checked)").attr("disabled", "disabled");
        } else
        {
            $(".form_content_left .regionCheckboxTable:not(:checked)").removeAttr("disabled");
        }

    });

    $("#content_zone_left_zoekopdracht .regionCheckboxTable").click(function()
    {
        var countCheckedRegionsTable = 0;
        $("#content_zone_left_zoekopdracht .regionCheckboxTable:checked").each(function()
        {
            countCheckedRegionsTable++;
        });
        if (countCheckedRegionsTable > 4)
        {
            $("#content_zone_left_zoekopdracht .regionCheckboxTable:not(:checked)").attr("disabled", "disabled");
        } else
        {
            $("#content_zone_left_zoekopdracht .regionCheckboxTable:not(:checked)").removeAttr("disabled");
        }
        if (countCheckedRegionsTable == 0)
        {
            $("#content_zone_left_zoekopdracht .regionCheckbox:not(:checked)").removeAttr("disabled");
            $("#content_zone_left_zoekopdracht .regionCheckbox").removeAttr("checked")
        }
    });

    $(".form_content_left .regionCheckboxTable").click(function()
    {
        var countCheckedRegionsTable = 0;
        $(".form_content_left .regionCheckboxTable:checked").each(function()
        {
            countCheckedRegionsTable++;
        });
        if (countCheckedRegionsTable > 4)
        {
            $(".form_content_left .regionCheckboxTable:not(:checked)").attr("disabled", "disabled");
        } else
        {
            $(".form_content_left .regionCheckboxTable:not(:checked)").removeAttr("disabled");
        }
        if (countCheckedRegionsTable == 0)
        {
            $(".form_content_left .regionCheckbox:not(:checked)").removeAttr("disabled");
            $(".form_content_left .regionCheckbox").removeAttr("checked")
        }
    });
    $(".textfield_content_zone_left_zoekopdracht:first").bind('click, focus', function(){        
        if( $(this).val() == "Zoek op trefwoord"){
            $(this).val("");
        }    
    }).focusout(function(){
        if( $(this).val() == ""){
            $(this).val("Zoek op trefwoord");
        }
    });
    
    $(".textfield_navi_search_bar").bind('click, focus', function() {
    if ($(this).val() == "Zoek binnen deze site") {
            $(this).val("");
        }
    });

    $(".txtEmail").bind('click, focus', function() {
    if ($(this).val() == "E-mailadres") {
            $(this).val("");
        }
    });
    
    
}

function showTooltip()
{
    $(".linkedIn .tt_linkedin").attr("data", "linkedin_short");

    var activeTip = $(".linkedIn .tt_linkedin");
    $("#tt_linkedin_short").removeClass("big");
    var i = 0;
    $.ajax({
        type: "GET",
        url: "/xml/tooltips.xml",
        dataType: "xml",
        success: function(xml)
        {
            $(xml).find('tt').each(function()
            {
                var infoblok = $(this).find('infoblok').text();
                var name = $(this).attr('name');
                if (activeTip.attr('data') == name && !$('#tt_' + name).length)
                {
                    var tip;
                    tip = '<div class="tTip_l" id="tt_' + name + '"><div class="tt_arrow"></div>' + infoblok + '<span class="close">sluiten</span></div>';
                    //alert(tip);      				        
                    activeTip.after(tip);
                    $(".close").click(function()
                    {
                        $(this).parent().remove();
                    });
                } else
                {
                    $('#tt_' + name).remove();
                }
            });
        }
    });
}

function DeActivateDiv(divElement) {
	
	var the_item = document.getElementById(divElement);
	if (document.getElementById)
	{ // DOM3 = IE5, NS6
		if (the_item.style.display == 'block')
		    the_item.style.display = 'none';
	}	
	else	
	{
		if (document.layers)
		{ // Netscape 4
			if (the_item.display == 'block')
    			the_item.display = 'none';
		}
		else
		{ // IE 4
			if (the_item.style.display == 'block')
			    the_item.style.display = 'none';
		}
	}
}

function ActivateDiv(divElement) 
{
	var the_item = document.getElementById(divElement);	
	if (the_item == null)
	    return;
	
	if (document.getElementById)
	{ // DOM3 = IE5, NS6
		if (the_item.style.display == 'none')
    		the_item.style.display = 'block';
	}	
	else	
	{
		if (document.layers)
		{ // Netscape 4
			if (the_item.display == 'none')
    			the_item.display = 'block';
		}
		else
		{ // IE 4
			if (the_item.style.display == 'none')
    			the_item.style.display = 'block';
		}
	}
}

//function FireDefaultButton(event, target) {
//    // srcElement is for IE
//    var element = event.target || event.srcElement;

//    if (13 == event.keyCode && !(element && "textarea" == element.tagName.toLowerCase())) {
//        var defaultButton;
//        defaultButton = document.getElementById(target);

//        if (defaultButton && "undefined" != typeof defaultButton.click) {
//            defaultButton.click();
//            event.cancelBubble = true;
//            if (event.stopPropagation)
//                event.stopPropagation();
//            return false;
//        }
//    }
//    return true;
//}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function triggerPageView(page) {   
    _gaq.push(['_trackPageview', page]); 
}

$.extend({ URLEncode: function(c) {
    var o = ''; var x = 0; c = c.toString(); var r = /(^[a-zA-Z0-9_.]*)/;
    while (x < c.length) {
        var m = r.exec(c.substr(x));
        if (m != null && m.length > 1 && m[1] != '') {
            o += m[1]; x += m[1].length;
        } else {
            if (c[x] == ' ') o += '+'; else {
                var d = c.charCodeAt(x); var h = d.toString(16);
                o += '%' + (h.length < 2 ? '0' : '') + h.toUpperCase();
            } x++;
        }
    } return o;
},
    URLDecode: function(s) {
        var o = s; var binVal, t; var r = /(%[^%]{2})/;
        while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') {
            b = parseInt(m[1].substr(1), 16);
            t = String.fromCharCode(b); o = o.replace(m[1], t);
        } return o;
    }
});
