function toggleDivShow(featureID) {
	if(document.getElementById && document.getElementById(featureID)){
		var domEl = document.getElementById(featureID);
		if (domEl.className == "hideMe") {
			domEl.className = "showMe";
			document.getElementById(featureID + 'Title').className = "titleMinus";
		}else{
			domEl.className = "hideMe";
			document.getElementById(featureID + 'Title').className = "titlePlus";
		}
	}
	return false;
}

function setDivShow() {
	if(document.getElementById){
		for(i=2;i<10;i++){
			if(document.getElementById && document.getElementById('cBlock' + i)){
				document.getElementById('cBlock' + i).className = "hideMe";
				document.getElementById('cBlock' + i + 'Title').className = "titlePlus";
			}
		}
	}
}


function checkForm(thisForm){
	var hasError = 0;
	var hasError2 = 0;
	var hasError3 = 0;
	var missingFields = "";

	highlightColor = "#f58220";
	defaultColor = "#ffffff";
	thisForm = thisForm;

	var arrFields = new Array("title", "gender", "nationality", "firstname", "surname", "email", "cv");
	var arrTitles = new Array("Title", "Gender", "Nationality", "First Name", "Surname", "Email Address", "CV");

	for(i=0; i<arrFields.length; i++){
		theField = arrFields[i]
		theTitle = arrTitles[i]

		if(isNaN(thisForm[theField].length) || ! isNaN(thisForm[theField].selectedIndex)){
			if(thisForm[theField].value == ""){
				missingFields += theTitle + "\n";
				thisForm[theField].style.background = highlightColor;
				if(hasError == 0){thisForm[theField].focus()}
				hasError = 1;
			}else{
				thisForm[theField].style.background = defaultColor;
			}
		}else{
			var hasNodeSelected = 0;
			for(j=0; j<thisForm[theField].length; j++){
				if(thisForm[theField][j].checked){
					hasNodeSelected++;
				}
			}
			if(hasNodeSelected == 0){
				hasError = 1;
				missingFields += theTitle + "\n";
			}
		}
	}

	thisEmail = thisForm.email
	mail=thisEmail.value;
	atloc=(mail.indexOf("@"));
	if (atloc==-1) {
		thisEmail.style.background = highlightColor;
		thisEmail.focus();
		hasError2 = 1;
	}else if (mail.indexOf(".",atloc)==-1) {
		thisEmail.style.background = highlightColor;
		thisEmail.focus();
		hasError2 = 1;
	}else if (mail.indexOf(' ') > 0){
		thisEmail.style.background = highlightColor;
		thisEmail.focus();
		hasError3 = 1;
	}

	if(hasError == 1){
		alert('Please complete the following fields:\n' + missingFields)
		return false;
	}else if (hasError2 == 1){
		alert('Please enter a valid e-mail address.')
		return false;
	}else if (hasError3 == 1){
		alert('Please ensure that your email address does not contain spaces.')
		return false;
	}else{
		return true;
	}

}
