function validateFeedback(cisContactForm){
	feedbackStr = "";
	checkForm(cisContactForm);
	if (feedbackStr != ""){
		feedbackStr = "Your feedback could not be accepted for the following reasons:\n" + feedbackStr
		alert(feedbackStr);
		return false;
	}else{
		return true;
		//alert("returning true");
	}
}

function checkForm(cisContactForm){

	cisContactForm.name.style.background = "white";
	cisContactForm.email.style.background = "white";
	cisContactForm.message.style.background = "white";
	

	if ((cisContactForm.name.value == "") || (cisContactForm.name.value == " ")){
		feedbackStr = feedbackStr + "Please supply your full name\n";
		cisContactForm.name.style.background = "yellow";
	}

	validateEmail(cisContactForm.email.value, cisContactForm);

	if ((cisContactForm.message.value == "") || (cisContactForm.message.value == " ")){
		feedbackStr = feedbackStr + "Please enter a message to send\n";
		cisContactForm.message.style.background = "yellow";
	}

// checks valid email address and passes this to the validate function
function validateEmail(emailaddress, whichForm){
	var theStr = new String(emailaddress)
	var index = theStr.indexOf("@")
	
	if (index > 0){
		var pindex = theStr.indexOf(".",index)
		if ((pindex > index+1) && (theStr.length > pindex+1)){
			emailGood = 1;
			//alert("Good email")
		}else{
			emailGood = 0;
			feedbackStr = feedbackStr + "You have supplied an invalid email address\n"
			cisContactForm.email.style.background = "yellow";
		}
	}else{
		feedbackStr = feedbackStr + "Please supply your email address\n"
		cisContactForm.email.style.background = "yellow";
	}
}

}
