	//  isLeeg( string)
    //      Controleert of de gegeven string leeg is of alleen maar spaties bevat
    //      returned true wanneer de string leeg is anders false
    //
    function isLeeg( deString){
        return( trim( deString).length == 0);
    }


    //  trim( string)
    //      Haalt alle spaties aan het begin en het eind van een string weg
    //
    function trim( deString)    {
        deString = String( deString);

        // Verwijder alle spaties aan het begin
        while( isSpatie( deString.charAt(0))) {
            deString = deString. substring( 1, deString.length);
        }

        // Verwijder de spaties aan het eind
        while( isSpatie( deString.charAt( deString.length - 1))) {
            deString = deString.substring( 0, deString.length - 1);
        }

        return( deString);
    }


    //  isSpatie()
    //      Controleer of het karakter een spatie, tab of nieuwe regel is
    //
    function isSpatie( karakter){
        karakter = String( karakter);
        return( karakter == ' '   ||   karakter == '\n'  ||  karakter == '\r'  ||  karakter == '\t');
    }

	function IncludeJavaScript(bestand)
	{
  		document.write('<script type="text/javascript" src="' + bestand + '"></script>');
	}

    function rgbToHex(rgb) {
        var rgbvals = /rgb\((.+),(.+),(.+)\)/i.exec(rgb);
        var rval = parseInt(rgbvals[1]);
        var gval = parseInt(rgbvals[2]);
        var bval = parseInt(rgbvals[3]);
        rval = rval.toString(16);
        if (rval.length == 1) { rval = '0' + rval; } // FF verwijdert de voorloop-nul
        gval = gval.toString(16);
        if (gval.length == 1) { gval = '0' + gval; }
        bval = bval.toString(16);
        if (bval.length == 1) { bval = '0' + bval; }
        return '#' + (
            rval +
            gval +
            bval
        ).toUpperCase();
    }

    function achtergrondkleur( selector) {
        var kleur = $(selector).css("background-color");
        if (kleur != undefined) {
            if (kleur.indexOf('rgb') == -1) {
                // IE
            }
            else {
                // FF
                kleur = rgbToHex( kleur);
            }
        }

        return kleur;
    }

	function rondeHoeken() {

        Rounded("div#info","tl","#fff","#d1e5fc","smooth");
        Rounded("div#info","bl","#fff","#d1e5fc","smooth");

        if (achtergrondkleur("div#boxzoeken") != undefined) {
            Rounded("div#boxzoeken","all","#fff",achtergrondkleur("div#boxzoeken"),"border " + achtergrondkleur("div#boxzoeken"));
        }

        if (achtergrondkleur("div#boxlogin") != undefined) {
            Rounded("div#boxlogin","all","#fff",achtergrondkleur("div#boxlogin"),"smooth");
        }
        else if (achtergrondkleur("div#boxingelogd") != undefined) {
            Rounded("div#boxingelogd","all","#fff",achtergrondkleur("div#boxingelogd"),"smooth");
        }

        if (achtergrondkleur(".subtabboxrand") != undefined) {
            Rounded("div.subtabbox","bottom","transparent","#fff","border " + achtergrondkleur(".subtabboxrand"));
        }
        else if (achtergrondkleur(".subtabboxjurisprudentierand") != undefined) {
            Rounded("div.subtabbox","all","transparent","#fff","border " + achtergrondkleur(".subtabboxjurisprudentierand"));
        }

        if (achtergrondkleur(".accordeonrand") != undefined) {
            Rounded("div.accordeon","top","transparent",achtergrondkleur(".accordeonrand"),"border " + achtergrondkleur(".accordeonrand"));
            Rounded("div.accordeon","bottom","transparent","#fff","border " + achtergrondkleur(".accordeonrand"));
        }

        if (achtergrondkleur(".xmlcomponentrand") != undefined) {
            Rounded("div.xmlcomponent","top","transparent",achtergrondkleur(".xmlcomponentrand"),"border " + achtergrondkleur(".xmlcomponentrand"));
            Rounded("div.xmlcomponent","bottom","transparent","#fff","border " + achtergrondkleur(".xmlcomponentrand"));
            $("div.xmlcomponent").css("display","block");
            //$("div.xmlcomponent").fadeIn("slow");
        }

        if (achtergrondkleur(".controlTekstrand") != undefined) {
            Rounded("div.controlTekst","top","transparent",achtergrondkleur(".controlTekstrand"),"border " + achtergrondkleur(".controlTekstrand"));
            Rounded("div.controlTekst","bottom","transparent","#fff","border " + achtergrondkleur(".controlTekstrand"));
        }

        //Rounded("div.beslisboombox","all","transparent","#fff","border #EFEFEF");

        if (achtergrondkleur(".tocrand") != undefined) {
            Rounded("div.toc","all","transparent",achtergrondkleur(".tocrand"),"border " + achtergrondkleur(".tocrand"));
        }

        if (achtergrondkleur(".landingspaginaboxrand") != undefined) {
            Rounded("div.landingspaginabox","all","transparent",achtergrondkleur(".landingspaginaboxrand"),"border " + achtergrondkleur(".landingspaginaboxrand"));
        }

        if (achtergrondkleur(".landingspaginaboomrand") != undefined) {
            Rounded("div.landingspaginaboom","all","transparent",achtergrondkleur(".landingspaginaboomrand"),"border " + achtergrondkleur(".landingspaginaboomrand"));
        }

        if (achtergrondkleur("div#boxnotitieszoeken") != undefined) {
            Rounded("div#boxnotitieszoeken","all","#fff",achtergrondkleur("div#boxnotitieszoeken"),"border " + achtergrondkleur("div#boxnotitieszoeken"));
        }

        Rounded("div.webtekst","all","transparent","#ececec","border #e5e5e5");

        Rounded("div.relatedBox","top","transparent","#ececec","border #ececec");
        Rounded("div.relatedBox","bottom","transparent","#fff","border #ececec");

        Rounded("div.relatedContentKop","all","ffffff","#cccccc","border #ffffff");

        Rounded("div.relatedContentBox","top","transparent","#ececec","border #ececec");
        Rounded("div.relatedContentBox","bottom","transparent","#fff","border #ececec");

        Rounded("div.balkbox","top","transparent","#ececec","border #ececec");
        Rounded("div.balkbox","bottom","transparent","#fff","border #ececec");

        Rounded("div.weblogbiografie","all","#fff","#ececec","border #ececec");
        Rounded("div.weblogmenu","all","#fff","#ececec","border #ececec");
        
        if (achtergrondkleur("div.zoekformulierjurisprudentierand") != undefined) {
            Rounded("div.zoekformulierjurisprudentie","all","#fff",achtergrondkleur(".zoekformulierjurisprudentierand"),"border " + achtergrondkleur(".zoekformulierjurisprudentierand"));
        }        
        
        Rounded("div.resultatentabel","all","#fff","#ececec","border #ececec");

        Rounded("div.selectietooldiv","all","#fff","#ffffff","border #E7E3E7");
        Rounded("div.onvoldoenderechten","all","#fff","#ececec","border #ececec");

        Rounded("div.boxfiguurenkop","all","#fff","#fff","border " + achtergrondkleur(".subtabboxrand"));

	}

	function tabfunctionaliteit()
	{
		// subtabs
        $('#subtabs > ul').tabs();
        $('#subtabs').css("display","block");
        //$('#subtabs').fadeIn("slow");
	}

    //function tabHover() {
    //    var divarr = $(this).find("div").each( function() {
    //        var huidigeClass = $(this).attr("class");
    //        $(this).removeClass(huidigeClass);
    //        $(this).addClass(huidigeClass + "-hover");
    //        $(this).css("cursor","hand");
    //    } );
    //}

    //function tabOut() {
    //    var divarr = $(this).find("div").each( function() {
    //        var huidigeClass = $(this).attr("class");
    //        $(this).removeClass(huidigeClass);
    //        $(this).addClass(huidigeClass.substring(0,huidigeClass.indexOf('-hover')));
    //        $(this).css("cursor","default"); } );
    //}

    function hoverTab( li) {
        var divarr=li.getElementsByTagName('div');
        for (i=0;i<divarr.length;i++){
            divarr[i].className = divarr[i].className + '-hover';
            divarr[i].style.cursor = 'hand';
        }
    }

    function blurTab( li) {
        var divarr=li.getElementsByTagName('div');
        for (i=0;i<divarr.length;i++){
            divarr[i].className = divarr[i].className.substring(0,divarr[i].className.indexOf('-hover'));
            divarr[i].style.cursor = 'default';
        }
    }

	function zoektermFocus( invoerveld, voorbeeld)
	{
		if( invoerveld.value == voorbeeld)
		{
			invoerveld.value = '';
		}
	}

	var accordeonitemBackgroundColor = '#F1F1F1';

	function accordeonfunctionaliteit()
	{
		$(".accordeon dd").each( function() { $(this).show(); } );

        $(".submenuaccord dt").hover( accordeonitemHover, accordeonitemOut ) ;

//		$(".accordeon dd:first").show();

//		$(".accordeon dt").bind("click",
//            function() {
//                $("dd:visible").hide();
//				if($(this).next().css("display") == 'none')
//				{
//                	$(this).next().show();
//                	return false;
//				}
//				else
//				{
//                	$(this).next().hide();
//                	return false;
//				}
//            }

//		);

        $('.accordeon').css("display","block");
        //$('.accordeon').fadeIn("slow");

	}

    function accordeonitemHover() {

		// pas de achtergrondkleur aan
		accordeonitemBackgroundColor = $(this).css("background-color");
        if (achtergrondkleur(".accordeonhoveritem") != undefined) {
            $(this).css("background-color", achtergrondkleur(".accordeonhoveritem"));
        }

		var offset = $(this).offset();
		var id = $(this).find(".id:first").html();

    }

    function accordeonitemOut() {

		// zet de achtergrondkleur weer terug
        $(this).css("background-color", accordeonitemBackgroundColor);

    }

	function verbergTekstdialog()
	{
		$(".ui-tekstdialog").each( function() {
			$(this).css({display: 'none'});
		} );
	}

	function toonTekstdialog( xmlbestand)
	{

        var velden = new Array();

		// verberg evt. de openstaande tekstdialog
		verbergTekstdialog();

        var html = $.ajax({
        url: "default_mod.asp",
        data: "haalWebtekst=true&xmlbestand=" + xmlbestand,
        dataType: "html",
        async: false
        }).responseText;

        velden = html.split("$$");

		$("#tekstdialog").tekstdialog({
			width: 400,
			height: 500,
			minWidth: 150,
			minHeight: 100,
			position: 'center',
			buttons: [],
			draggable: true,
			resizable: false
		});

		$(".ui-tekstdialog-title").html(velden[0]);

		$("#tekstdialog").each( function() {
			$(this).find(".dialogtekst").html(velden[1]);
		});
	}
    
    function verbergInstantiesdialog()
	{
		$(".ui-instantiesdialog").each( function() {
			$(this).css({display: 'none'});
		} );
	}
	
    function toonInstantiesdialog()
    {

		// verberg evt. de openstaande dialog
		verbergInstantiesdialog();        		
		
		var offset = $(".instantieselecteerknop").offset();
		
		$("#instantiesdialog").instantiesdialog({
			width: 400,
			height: 500,
			minWidth: 150,
			minHeight: 100,
			position: 'center',
			buttons: [],
			draggable: true,
			resizable: false
		});
		
    }
    
    function toggleOnderliggendeInstanties( checkboxid)
    {

        $("#onderliggende" + checkboxid).show();
        var aanvinken = ($("#" + checkboxid).prev().attr('src') == imgTrue) ? true : false;        
        
        $("#" + checkboxid).parents(".instantie").find("input.instantie").each(
            function() {                               
                $(this).attr('checked',aanvinken);
                $(this).prev().attr('src',(aanvinken ? imgTrue : imgFalse));
                if(aanvinken)
                {
                    
                }
            }
        );                
    }
    
    function selecteerInstanties()
    {
        var instantie = '';
        var instanties = '';
        var weergaveInstanties = '';
        var weergaveGerechtshoven = '';
        var weergaveRechtbanken = '';
        
        $("#instantiesdialog").find("input[type=checkbox].instantie").each(
            function() {
                var isAangevinkt = ($(this).prev().attr('src') == imgTrue) ? true : false;
                if(isAangevinkt)
                {      
                    instantie = $(this).attr('value');       
                    if(!isLeeg(instanties)) {instanties += "; ";}       
                    instanties += instantie;
                    
                    if(instantie.indexOf('Gerechtshof') > -1 )
                    {
                        if(!isLeeg(weergaveGerechtshoven)) {weergaveGerechtshoven += "; ";}       
                        weergaveGerechtshoven += instantie.substring(12);
                    }
                    else if(instantie.indexOf('Rechtbank') > -1 )
                    {
                        if(!isLeeg(weergaveRechtbanken)) {weergaveRechtbanken += "; ";}       
                        weergaveRechtbanken += instantie.substring(10);
                    }
                    else
                    {
                        if(!isLeeg(weergaveGerechtshoven))
                        {
                            if(!isLeeg(weergaveInstanties)) { weergaveInstanties += '<br />'; }                            
                            weergaveInstanties += 'Gerechtshof (' + weergaveGerechtshoven + ')';
                            weergaveGerechtshoven = '';
                        }
                        if(!isLeeg(weergaveRechtbanken))
                        {
                            if(!isLeeg(weergaveInstanties)) { weergaveInstanties += '<br />'; }                            
                            weergaveInstanties += 'Rechtbank (' + weergaveRechtbanken + ')';
                            weergaveRechtbanken = '';
                        }
                        if(!isLeeg(weergaveInstanties)) { weergaveInstanties += '<br />'; }                            
                        weergaveInstanties += instantie;
                    }
                    
                }                
            }
        );
        
        if(!isLeeg(weergaveGerechtshoven))
        {
            if(!isLeeg(weergaveInstanties)) { weergaveInstanties += '<br />'; }                            
            weergaveInstanties += 'Gerechtshof (' + weergaveGerechtshoven + ')';
            weergaveGerechtshoven = '';
        }
        if(!isLeeg(weergaveRechtbanken))
        {
            if(!isLeeg(weergaveInstanties)) { weergaveInstanties += '<br />'; }                            
            weergaveInstanties += 'Rechtbank (' + weergaveRechtbanken + ')';
            weergaveRechtbanken = '';
        }
                        
        verbergInstantiesdialog();
        $(".hiddenzoekveld.instanties").attr('value',instanties);
        $(".zoekveld.instanties").attr('name','huhu');
        $(".zoekveld.instanties").hide();
        $(".geselecteerdeInstanties").html(weergaveInstanties);
        $(".geselecteerdeInstanties").show();
    }

	function togglePrintdialog()
	{
		if($(".ui-printdialog").css("display") == "block")
		{
			verbergPrintdialog();
		}
		else
		{
			toonPrintdialog();
		}
	}

	function verbergPrintdialog()
	{
		$(".ui-printdialog").each( function() {
			$(this).css({display: 'none'});
		} );
	}

	function toonPrintdialog()
	{

		// verberg evt. de openstaande printdialog
		verbergPrintdialog();

		$(".printdialog").printdialog("open");
		$(".ui-printdialog").each( function() {
			var offset = $(".printversie img").offset();
			$(this).css({display: 'block', position: 'absolute', top: offset.top + 26, left: offset.left - 2, width: 200, height: 150, overflow: 'hidden', background: 'none'});
		} );

	}

    function kopieer( id)
    {
        var tekst = $("#" + id).html();
		while (tekst.indexOf('&amp') > -1) {
			tekst = tekst.replace('&amp;','&');
		}
		window.clipboardData.setData('text', tekst);
        alert('De gegevens zijn naar het klembord gekopiëerd.');
    }

	function verbergAccordeonSubmenus()
	{
		$(".ui-submenu").each( function() {
			$(this).css({display: 'none'});
		} );
	}

    function toonAccordeonSubmenu( id, documentid)
	{

		// verberg evt. de openstaande submenus
		verbergAccordeonSubmenus();

        // controleer of de kinderen al opgehaald zijn
        if (isLeeg($("div#contentsub" + id).html()))
        {
            // ophalen items voor uitklapmenu
            var html = $.ajax({
            url: "toc_mod.asp",
            data: "haalAccordeonSubmenuitems=true&documentID=" + documentid,
            async: false
            }).responseText;

            // plaats de html met de items
            $("div#contentsub" + id).html(html);

            // voeg hover (andere achtergrondkleur) toe bij nieuwe items
            $(".submenuaccord dt").hover( accordeonitemHover, accordeonitemOut ) ;

        }
        else
        {
            // de kinderen zijn al eens opgehaald, dus alleen weergeven/verbergen
        }

		$("div#submenuaccord" + id).submenu("open");
		$(".ui-submenu").each( function() {
			if($(this).find(".id:first").html() == id)
			{
				var offset = $("td#" + id).offset();
                $(this).css({display: 'block', position: 'absolute', top: offset.top - 3, left: offset.left - 1, width: 254, height: $("div#submenuaccord" + id).height(), overflow: 'hidden', background: 'none'});
                $(this).css("height",$("div#submenuaccord" + id).height() + 10);
			}
			else
			{
				$(this).css({display: 'none'});
			}
		} );

	}

	function hoverSubTab( li) {
		var divarr=li.getElementsByTagName('div');
		for (i=0;i<divarr.length;i++){
			divarr[i].style.cursor = 'hand';
		}
	}

	function blurSubTab( li) {
		var divarr=li.getElementsByTagName('div');
		for (i=0;i<divarr.length;i++){
			divarr[i].style.cursor = 'default';
		}
	}

	function resizeFiguren() {
		var maxbreedte = 480;
		$(".figuur").each( function() {
			if ($(this).width() > maxbreedte)
			{
				$(this).width(maxbreedte);
			}
		});
	}

    function notitieEditor( textareaID) {
        if($("#" + textareaID).html() == null) {
        }
        else {
            var oFCKeditor = new FCKeditor( textareaID );
            oFCKeditor.StartupFocus = false;
            oFCKeditor.Width = "400";
            oFCKeditor.Height = "124";
            oFCKeditor.ToolbarSet = "Basic";
            oFCKeditor.BasePath = "fckeditor/";
            oFCKeditor.ReplaceTextarea();
        }
    }

    // verwijder de spatie uit de editor (moet er in IE worden geplaatst, anders krijgt de editor focus na het laden en scrollt de pagina naar de editor)
    function FCKeditor_OnComplete( editorInstance )
    {
        editorInstance.Events.AttachEvent( 'OnFocus', fckEditorFocus ) ;
    }

    function fckEditorFocus( editorInstance )
    {
        if (editorInstance.GetHTML() == '<p>&#160;</p>')
        {
            editorInstance.SetHTML('');
        }
    }

	function verwijderNotitie( notitieID) {
		if( confirm('De notitie wordt definitief verwijderd. Weet u zeker dat u de notitie wilt weggooien?') ) {
            document.location.href = 'notities_mod.asp?verwijderen=true&notitieID=' + notitieID;
		}
	}

    function bewerkNotitie( notitieID) {
        var textarea = '<div class="notitie-bewerktekst"><textarea id="notitie' + notitieID + '" rows="10" cols="60">' + $('#tebewerkennotitietekst' + notitieID).html().replace(/<BR>/g,'\n') +'</textarea>';
        var button   = '<div class="notitie-bewerknoppen"><input type="image" value="Bewaar" src="layout/img/notitie-bewaar.gif" class="bewaarKnop" /> <input type="image" value="Annuleer" src="layout/img/notitie-annuleer.gif" class="annuleerKnop" /></div></div>';
        var revert = $('#tebewerkennotitietekst' + notitieID).html();
        $('#tebewerkennotitietekst' + notitieID).after(textarea+button).remove();
        $('.bewaarKnop').click(function(){bewaarNotitie(this, false);});
        $('.annuleerKnop').click(function(){bewaarNotitie(this, revert);});
        notitieEditor('notitie' + notitieID);
	}

    function bewaarNotitie(obj, cancel) {
        var notitieID = $(obj).parents('.notitietekstcontainer').find('.notitieID').html();
        if(!cancel) {
        var oEditor = FCKeditorAPI.GetInstance('notitie' + notitieID);
        t = oEditor.GetHTML() ;
        var html = $.ajax({
        url: "notities_mod.asp",
        data: "updaten=true&notitieID=" + notitieID + "&documentXMLID=" + $('#documentID').html() + "&notitie=" + escape(t),
        async: false
        }).responseText;
        }
        else {
        var t = cancel;
        }
        if(t=='') t='(geen tekst)';
        $(obj).parent().parent().after('<div id="tebewerkennotitietekst' + notitieID + '" class="tebewerkennotitietekst">' + t.replace(/\n/g,'<br/>') + '</div>').remove();
    }

    function schemafunctionaliteit() {
        if(typeof(toonSchema) == 'function') {
            toonSchema();
        }
    }

    function toonVoetnoot(kennisbankafkorting,kruimel,melding){
        var scherm, strs;
        scherm=window.open("","voetnootscherm","toolbar=no,resizable,location=no,menubar=no,scrollbars=yes,width=400,height=300");
        if(document.getElementById(melding) != undefined)

        {
        strs  = '<html class="popup">' +
                '<head>' +
                "<title>Voetnoot</title>" +
                "<link type='text/css' rel='stylesheet' href='layout/style.css' />" +
                "<link type='text/css' rel='stylesheet' href='kennisbanken/" + kennisbankafkorting + "/layout/style.css' />" +
                "</head>" +
                "<body>" +
                "<div class='btn_close'><a href='#' onclick='window.close()'>" +
                "<img alt='Sluiten' src='layout/img/voetnoot-sluiten.gif' /></a></div>" +
                "<div class='btn_print'><a href='#' onclick='window.print()'>" +
                "<img alt='Print' src='layout/img/voetnoot-print.gif' /></a></div>" +
                "<p>" + kruimel + '</p><div id="popupcontent"><h1 class="footnotetitle"><b>Voetnoot</b></h1><p>' +
                document.getElementById(melding).innerHTML +
                "</p></div></body>"+
                "</html>";
        }
        else
        {
        strs  = '<html class="popup">' +
		                '<head>' +
		                "<title>Voetnoot</title>" +
		                "<link type='text/css' rel='stylesheet' href='layout/style.css' />" +
		                "<link type='text/css' rel='stylesheet' href='kennisbanken/" + kennisbankafkorting + "/layout/style.css' />" +
		                "</head>" +
		                "<body>" +
		                "<div class='btn_close'><a href='#' onclick='window.close()'>" +
		                "<img alt='Sluiten' src='layout/img/voetnoot-sluiten.gif' /></a></div>" +
		                "<div class='btn_print'><a href='#' onclick='window.print()'>" +
		                "<img alt='Print' src='layout/img/voetnoot-print.gif' /></a></div>" +
		                "<p>" + kruimel + '</p><div id="popupcontent"><h1 class="footnotetitle"><b>Voetnoot</b></h1><p>' +
		                melding +
		                "</p></div></body>"+
                "</html>";
        }
        scherm.document.open();
        scherm.document.write(strs);
        scherm.document.close();
        scherm.focus();
    }

/*
 * autoTab    Kan worden opgeroepen vanuit de keyUp handler van een veld als
 *            onKeyUp="autoTab( this, 2, event)"
 */
function autoTab(input,len, e) {
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].select();
        input.form[(getIndex(input)+1) % input.form.length].focus();
    }
}

function containsElement(arr, ele) {
    var found = false, index = 0;

    while(!found && index < arr.length)
    if(arr[index] == ele)
        found = true;
    else
        index++;

    return found;
}


function getIndex(input) {
    var index = -1, i = 0, found = false;

    while (i < input.form.length && index == -1)
        if (input.form[i] == input)
            index = i;
        else
            i++;
    return index;
}

function kiesDatum( dag, maand, jaar, veldnaam, beginjaar)
{
	var	scherm, url;

	url = 'selecteerDatum.asp?dag='+dag+'&maand='+maand+'&jaar='+jaar+'&veld='+veldnaam+'&beginjaar='+beginjaar;
  	scherm = window.open( url, 'kiesdatum', 'top=200,left=450,width=180,height=240,scrollbars=no');
	scherm.focus();
}

function vulDatum(elem) {

        var dag, maand, jaar

        dag = document.forms['formulier'].elements[elem+'dag'].value;
        if (dag.charAt(0) == '0') {dag = dag.charAt(1);}
        maand = document.forms['formulier'].elements[elem+'maand'].value;
        if (maand.charAt(0) == '0') {maand = maand.charAt(1);}
        jaar = document.forms['formulier'].elements[elem+'jaar'].value;

}

function vulDatumUitKalender( dag, maand, jaar, veldnaam)
{

    document.getElementById(veldnaam+'dag').value = dag;
    document.getElementById(veldnaam+'maand').value = maand;
    document.getElementById(veldnaam+'jaar').value = jaar;
	vulDatum(veldnaam);

}

/*
 * vergelijkDatum( dag1, maand1, jaar1, dag2, maand2, jaar2)
 *       Vergelijkt twee datums en returned de volgende waarden:
 *       -1  :  datum1 is kleiner dan datum2
 *       0   :  datum1 en datum2 zijn gelijk
 *       1   ;  datum1 is groter dan datum2
 */

function vergelijkDatums( dag1, maand1, jaar1, dag2, maand2, jaar2)
{
    var datum1, datum2;

    if( dag1 == dag2  &&  maand1 == maand2  &&  jaar1 == jaar2) {
        return 0;
    }

    datum1 = new Date( jaar1, maand1 - 1, dag1);
    datum2 = new Date( jaar2, maand2 - 1, dag2);

    if( datum1 < datum2) {
        return -1;
    }
    else {
        return 1;
    }
}

// TOC functies

//var cssTocOpen = "url( layout/img/tocitem-open.gif) no-repeat 2px 8px";
//var cssTocGesloten = "url( layout/img/tocitem-gesloten.gif) no-repeat 3px 8px";
//var timerID = 0;

function tocfunctionaliteit()
{
    $("dd:not(:first)").hide();
    $("dd").each( function() { $(this).css("display","none"); } );

    $(".toc dt").bind("click",
        function() {
            //$("dd:visible").hide();
            $(this).parents("dd").show();
            //$(this).parents("dd").prev().find(".pijltje").css("background",cssTocOpen);
            $(this).parents("dd").prev().find(".pijltje").html("-");
            if($(this).next().css("display") == 'none')
            {
                //$(this).find(".pijltje").css("background",cssTocOpen);
                $(this).find(".pijltje").html("-");
                $(this).next().show();
                return false;
            }
            else
            {
                //$(this).find(".pijltje").css("background",cssTocGesloten);
                $(this).find(".pijltje").html("+");
                $(this).next().hide();
                return false;
            }
        }
    );

    $(".toc dt").hover( tocitemHover, tocitemOut ) ;

    $(".relatedContent dt").hover( relatedContentitemHover, relatedContentitemOut ) ;
    $(".relatedBox dt").hover( relatedContentitemHover, relatedContentitemOut ) ;
    $(".weblogmenu dt").hover( relatedContentitemHover, relatedContentitemOut ) ;

    //$("#content").hover( verbergRolodexen, function() { return false; } ) ;

    $(".relatedContentBox .tekstcontent").css("display","none");

}

var tocitemBackgroundColor = '';
var tocitemTekstColor = '';

function selecteerHoofdtab() {

    var onderdeelID = $(".onderdeelID").html();

    $("#hoofdmenu").find("li").each( function() {
        var tabid = $(this).find(".id").html();
        $(this).removeClass("hoofdtab");
        if (tabid == onderdeelID)
        {
            $(this).addClass("hoofdtab");
            $(this).find("div").each( function() {

                var huidigeClass = $(this).attr("class");
                $(this).removeClass(huidigeClass);
                $(this).addClass(huidigeClass + "-selected");
                $(this).css("cursor","default");

            } );

        }
        else
        {
            $(this).find("div").each( function() {

                var huidigeClass = $(this).attr("class");
                if (huidigeClass.indexOf('-selected') > 0)
                {
                    $(this).removeClass(huidigeClass);
                    $(this).addClass(huidigeClass.substring(0,huidigeClass.indexOf('-selected')));
                }
                $(this).css("cursor","hand");

            } );
        }
    } );

    tabfunctionaliteit();

}

//  function verbergRolodexen()
//  {
//      $(".ui-dialog").each( function() {
//          $(this).css({display: 'none'});
//      } );
//  }

//  function toonRolodex( id, offsetTop, offsetLeft) {

//      $("div#rolodex" + id).dialog("open");
//      $(".ui-dialog").each( function() {
//          if($(this).find(".id:first").html() == id)
//          {
//              $(this).css({display: 'block', position: 'absolute', top: offsetTop, left: offsetLeft, width: 499, height: 393, overflow: 'hidden', background: 'url( layout/img/rolodex.gif) no-repeat 0px 0px'});
//          }
//          else
//          {
//              $(this).css({display: 'none'});
//          }
//      } );

//  }

//  function verbergRolodex( id) {
//      $(".ui-dialog").each( function() {
//          if($(this).find(".id:first").html() == id)
//          {
//              $(this).css({display: 'none'});
//          }
//      } );
//  }

function printDocument( id)
{

}

function tocitemHover() {

    // verberg evt. de openstaande rolodex
    //verbergRolodexen();

    // pas de tekstkleur aan
    tocitemTekstColor = $(this).find("a:first").css("color");
    if (achtergrondkleur(".tochoveritemtekst") != undefined) {
        $(this).find("a:first").each( function() { $(this).css("color", achtergrondkleur(".tochoveritemtekst")); } );
    }

    // pas de achtergrondkleur aan
    tocitemBackgroundColor = $(this).css("background-color");
    if (achtergrondkleur(".tochoveritem") != undefined) {
        $(this).css("background-color", achtergrondkleur(".tochoveritem"));
    }

//      var offset = $(this).offset();
//      var id = $(this).find(".id:first").html();

    // toon de rolodex na 2 seconden
    //timerID = setTimeout(function() {toonRolodex(id, offset.top - 135, offset.left + 310);}, 1000);

}

function tocitemOut() {

    // zet de tekstkleur weer terug
    $(this).find("a:first").each( function() { $(this).css("color", tocitemTekstColor); } );

    // zet de achtergrondkleur weer terug
    $(this).css("background-color", tocitemBackgroundColor);

    // stop de timer, anders wordt het rolodexkaartje alsnog getoond
    //clearTimeout ( timerID);
}

function relatedContentitemHover() {
    tocitemBackgroundColor = $(this).css("background-color");
    if (achtergrondkleur(".tochoveritem") != undefined) {
        $(this).css("background-color", achtergrondkleur(".tochoveritem"));
    }
}

function relatedContentitemOut() {
    $(this).css("background-color", tocitemBackgroundColor);
}

function toonKinderen(documentID) {

    var docID = documentID.replace(/\./g,'x').replace(/\:/g,'d');

    // controleer of er wel een tocitem is van het documentID
    if (document.getElementById(docID) != null)
    {
        // controleer of de kinderen al opgehaald zijn
        if (isLeeg($("dd#" + docID).html()))
        {
            var html = $.ajax({
            url: "toc_mod.asp",
            data: "haalKinderen=true&documentID=" + documentID,
            async: false
            }).responseText;

            // toon overal een pijltje van dichtgeklapt item
            //$("dd:visible").prev().find(".pijltje").css("background",cssTocGesloten);
            $("dd:visible").prev().find(".pijltje").html("-");

            // toon pijltje van opengeklapt item bij het huidige item
            //$("dd#" + docID).prev().find(".pijltje").css("background",cssTocOpen);
            $("dd#" + docID).prev().find(".pijltje").html("-");

            // plaats de html met de kinderen
            $("dd#" + docID).html(html);

            // zorg voor inspringing adhv aantal voorouders
            $("dd#" + docID).parents("dd").each(function(){$("dd#" + docID).find(".inspringen").append('&nbsp;&nbsp;&nbsp;'); })
            $("dd#" + docID).find(".inspringen").append('&nbsp;&nbsp;&nbsp;');

            // uitklapfunctionaliteit toevoegen aan de nieuwe items
            $("dd#" + docID).find("dd").each( function() { $(this).css("display","none"); } );
            $("dd#" + docID).find("dt").bind("click",
                function() {
                    //$("dd:visible").hide();
                    $(this).parents("dd").show();
                    //$(this).parents("dd").prev().find(".pijltje").css("background",cssTocOpen);
                    $(this).parents("dd").prev().find(".pijltje").html("-");
                    if($(this).next().css("display") == 'none')
                    {
                        //$(this).find(".pijltje").css("background",cssTocOpen);
                        $(this).find(".pijltje").html("-");
                        $(this).next().show();
                        return false;
                    }
                    else
                    {
                        //$(this).find(".pijltje").css("background",cssTocGesloten);
                        $(this).find(".pijltje").html("+");
                        $(this).next().hide();
                        return false;
                    }
                }
            );
            // hoverfunctionaliteit toevoegen aan de nieuwe items
            $("dd#" + docID).find("dt").hover( tocitemHover, tocitemOut ) ;

        }
        else
        {
            // de kinderen zijn al eens opgehaald, dus alleen weergeven/verbergen
        }
    }
}

function toonDocument(documentID) {

//      loading();

    // verberg eventueel de rolodex
//      verbergRolodexen();

    // haal de inhoud van het document op
//        var document = $.ajax({
//        url: "toc_mod.asp",
//        data: "haalDocument=true&documentID=" + documentID,
//        async: false
//        }).responseText;
//      $("#contentrechts").html(document);

//      selecteerHoofdtab();

    // haal de related content op
//        var relatedContent = $.ajax({
//        url: "toc_mod.asp",
//        data: "haalRelatedContent=true&documentID=" + documentID,
//        async: false
//        }).responseText;

//      $("#relatedContent").html(relatedContent);

//        Rounded("div#tocVerwijzing","top","transparent","#ececec","border #ececec");
//        Rounded("div#tocVerwijzing","bottom","transparent","#fff","border #ececec");
//        $("#tocVerwijzing dt").hover( relatedContentitemHover, relatedContentitemOut ) ;

//        Rounded("div.relatedContentBox","top","transparent","#ececec","border #ececec");
//        Rounded("div.relatedContentBox","bottom","transparent","#fff","border #ececec");
//        $(".relatedContentBox dt").hover( relatedContentitemHover, relatedContentitemOut ) ;

//      checkTOCofRelatedContent();

//      resizeFiguren();

//      loadingVoltooid();

    loading();

    // stop de timer, anders wordt het rolodexkaartje alsnog getoond
    //clearTimeout ( timerID);

    //document.location.href = 'toon.asp?ID=' + documentID;
    var url = 'toon.asp?ID=' + documentID;
    window.location = url;
}

function toonWetgevingDocument(wetverwijzingID) {

    loading();
    var url = 'toon.asp?ID=' + wetverwijzingID + '&wvw=true';
    window.location = url;
}

function toonTOC(documentID) {

    $("#relatedContent").css("display","none");
    $("#relatedContentVerwijzing").css("display","block");

    $("#toc").css("display","block");
    $("#tocVerwijzing").css("display","none");

    uitklappen( documentID);

}

function toonRelatedContent(documentID) {

    $("#toc").css("display","none");
    $("#tocVerwijzing").css("display","block");

    $("#relatedContent").css("display","block");
    $("#relatedContentVerwijzing").css("display","none");

}

function toggle( id)
{
    if($("#" + id).css("display") == 'block')
    {
        $("#" + id).css("display","none");
        $("#" + id).parent().find(".teken").html("+");
        $("#" + id).parent().find(".teken").css("padding-right","6px");;
    }
    else
    {
        $("#" + id).css("display","block");
        $("#" + id).parent().find(".teken").html("-");
        $("#" + id).parent().find(".teken").css("padding-right","8px");;
    }
}

function checkTOCofRelatedContent( documentID)
{

    if ( isLeeg($(".relatedContent").html()) )
    {
        // er is geen gerelateerde content, dus ook geen verwijzing tonen
        $("#relatedContentVerwijzing").css("display","none");
        $("#relatedContent").css("display","none");

        $("#toc").css("display","block");
        $("#tocVerwijzing").css("display","none");

        // TOC uitklappen tot op documentniveau

uitklappen( documentID);
    }
    else
    {
        // er is wel gerelateerde content, toon dat en toon een verwijzing naar de toc
        $("#relatedContentVerwijzing").css("display","none");
        $("#relatedContent").css("display","block");

        $("#toc").css("display","none");
        $("#tocVerwijzing").css("display","block");
    }
}

function uitklappen( documentID)
{
    var arrVoorouders = new Array();

    // haal de voorouders op
    var voorouders = $.ajax({
    url: "toc_mod.asp",
    data: "haalVoorouders=true&documentID=" + documentID,
    async: false
    }).responseText;

    arrVoorouders = voorouders.split(",");

    // klap alle voorouders open
    for(var i=0; i<arrVoorouders.length; i++) {
        toonKinderen(arrVoorouders[i]);
        $("#" + arrVoorouders[i].replace(/\./g,'x').replace(/\:/g,'d')).show();
    }

    var docID = documentID.replace(/\./g,'x').replace(/\:/g,'d');

    // klap het item van het meegegeven documentID open
    $("#" + docID).show();

    highlightTOCitem( documentID);
}

function highlightTOCitem( documentID) {

    var docID = documentID.replace(/\./g,'x').replace(/\:/g,'d');

    if($("#" + docID).prev().find(".document").html() != null)
    {
    	// pas de hoogte van de scrollable div aan aan de hoogte van het venster
    	if($('#toc').height() > 300) {
    		$('#toc').css("height",$(window).height()-90);
    	}

    	// scroll de inhoudsopgave naar het huidge id
    	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
    	var divOffset = $('#toc').offset().top;
		var pOffset = $("#" + docID).prev().offset().top;
		var pScroll = pOffset - divOffset;
		pScroll = pScroll-100
		document.getElementById('toc').scrollTop += pScroll;

        // als er een td met class 'document' is, betreft het een documentniveau
        if (achtergrondkleur(".tocgeselecteerditem") != undefined) {
            $("#" + docID).prev().css("background-color",achtergrondkleur(".tocgeselecteerditem"));
        }
        if (achtergrondkleur(".tocgeselecteerditemtekst") != undefined) {
            $("#" + docID).prev().find("a:first").css("color",achtergrondkleur(".tocgeselecteerditemtekst"));
        }
    }
    else
    {
        // het betreft een niveau, toon de kinderen
        toonKinderen(documentID);
    }
}

function loading() {

    //$("#loading").show();
    $("#loading").css("display","block");
}

function loadingVoltooid() {

    //$("#loading").hide();
    $("#loading").css("display","none");

}


// Werkproces functies

function newSize(width, height)
{
	if(document.all && !document.getElementById)
	{
 		document.all['flashSchema'].style.pixelWidth = width;
 		document.all['flashSchema'].style.pixelHeight = height;
	}
	else
	{
		document.getElementById('flashSchema').style.width = width + "px";
		document.getElementById('flashSchema').style.height = height + "px";
	}
}
function setImgSize(imgSrc)
{
	var newImg = new Image();
	newImg.onload = function()
	{
		newSize(this.width, this.height);
		return true;
	}
	newImg.src = imgSrc;
}

function highlight(documentTekst, zoekterm) {

  	var uitvoer = "";
  	var i = -1;
  	var lcZoekterm = zoekterm.toLowerCase();
  	var lcDocumentTekst = documentTekst.toLowerCase();
  	while (documentTekst.length > 0) {
    	i = lcDocumentTekst.indexOf(lcZoekterm, i+1);
    	if (i < 0) {
      	uitvoer += documentTekst;
      	documentTekst = "";
    	} else {
      	// alles binnen tags overslaan
      	if (documentTekst.lastIndexOf(">", i) >= documentTekst.lastIndexOf("<", i)) {
        	// alles binnen een evt <script> block overslaan
        	if (lcDocumentTekst.lastIndexOf("/script>", i) >= lcDocumentTekst.lastIndexOf("<script", i)) {
                // alles binnen entiteiten overslaan
                if (lcDocumentTekst.lastIndexOf(";", i) >= lcDocumentTekst.lastIndexOf("&", i)) {
                uitvoer += documentTekst.substring(0, i) + "<font class='highlight'>" + documentTekst.substr(i, zoekterm.length) + "</font>";
                documentTekst = documentTekst.substr(i + zoekterm.length);
                lcDocumentTekst = documentTekst.toLowerCase();
                i = -1;
                }
        	}
      	}
    	}
  }

  return uitvoer;
}

function highlightZoektermen(zoektekst)
{
	var arrZoektermen;
    if(zoektekst.toLowerCase().indexOf('"') == 0 && zoektekst.toLowerCase().substring(1,zoektekst.length).indexOf('"') == zoektekst.length - 2) {
        arrZoektermen = zoektekst.toLowerCase().substring(1,zoektekst.length - 1).split();
    }
    else if(zoektekst.toLowerCase().indexOf(' en ') > 0) {
        arrZoektermen = zoektekst.toLowerCase().split(" en ");
	}
    else if(zoektekst.toLowerCase().indexOf(' of ') > 0) {
        arrZoektermen = zoektekst.toLowerCase().split(" of ");
	}
	else {
    	arrZoektermen = zoektekst.split(" ");
	}

  /*if (!document.getElementById('contentrechts') || typeof(document.getElementById('contentrechts').innerHTML) == "undefined") {
    return false;
  }

  var documentTekst = document.getElementById('contentrechts').innerHTML;*/
  var documentTekst = $('#content .xmlcontent').html();

  for (var i = 0; i < arrZoektermen.length; i++) {
    if(arrZoektermen[i] != 'niet') {
        documentTekst = highlight(documentTekst, arrZoektermen[i]);
    }
    if(arrZoektermen[i] == 'niet') {
        i++;
    }
  }
  $('#content .xmlcontent').html(documentTekst);
  /*document.getElementById('contentrechts').innerHTML = documentTekst;*/
  return true;
}

function taxonomyChange(){
// functie voor het conditioneel zetten van taxonomy2 op basis van de waarde in taxonomy1
    if (document.formulier.taxonomy2){
        document.formulier.taxonomy2.options.length = 0;
        var temp = new Array();
        temp = document.formulier.taxonomy2array.value.split('|');
        var lijst = new Array();
        if (document.formulier.taxonomy1.selectedIndex == 0 ){
            option = new Option('','');
            document.formulier.taxonomy2.options[0] = option;
            option = new Option('-kies eerst uit ' + document.formulier.taxonomy1Name.value + '-','-kies eerst uit ' + document.formulier.taxonomy1Name.value + '-');
            document.formulier.taxonomy2.options[1] = option;
       //     lijst = document.formulier.taxonomy2array.value.replace('|',',').split(',');
        }
        else {
            lijst = temp[document.formulier.taxonomy1.selectedIndex].split(',');
        }
        option = new Option('','');
        //document.formulier.taxonomy2.options[0] = option;
        for (var i=0;i<lijst.length;i++) {
            option = new Option(lijst[i],lijst[i]);
            document.formulier.taxonomy2.options[i] = option;
        }

    }
return false;
}

// FUNCTIES BESLISBOMEN:

function boomMouseOver(element) {
    element.style.backgroundColor='#D2E8E9';
    element.style.cursor='hand';
}

function boomMouseOut(element) {
    element.style.backgroundColor='#FFFFFF';
}

function volgendeVraag(id,vorigeboomIDs) {
    var vervolgboom = document.getElementById('vervolgboom').innerText;
    var vorigeVraagId = '';
    if(trim(vervolgboom)!='') {
        vorigeVraagId = trim( document.getElementById('vorigevraagid').innerText);
    }
    if(vorigeboomIDs!='' && vervolgboom!='') {
        document.location.replace('beslisboom.asp?id=' + id + '&vorigevraagid=' + vorigeboomIDs + '&vervolgboom=' + vervolgboom);
    }
    else if(vorigeboomIDs!='') {
        document.location.replace('beslisboom.asp?id=' + id + '&vorigevraagid=' + vorigeboomIDs);
    }
    //else if (vervolgboom!='') {
    //  document.location.replace('beslisboom.asp?id=' + id + '&vorigevraagid=' + vorigeVraagId + '&vervolgboom=' + vervolgboom);
    //}
    else {
        document.location.replace('beslisboom.asp?id=' + id);
    }
}

function vraagMouseOver(element) {
    element.style.backgroundColor=achtergrondkleur(".multiplechoiceachtergrond");
    element.style.cursor='hand';
    element.style.backgroundImage='url(layout/img/Beslisbomen/groepvraag-pijl.gif)';
}

function vraagMouseOut(element) {
    element.style.backgroundColor='#FBF9FB';
    element.style.backgroundImage='none';
}

function maakVerwijzing(id) {
    // open verwijzingen in een popup met een grootte van 70% van de opener
    var width = document.body.clientWidth * 0.7;
    var height = document.body.clientHeight * 0.7;
    var popup = window.open('toon.asp?id=' + id + '','','toolbar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height);
    return false;
}

function maakBoomVerwijzing(id) {
    var vorigeVraagId = document.getElementById('vorigevraagid').innerHTML;
    var vorigeVraagIds = '';
    if(trim(vorigeVraagId)!='') {
        vorigeVraagIds = trim(vorigeVraagId) + ',' + trim(document.getElementById('id').innerHTML);
    }
    else {
        vorigeVraagIds = trim(document.getElementById('id').innerHTML);
    }
    document.location.replace('beslisboom.asp?id=' + id + '&vervolgboom=ja&vorigevraagid=' + vorigeVraagIds);
    return false;
}

function maakInterVerwijzing(id) {
    // open verwijzingen in een popup met een grootte van 70% van de opener
    var width = document.body.clientWidth * 0.7;
    var height = document.body.clientHeight * 0.7;
    var popup = window.open(id,'','toolbar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height);
    return false;
}

function boomAfsluiten( id, type) {
    document.location.replace('landingspagina.asp?id=' + id + '&type=' + type);
}

function inuitklappen(id) {
    var inOfUitTeKlappenBoom = document.getElementById("vorigevragen" + id);
    if(inOfUitTeKlappenBoom.style.display == 'block') {
        // INKLAPPEN
        inOfUitTeKlappenBoom.style.display = 'none';
        //document.getElementById("vorigevragenkop" + id).style.backgroundImage = 'url(layout/img/Beslisbomen/plus.gif)';
        document.getElementById("vorigevragenboven" + id).style.display = 'block';
        document.getElementById("vorigevragenkop" + id).style.backgroundImage = 'none';
        document.getElementById("vorigevragenkop" + id).style.paddingBottom = '0px';
        document.getElementById("vorigevragenkoponder" + id).style.marginBottom = '6px';
        document.getElementById("vorigevragenkoponder" + id).style.display = 'block';
    }
    else {
        // UITKLAPPEN
        inOfUitTeKlappenBoom.style.display = 'block';
        //document.getElementById("vorigevragenkop" + id).style.backgroundImage = 'url(layout/img/Beslisbomen/min.gif)';
        document.getElementById("vorigevragenboven" + id).style.display = 'none';
        document.getElementById("vorigevragenkop" + id).style.backgroundImage = 'none';
        document.getElementById("vorigevragenkop" + id).style.paddingBottom = '6px';
        document.getElementById("vorigevragenkoponder" + id).style.marginBottom = '0px';
        document.getElementById("vorigevragenkoponder" + id).style.display = 'none';
    }
}

function afdrukken(id, vorigeVraagId) {
    var popup = window.open('beslisboomafdrukken.asp?id=' + id + '&vorigeVraagId=' + vorigeVraagId,'bbpopup','status=no,resizable=yes');
}

// mogelijkheden:
// nieuwbouw aangevinkt en functies ook: alleen divs tonen met bouw=N
// bestaandebouw aangevinkten functies ook: alleen divs tonen met bouw=B
// beide aangevinkt en functies ook: alles tonen

// nieuwbouw aan, filter aan: alleen divs tonen met bouw=N EN mimimaal 1 filter=ja
// bestaandebouw aan, filter aan: alleen divs tonen met bouw=B EN mimimaal 1 filter=ja
// beide aan, filter aan: alleen divs tonen met filter=ja


// wat te doen:
// aanvinken filter:
// loop langs alle divs, controleer of n of b =

function checkFuncties(cbx)
{
	var naam = cbx.name;
    var arrayList2 = $(".functie");
    var arrayList4 = $(".functie table");
    var tonen = false;

    var inNieuwbouw = true;
    var inBestaandebouw = true;

    if($("#selectietoolnieuwbouw").attr("checked") != true)
    {
    	inNieuwbouw = false;
    }
    if($("#selectietoolbestaandebouw").attr("checked") != true)
    {
    	inBestaandebouw = false;
    }

    if(!inNieuwbouw && !inBestaandebouw)
    {
    	$.each(arrayList2, function(i) {
		     this.style.color = "grey";
		     arrayList4.eq(i).css('color','grey');
		    });
    }
    else
   	{
	   	// kijken of alle checkboxen gecheckt zjin:
	   	var teller = 0
	   	var arrValues = [ "woonfunctie", "bijeenkomstfunctie", "celfunctie", "gezondheidszorgfunctie", "industriefunctie", "kantoorfunctie", "logiesfunctie", "onderwijsfunctie", "sportfunctie", "winkelfunctie", "overige_gebruiksfunctie", "bouwwerk_geen_gebouw_zijnde"];
	   	var checkBoxen = $(".selectietool");
		$.each(checkBoxen, function() {
				if($(this).attr("checked") == true)
				{
					teller = teller + 1;
				}
		});
		if(teller == arrValues.length)
		{
			// alle checkboxen zijn gecheckt, toon alles mits beide geselecteerd
			$.each(arrayList2, function(i) {
				if($(this).attr("bouw") == "N")
				{
					if(inNieuwbouw){
						this.style.color = "black";
						arrayList4.eq(i).css('color','black');
					}
					else{
						this.style.color = "grey";
						arrayList4.eq(i).css('color','grey');
					}
				}
				if($(this).attr("bouw") == "B")
				{
					if(inBestaandebouw){
						this.style.color = "black";
						arrayList4.eq(i).css('color','black');
					}
					else{
						this.style.color = "grey";
						arrayList4.eq(i).css('color','grey');
					}
				}
			});
		}
		else
		{
			// niet alle checkboxen zijn gecheckt.
			var tonen = false;
			// loopen door alles div met functies
			$.each(arrayList2, function(i) {
				tonen = false;
				// loopen door alle checkboxen
				$.each(
					arrValues,
					function( intIndex, objValue ){

						if(arrayList2.eq(i).attr(objValue) == "ja")
						{
							// controleren of de bijbehorende checkbox gecheckt is.
							var arrayList3 = $(".selectietool");
							$.each(arrayList3, function() {
								if($(this).attr("name") == objValue)
								{
									if($(this).attr("checked") == true)
									{
										tonen = true;
									}
							    }
							});
					    }
					}
				);

				if($(this).attr("bouw") == "N")
				{
					if(tonen && inNieuwbouw){
						arrayList2.eq(i).css('color', 'black');

						/*arrayList4.eq(i).css('color', 'black');*/
						$(this).find('table').each(function(){
							$(this).css('color', 'black');
							});
					}
					else{
						arrayList2.eq(i).css('color', 'grey');
						/*arrayList4.eq(i).css('color', 'grey');*/
						$(this).find('table').each(function(){
							$(this).css('color', 'grey');
							});
					}
				}
				if($(this).attr("bouw") == "B")
				{
					if(tonen && inBestaandebouw){
						arrayList2.eq(i).css('color', 'black');
						/*arrayList4.eq(i).css('color', 'black');*/
						$(this).find('table').each(function(){
							$(this).css('color', 'black');
							});
					}
					else{
						arrayList2.eq(i).css('color', 'grey');
						/*arrayList4.eq(i).css('color', 'grey');*/
						$(this).find('table').each(function(){
							$(this).css('color', 'grey');
							});
					}
				}
			});
		}
	}
}

function ToonWindowScroll()
{

    var contentRechts = $("#contentrechts").height();

    $('#toc').css("height",$(window).height()-60);

	// alleen scrollen als contentrechts groter is als de window
	// en scrollen totdat de bottom bereikt is

	if($("#contentrechts").height() > $(window).height()){
	var marginheight = parseInt($("#toc").css("margin-top").replace("px", ""));
	// scroll down

        	var offset = $("#toc").offset();

		    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
		    var dsoctop=document.all? iebody.scrollTop : pageYOffset;

		    if (marginheight > -200) {
		    	dsoctop = dsoctop - 200;
		    }

		    if (dsoctop < 0) {
		    	dsoctop = 0;
		    }
		        dsoctop += "px";

				if(parseInt($("#toc").css("margin-top").replace("px", ""))+$("#toc").height() < contentRechts) {
        			$('#toc').css("margin-top",dsoctop);
        			//$('#toc').animate({
		            //marginTop: dsoctop
		        	//}, 100 );
        		}
        		else {
        			if(dsoctop.replace("px", "") < parseInt($("#toc").css("margin-top").replace("px", ""))) {
        				$('#toc').css("margin-top",dsoctop);
        				//$('#toc').animate({
			            //marginTop: dsoctop
			        	//}, 100 );
        			}
        		}



    }
}
