//validation for nomination form
function validateNomination(thisForm){
	message = "";
	formOkay = true;

	with(thisForm){
		if(document.nominateForm.name.value == ""){
			message += "\n\t- your name\r";
			formOkay = false;
		}
		if(document.nominateForm.email.value == "" || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.nominateForm.email.value))){
			message += "\n\t- make sure your e-mail address is correct\r";
			formOkay = false;
		}
		if(document.nominateForm.title.value == ""){
			message += "\n\t- title of the fanfic\r";
			formOkay = false;
		}
		if(document.nominateForm.author.value == ""){
			message += "\n\t- name of the author\r";
			formOkay = false;
		}
		if(document.nominateForm.url.value == "http://"){
			message += "\n\t- the url of the fanfic\r";
			formOkay = false;
		}
		if((document.nominateForm.man.value == "-" && document.nominateForm.other_m.value == "") || (document.nominateForm.woman.value == "-" && document.nominateForm.other_f.value == "")){
			message += "\n\t- the pairing\r";
			formOkay = false;
		}
		if(document.nominateForm.maincat.value == "-"){
			message += "\n\t- the main category\r";
			formOkay = false;
		}
		
		//if the user forgot to fill in any of the items above an alertbox will pop up with an appropriate message
		if(!formOkay) {
			alert( "The form could not be submitted, because you forgot to fill in the following items: \r" + message + " \r\nPlease enter this information and try again.");
		}
		return formOkay;
	}
}

//validation for volunteer form
function validateVolunteer(thisForm){
	message = "";
	formOkay = true;

	with(thisForm){
		if(document.volunteer.name.value == ""){
			message += "\n\t- your name\r";
			formOkay = false;
		}
		if(document.volunteer.email.value == "" || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.volunteer.email.value))){
			message += "\n\t- make sure your e-mail address is correct\r";
			formOkay = false;
		}
		if(document.volunteer.lj[0].checked == false && document.volunteer.lj[1].checked == false){
			message += "\n\t- select whether you have an LJ or not\r";
			formOkay = false;
		}
		if(document.volunteer.lj[0].checked == true && document.volunteer.ljname.value == ""){
			message += "\n\t- your LJ username\r";
			formOkay = false;
		}
		if(document.volunteer.noms.checked == false && document.volunteer.banner.checked == false){
			message += "\n\t- select what you're volunteering for\r";
			formOkay = false;
		}
		if(document.volunteer.comments.value == ""){
			message += "\n\t- your motivation/experience\r";
			formOkay = false;
		}
		
		if(!formOkay) {
			alert( "The form could not be submitted, because you forgot to fill in the following items: \r" + message + " \r\nPlease enter this information and try again.");
		}
		return formOkay;
	}
}

//validation for vote form
function validateVote(thisForm){
	message = "";
	formOkay = true;
	with(thisForm){
		if(document.voteform.name.value == ""){
			message += "\n\t- your name\r";
			formOkay = false;
		}
		if(document.voteform.email.value == "" || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.voteform.email.value))){
			message += "\n\t- make sure your e-mail address is filled in and correct\r";
			formOkay = false;
		}
		if(document.voteform.second != null){
			if(document.voteform.first.selectedIndex == document.voteform.second.selectedIndex && document.voteform.first.selectedIndex != 0){
				message += "\n\t- you can not vote more than once for the same fanfic\r";
				formOkay = false;
			}
		}
		if(document.voteform.third != null){
			if((document.voteform.first.selectedIndex == document.voteform.third.selectedIndex && document.voteform.first.selectedIndex != 0) || (document.voteform.second.selectedIndex == document.voteform.third.selectedIndex && document.voteform.second.selectedIndex != 0)){
				message += "\n\t- you can not vote more than once for the same fanfic\r";
				formOkay = false;
			}
		}
		if(document.voteform.second == null && document.voteform.third == null){
			if(document.voteform.first.selectedIndex == 0){
				message += "\n\t- you haven't voted yet\r";
				formOkay = false;
			}
		}
		if(document.voteform.second != null && document.voteform.third == null){
			if(document.voteform.first.selectedIndex == 0 && document.voteform.second.selectedIndex == 0){
				message += "\n\t- you haven't voted for any fanfics\r";
				formOkay = false;
			}
		}
		if(document.voteform.third != null){
			if(document.voteform.first.selectedIndex == 0 && document.voteform.second.selectedIndex == 0 && document.voteform.third.selectedIndex == 0){
				message += "\n\t- you haven't voted for any fanfics\r";
				formOkay = false;
			}
		}
		if(!formOkay) {
			alert( "The form could not be submitted, because you forgot to fill in the following items: \r" + message + " \r\nPlease enter this information and try again.");
		}
		return formOkay;
	}
}
