function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}
	return true;
}

function checkBoxes(){
	var mailelembox = document.getElementById("checkmail");
	var newselembox = document.getElementById("checknews");
	
	if(mailelembox.checked == true){
			for(var i=1; i<4; i++){
				var testelem = document.getElementById("req" + i);
				var elemname = testelem.getAttribute('name');
				// alert(i + ': ' + elemname + '\n\n' + testelem.value);
				if (!isEmpty(testelem, ('Oops, you forgot to fill in ' + elemname))) return false;
			}
	}
	if(newselembox.checked == true){
		for(var i=1; i<9; i++){
			var testelem = document.getElementById("req" + i);
			var elemname = testelem.getAttribute('name');
			
			if (!isEmpty(testelem, ('Oops, you forgot to fill in ' + elemname))) return false;
		}
	}
	
	if((mailelembox.checked == false) && (newselembox.checked == false)){
		alert("Please select a checkbox option as to which updates you would like to recieve!");
		return false;
	}
	return true;
}



