
function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}

function out_URL(str){

	return (str.indexOf("://")>0);

}

function urlencode(str) {
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}


function check_un(str){

	if(confirm("Do you really want to unsubscribe from the RAA newsletter")){
sub=document.getElementById("sub");
sub.unsub.value=1;
check_sub(str);
	}
}



function check_sub(str){
sub=document.getElementById("sub");

if(!isValidEmail(""+sub.email.value)){alert("please check you have entered your email address correctly");
	sub.email.focus()}

	else if(out_URL(sub.name.value)){
alert("please do not insert URLs in form");
		sub.name.focus()

	}

		else if(out_URL(sub.plots.value)){
alert("please do not insert URLs in form");
		sub.plots.focus()

	}

	else if(sub.name.value.length<4){
alert("please give your name");
		sub.name.focus()

	}


	else{

		sub.action="handle_sub.php"+str+"name="+urlencode(sub.name.value)+"&email="+urlencode(sub.email.value)+"&plots="+urlencode(sub.plots.value)+"&raa="+sub.raa.checked+"&unsub="+sub.unsub.value;

sub.submit();


}}
