
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else 
		countfield.value = maxlimit - field.value.length;
	}

function checkreg_2010_05_13() {
	var HowManyErrors = 0;
	errorColor = '#ffff99';
	normalColor = '#ffffff';
	document.getElementById('ErrorMessages').style.background = normalColor;
	document.getElementById('ErrorMessages').innerHTML = "";
	
	if (document.RegForm.SALUTATION.value=="") { 
			 document.RegForm.SALUTATION.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.SALUTATION.style.background = normalColor; }
	if (document.RegForm.FIRST_NAME.value=="") {
			 document.RegForm.FIRST_NAME.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.FIRST_NAME.style.background = normalColor; }
	if (document.RegForm.LAST_NAME.value=="") {
			 document.RegForm.LAST_NAME.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.LAST_NAME.style.background = normalColor; }
	if (document.RegForm.INSTITUTION.value=="") {
			 document.RegForm.INSTITUTION.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.INSTITUTION.style.background = normalColor; }
	if (document.RegForm.DEPARTMENT.value=="") {
			 document.RegForm.DEPARTMENT.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.DEPARTMENT.style.background = normalColor; }
	if (document.RegForm.PROJECT_TITLE.value=="") {
			 document.RegForm.PROJECT_TITLE.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.PROJECT_TITLE.style.background = normalColor; }
	if (document.RegForm.FUNDER.value=="") {
			 document.RegForm.FUNDER.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.FUNDER.style.background = normalColor; }
	if (document.RegForm.PROJECT_ROLE.value=="") {
			 document.RegForm.PROJECT_ROLE.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.PROJECT_ROLE.style.background = normalColor; }
	if (document.RegForm.MAILING_ADDRESS.value=="") {
			 document.RegForm.MAILING_ADDRESS.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.MAILING_ADDRESS.style.background = normalColor; }
	if (document.RegForm.CITY.value=="") {
			 document.RegForm.CITY.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.CITY.style.background = normalColor; }
	if (document.RegForm.PROVINCE.value=="") {
			 document.RegForm.PROVINCE.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.PROVINCE.style.background = normalColor; }
	if (document.RegForm.POSTAL_CODE.value=="") {
			 document.RegForm.POSTAL_CODE.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.POSTAL_CODE.style.background = normalColor; }
	if (document.RegForm.WORK_TELEPHONE.value=="") {
			 document.RegForm.WORK_TELEPHONE.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.WORK_TELEPHONE.style.background = normalColor; }
	if (document.RegForm.EMAIL.value=="") {
			 document.RegForm.EMAIL.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.EMAIL.style.background = normalColor; }
	if (document.RegForm.EMAIL2.value=="") {
			 document.RegForm.EMAIL2.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.EMAIL2.style.background = normalColor; }
	// check that both emails match
	if (document.RegForm.EMAIL.value!=document.RegForm.EMAIL2.value) {
			 document.RegForm.EMAIL.style.background = errorColor;
			 document.RegForm.EMAIL2.style.background = errorColor;
			 HowManyErrors++;
	}	
	if (document.RegForm.WORKSHOP_ATTEND.value=="") {
			 document.RegForm.WORKSHOP_ATTEND.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.WORKSHOP_ATTEND.style.background = normalColor; }
	if (document.RegForm.WORKSHOP2_ATTEND.value=="") {
			 document.RegForm.WORKSHOP2_ATTEND.style.background = errorColor; HowManyErrors++;
	} else { document.RegForm.WORKSHOP2_ATTEND.style.background = normalColor; }
	//if (document.RegForm.REGISTRATION_TYPE.value=="") {
		//	 document.RegForm.REGISTRATION_TYPE.style.background = errorColor; HowManyErrors++;
	//} else { document.RegForm.REGISTRATION_TYPE.style.background = normalColor; }
	
	if(HowManyErrors != 0) {
		messageList = "Please complete the form.";
		document.getElementById('ErrorMessages').style.background = errorColor;
		document.getElementById('ErrorMessages').innerHTML = messageList;
		return false;
	} else {
		startupload();
		return true;
	}
	
}