secondShowing = false;
function occupationChanged(selectbox) {
	selectedOption = selectbox[selectbox.selectedIndex].value
	if (selectedOption == "Assistentti") {
		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("Assistentti");
		selectedOption = secondSelectBox[secondSelectBox.selectedIndex].value
			if (selectedOption != "") {
				//alert("");
				return true;
				} else {
				alert("Valitse toimiala");
				return false;
				}
			} else {
		return true;
	}
}

function isEmail(str) {
	return ((str != "") && (str.indexOf("@") != -1) && (str.indexOf(".") != -1));
}


function validateNewsletters(form) {
	if(document.register.FirstName.value.length < 1) {
		alert("Kirjoita etunimesi");
		document.register.FirstName.focus()
		return false;
	}
	if(document.register.Surname.value.length < 1) {
		alert("Kirjoita sukunimesi");
		document.register.Surname.focus()
		return false;
	}
	if( !isEmail(document.register.Email.value) ) {
		alert("Anna toimiva sähköpostiosoite");
		document.register.Email.focus()
		return false;
	}
//	if(!document.register.ReceiveEmails.checked) {
//  	alert("Ole hyvä ja merkitse, että haluat saada postia 3M:ltä.");
//  	document.register.ReceiveEmails.focus()
//		return false;
//	}
	if(!document.register.AgreeWithPrivacy.checked) {
  	alert("Lue ja hyväksy käyttöehtomme.");
  	document.register.AgreeWithPrivacy.focus()
		return false;
	}

}
