function trim(s) {
	var maxlength = 5000;
	if (s.value.length > maxlength) {
		s.value = s.value.substring(0,maxlength);
	}
}
function submitform() {
	document.forms[0].submit();
}

function validateOnSubmit() {
	var errs=0;
	var doc_nom = document.forms.nominationform;
	// execute all element validations in reverse order, so focus gets
	// set to the first one in error.
	// if (!doc_nom.Enter_contest[0].checked && !doc_nom.Enter_contest[1].checked) errs += 1;
	if (doc_nom.Phone.value=="") errs += 1;
	if (doc_nom.Postal_code.value=="") errs += 1;
	if (doc_nom.Province.options[0].selected) errs += 1;
	if (doc_nom.City.value=="") errs += 1;
	if (doc_nom.Address.value=="") errs += 1;
	if (doc_nom.Nominator.value=="") errs += 1;
	if (!doc_nom.Disc_Theatre.checked && !doc_nom.Disc_Dance.checked && !doc_nom.Disc_Film.checked && !doc_nom.Disc_Broadcasting.checked && !doc_nom.Disc_ClassicalMusic_Opera.checked && !doc_nom.Disc_Popular_Music.checked) errs += 1;	
	if (doc_nom.Nominee_name.value=="") errs += 1;
	if (errs>1) alert('There are required fields which need an entry before sending');
	else if (errs==1) alert('There is a required field which needs an entry before sending');
	else if (!document.forms.nominationform.Disclaimer_agreement.checked) alert ("Please review the Declaration of Nominator. This information cannot be sent without accepting the Declaration of Nominator's terms and conditions.");
	//checks for no missing fields and accept box is checked
	if (errs==0 && document.forms.nominationform.Disclaimer_agreement.checked) {
		submitform();
	}	
};

function validateContactOnSubmit() {
	alert("send!");
	var errs=0;
	var doc_nom = document.forms.contactform;
	var len = doc_nom.Expecting_reply.length;
	var reply = "";
	// execute all element validations in reverse order, so focus gets
	// set to the first one in error.
	if (doc_nom.Message.value=="") errs += 1;
	if (doc_nom.Email.value=="") errs += 1;
	if (doc_nom.Expecting_reply.value=="") errs += 1;
	for (i = 0; i <len; i++) {
		if (doc_nom.Expecting_reply[i].checked) {
			reply = doc_nom.Expecting_reply[i].value;
		} 
	}
	if (reply=="") errs += 1;	
	if (document.forms.contactform.Contact_name.value=="") errs += 1;
	if (errs>1) alert('There are required fields which need an entry before sending');
	else if (errs==1) alert('There is a required field which needs an entry before sending');
	//checks for no missing fields and accept box is checked
	if (errs==0) {
		submitform();
	}
};

function formReset() {
	document.forms[0].reset();
}
