function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

function isChecked(butts) {
    for(i=0; i<butts.length; i++) if(butts[i].checked) return true;
    return false;
} 

function check_form(theform) {
	if(theform.returnedproduct.value=='') {
		alert('Please tell us which product you\'re recycling');
		theform.returnedproduct.style.backgroundColor='yellow';
		theform.returnedproduct.focus();
		return false;
	} else {
	if(!isChecked(theform.p)) {
		alert('Please choose the product you would like');
		theform.p[0].focus();
		return false;
	} else {
		if(theform.firstname.value=='') {
			alert('Please enter your first name');
			theform.firstname.style.backgroundColor='yellow';
			theform.firstname.focus();
			return false;
		} else {
			if(theform.lastname.value=='') {
				alert('Please enter your last name');
				theform.lastname.style.backgroundColor='yellow';
				theform.lastname.focus();
				return false;
			} else {
				if(!check_email(theform.emailaddress.value)) {
					alert('Please enter a valid e-mail address');
					theform.emailaddress.style.backgroundColor='yellow';
					theform.emailaddress.focus();
					return false;
				} else {
					if(!isChecked(theform.paytype)) {
						alert('Please choose your payment method');
						theform.paytype[0].focus();
						return false;
					} else {
						return true;
					}
				}
			}
		}
	}
}
}