
window.onload = function(){ //Wait for the page to load.
	
	var advanced_button = document.getElementById("advanced_simplesearch");
	if (null != advanced_button) {
		var advanced_button_class = advanced_button.getAttribute("class");
		if (null != advanced_button_class) { // ie6 does not return this properly!!!
			var issimplesearch = (advanced_button.getAttribute("class").indexOf("invisible", 0) < 0);
			// the following if-else-statement will make sure that the correct
			// fields are shown, EVEN if the user has CSS disabled.
	    	if (issimplesearch) {
	    		hideAdvancedFields();
	    	} else {
	    		showAdvancedFields();
	    	}
		}
	}
	
	var simplesearch = document.getElementById("simplesearchbutton");
	if (null != simplesearch) { // button is not available on details screen
	    simplesearch.onclick = function() {
	    	hideAdvancedFields(); 
	    	inspectChoosenSector();
	    	return false;
	    };
	    simplesearch.href = "#searchform";
    }
    
    var advancedsearch = document.getElementById("advancedsearchbutton");
    if (null != advancedsearch) { // button is not available on details screen
	    advancedsearch.onclick = function () {
	    	showAdvancedFields(); 
	    	inspectChoosenSector();
	    	return false;
	    };
	    advancedsearch.href = "#searchform";
    }
    
    var advancedsearchlink = document.getElementById("advancedsearchlink"); // the intro tekst may also contain a search link
    if (null != advancedsearchlink) {
	    advancedsearchlink.onclick = function () {
	    	showAdvancedFields(); 
	    	inspectChoosenSector(); 
	    	return false;
	    };
	    advancedsearchlink.href = "#";
    }
    
    var fontSizeContainer = document.getElementById("font_size_container");
    if (null != fontSizeContainer) {
    	var li = document.createElement("li");
    	li.setAttribute("class", "font_size");
    	li.setAttribute("id", "font_size");
    	li.innerHTML = "Tekstgrootte " + 
					 '<a id="decrease_font_size" href="#" onclick="javascript:decreaseFontSize();return false;" title="Tekst kleiner maken" class="minus imgreplacement">&minus;</a> ' +  
					 '<a id="increase_font_size" href="#" onclick="javascript:increaseFontSize();return false;" title="Tekst groter maken" class="plus imgreplacement">+</a>';
    	fontSizeContainer.appendChild(li);
    }

    
    // toezichtkaart.jsp:
    var reftoelichtingbasistoezicht = document.getElementById("reftoelichtingbasistoezichtcontainer");
    if (null != reftoelichtingbasistoezicht) {
    	reftoelichtingbasistoezicht.innerHTML = '<a id="extrareftoelichtingbasistoezicht" '+ 
    	'href="#" onclick="javascript:toggleToelichtingBasistoezicht(); return false;" '+
    	'title="Toelichting Basistoezicht">Toelichting Basistoezicht</a>';
    }
    
    var refextratoelichtingbasistoezicht = document.getElementById("extrareftoelichtingbasistoezichtcontainer");
    if (null != refextratoelichtingbasistoezicht) {
    	refextratoelichtingbasistoezicht.innerHTML = '(<a id="extrareftoelichtingbasistoezicht" '+ 
    	'href="#" onclick="javascript:toggleToelichtingBasistoezicht(); return false;" '+
    	'title="Toelichting Basistoezicht">Toelichting Basistoezicht</a>)';
    }

    var toelichtingbasis = document.getElementById("toelichtingbasistoezicht");
    if (null != toelichtingbasis) {
    	toelichtingbasis.style.display = "none";
    }
};
