// Home JavaScript Document

$(document).ready(function() {
	$(".benefits").click(function() {
			$("#benefits").toggle(); // First click should toggle to 'show'
	});
});

function isReady(form) {
	if (isFilled(form.Issue) === false) {
		alert("Please enter the issue that you would like BATA to ask the politicians.");
		form.Issue.focus();
		return false;
	}
	if (isFilled(form.Name) === false) {
		alert("Please enter your name and try again.");
		form.Name.focus();
		return false;
	}
	if (isFilled(form.Email) === false) {
		alert("Please enter your email address and try again.");
		form.Email.focus();
		return false;
	}
	if (isFilled(form.Email) === true) {
		if (isEmail(form.Email) === false) {
			alert("Your Email address appears to be incorrect. \n\Please check it and try again.");
			form.Email.focus();
			return false;
		}
	}
}

// check for null and for empty
function isFilled(elm) {
	if (elm.value === "" || elm.value === null) {
		return false;
	}
	else {
		return true;
	}
}

// check for Email addy: looking for [@] & [.]
function isEmail(elm) {
	if (elm.value.indexOf("@") != "-1" && elm.value.indexOf(".") != "-1" && elm.value != " ") {
		return true;
	}
	else {
		return false;
	}
}