function hideElements(test) {
	var i=0;
	while(i<test.length) {
		$(test[i]).hide();
		i++;
	}
}

function showElements(test) {
	var i=0;
	while(i<test.length) {
		$(test[i]).show();
		i++;
	}
}

//Check for address
function checkForAddress() {
	elZipcode	= $('postalcode');
	elNumber	= $('houseno');
	elStreet	= $('street');
	elCity		= $('city');
	// Have the street and city filled in by getAddress-function
	if ((elZipcode.getValue() != '') && (elNumber.getValue() != '')) {
		getAddress(elZipcode, elNumber, elStreet, elCity);
	}
}

//Fill the education_level SELECT
function setEducationLevels(educationlevelID, educationcityID) {
    if(educationcityID == '') {
        educationcityID = $('education_city').getValue();
    }
    retrieveEducationLevels(educationcityID, $('education_level'), educationlevelID);
}

//Fill the education_institute SELECT
function setEducationInstitutes(educationinstituteID, educationlevelID, educationcityID) {
    if(educationcityID == '') {
        educationcityID = $('education_city').getValue();
    }
    if(educationlevelID == '') {
        educationlevelID = $('education_level').getValue();
    }
    retrieveEducationInstitutes(educationlevelID, educationcityID, $('education_institute'), educationinstituteID);
}

//Fill the education_category SELECT
function setEducationCategories(educationcategoryID, educationinstituteID, educationlevelID, educationcityID) {
    if(educationcityID == '') {
        educationcityID = $('education_city').getValue();
    }
    if(educationlevelID == '') {
        educationlevelID = $('education_level').getValue();
    }
    if(educationinstituteID == '') {
        educationinstituteID = $('education_institute').getValue();
    }
    retrieveEducationCategories(educationinstituteID, educationlevelID, educationcityID, $('education_category'), educationcategoryID);
}

//Fill the education SELECT
function setEducations(educationID, educationcategoryID, educationinstituteID, educationlevelID, educationcityID) {
    if(educationcityID == '') {
        educationcityID = $('education_city').getValue();
    }
    if(educationlevelID == '') {
        educationlevelID = $('education_level').getValue();
    }
    if(educationinstituteID == '') {
        educationinstituteID = $('education_institute').getValue();
    }
    if(educationcategoryID == '') {
        educationcategoryID = $('education_category').getValue();
    }
    retrieveEducations(educationcategoryID, educationinstituteID, educationlevelID, educationcityID, $('education'), educationID);
}

// Verify if IT study was chosen, if so, show IT checkboxes
function testITcheckboxes(educationID) {
	if (in_array(educationID, arrayEducationsIT) && !showITstuff) {
		$('programming_knowledge_tr').show();
		$('database_knowledge_tr').show();
		$('developing_method_tr').show();
		$('software_knowledge_tr').show();
		retrieveProgrammingLanguages($('programming_knowledge'), programmingLanguageIDs);
		retrieveDatabaseLanguages($('database_knowledge'), databaseLanguageIDs);
		retrieveDevelopMethods($('developing_method'), developMethodIDs);
		retrieveVariousSoftware($('software_knowledge'), variousSoftwareIDs);
		showITstuff=true;
	}
	else if (!in_array(educationID, arrayEducationsIT) && showITstuff) {
		removeElements($('programming_knowledge'));
		removeElements($('database_knowledge'));
		removeElements($('developing_method'));
		removeElements($('software_knowledge'));
		showITstuff=false;
		$('programming_knowledge_tr').hide();
		$('database_knowledge_tr').hide();
		$('developing_method_tr').hide();
		$('software_knowledge_tr').hide();
	}
}

//Fill the region SELECT
function setCities(provinceID, cityIDs) {
    if(provinceID == '') {
        provinceID = $('province').getValue();
    }
    retrieveCityCheckboxes($('cities'),cityIDs,provinceID);
}

//Collapse or Expand a workdirectory
function toggleThis(event, workdirectionID, strImageLoc) {
	elTR = $('wd'+workdirectionID);
	elIMG= $('img'+workdirectionID);

	if(elTR.visible()) {
		elTR.hide();
		elIMG.writeAttribute({'src':strImageLoc+'/expand.gif'});
	}
	else {
		elTR.show();
		elIMG.writeAttribute({'src':strImageLoc+'/collapse.gif'});
	}
}

function countWDs(event) {
	amount = 0;
	for (i=0; i<functions.length; i++) {
		if ($('cbFunction'+functions[i]).checked==true) {
			amount+=1;
		}
	}
	if (amount==1)
		$('amountCheckedWDs').update(amount+' functie geselecteerd');
	else
		$('amountCheckedWDs').update(amount+' functies geselecteerd');
}

//Retrieve the workdirections
function getWorkDirections(workDirectionIDs, strImageLoc) {
	retrieveWorkDirections($('work_directions'), workDirectionIDs, strImageLoc);
}

//Collapse the workdirection
function collapseWorkDirections() {
	wdIDs = workdirectionIDs.slice();
	while (wdID = wdIDs.pop()) {
		if ($('wd'+wdID).visible()) {
			toggleThis(this, wdID, strImageLoc);
		}
	}
}


//#################### Mail beheer pagina's ####################\\
// Call the correct functions and show the associated DIV's
function processData(btnPress) {
    elLoadDiv    = $('loadingDiv');
    elEmailDiv   = $('emailDiv');
    elMessageDiv = $('messageDiv');
    strEmail     = $F('email');
    strType      = $F('type');
    elBtnSend    = $('btnSend');

    if (strEmail=='') {
        if(elLoadDiv.visible()) elLoadDiv.toggle();
        if(!elEmailDiv.visible()) elEmailDiv.toggle();
        if (btnPress) {
            elMessageDiv.update('Je hebt geen e-mail adres ingevuld!');
            elMessageDiv.show();
        }
    }
    else {
        if(elLoadDiv.visible()) elLoadDiv.toggle();
        if (btnPress) {
            elBtnSend.disable();
            elBtnSend.writeAttribute("value", "Afmelding wordt verstuurd.");
            disableMailing(strEmail, elEmailDiv, elMessageDiv, strType);
            setTimeout('resetButton(elBtnSend, "Opnieuw versturen...")',4000);
        }
        else {
            if(!elEmailDiv.visible()) elEmailDiv.toggle();
        }
    }
}

// Toggles the status of an graphical checkbox
function toggleCheckbox(element) {
    if (element.readAttribute('status')=='on') {
        element.writeAttribute('src','/shared_public/images/icons/off.png');
        element.writeAttribute('status','off');
    }
    else {
        element.writeAttribute('src','/shared_public/images/icons/on.png');
        element.writeAttribute('status','on');
    }
}

// Re-enables a BUTTON and modifies the text on it
function resetButton(elButton, strNewTxt) {
    elButton.writeAttribute("value", strNewTxt);
    elButton.enable();
}

//#################### Mail beheer pagina's ####################\\

