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('Il y a des champs exigés qui ont besoin d\'une entrée avant l\'envoi.');
	else if (errs==1) alert('Il y a un champs exigé qui a besoin d\'une entrée avant l\'envoi.');
	else if (!document.forms.nominationform.Disclaimer_agreement.checked) alert ("Veuillez passer en revue la Déclaration du proposant. Cette information ne peut pas être envoyée sans accepter les conditions de la Déclaration du proposant.");
	//checks for no missing fields and accept box is checked
	if (errs==0 && document.forms.nominationform.Disclaimer_agreement.checked) {
		submitform();
	}	
};

function validateContactOnSubmit() {
	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('Il y a des champs exigés qui ont besoin d\'une entrée avant l\'envoi');
	else if (errs==1) alert('Il y a un champs exigé qui a besoin d\'une entrée avant l\'envoi.');
	//checks for no missing fields and accept box is checked
	if (errs==0) {
		submitform();
	}
};

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

