// Subscription

function validate_email(email_address,result) {

	<!-- Result validation !-->
		if (document.mailing_list.sum.value == "") {
			alert("You must answer the question");
			return false;		
		}
		if (document.mailing_list.sum.value!=result) {
			alert("Your answer to the question is wrong!\nYou answered "+document.mailing_list.sum.value+", while the correct answer is "+result);
			return false;		
		}
		
		if (email_address=="") {
			alert("You must enter an e-mail address to join the mailing list!");
			return false;
		}

		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(email_address)) 
			return true;
		else {
			alert("You must enter a valid e-mail address!");
			return false;
		}
}



function subscribe() {
	<!-- All checks are OK, commence to subscribe page !-->
//	page_change('validate/mailing_list.php?email='+document.getElementById("email").value+'&action='+document.getElementById("action").value);
	page_change('subscribe/index_static.php?email='+document.getElementById("email").value+'&action='+document.getElementById("action").value);
	return false;
}



function enter_pressed(e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
	else 
    	return false;
//	return (keycode == 13);
	return false;
}

function evaluate_form() {
	if(	validate_email(	document.getElementById("email").value	,	document.getElementById("result_subscribe").value	) )
		subscribe();
	return false;
}
