secondShowing = false;
function occupationChanged(selectbox) {
	selectedOption = selectbox[selectbox.selectedIndex].value
	if (selectedOption == "OfficeManagerSecretarial") {
		showSelect();
		} else {
		hideSelect();
	}
}

function showSelect() {
	selectBoxDiv = document.getElementById("secondselect");
	selectBoxDiv.style.display = "block";
	secondShowing = true;
}

function hideSelect() {
	selectBoxDiv = document.getElementById("secondselect");
	selectBoxDiv.style.display = "none";
	secondShowing = false;
}

function checkSecond() {
	if (secondShowing == true) {
		secondSelectBox = document.getElementById("OfficeMgrSecretarial");
		selectedOption = secondSelectBox[secondSelectBox.selectedIndex].value
			if (selectedOption != "") {
				//alert("");
				return true;
				} else {
				alert("Please select your industry type");
				return false;
				}
			} else {
		return true;
	}
}

function isEmail(str) {
	return ((str != "") && (str.indexOf("@") != -1) && (str.indexOf(".") != -1));
}


function validateForm(form) {
	if(document.register.FirstName.value.length < 1) {
		alert("Please enter your first name");
		document.register.FirstName.focus()
		return false;
	}
	if(document.register.Surname.value.length < 1) {
		alert("Please enter your surname");
		document.register.Surname.focus()
		return false;
	}
	if( !isEmail(document.register.Email.value) ) {
		alert("Please enter a valid email address");
		document.register.Email.focus()
		return false;
	}
	if(!document.register.ReceiveEmails.checked) {
  	alert("Please agree to receive news and updates from 3M");
  	document.register.ReceiveEmails.focus()
		return false;
	}
	if(!document.register.AgreeWithPrivacy.checked) {
  	alert("Please read and accept our privacy policy");
  	document.register.AgreeWithPrivacy.focus()
		return false;
	}

}