function submitReg(answer1,answer2,answer3,code)
{
code=code.substring(code.length-1);
var hasWorked=0;
var x=document.getElementById("registermenu")
	if(x.securityString.value.length>2){
	if(code==0){
	
if(answer1.indexOf(x.securityString.value)!=-1)

{

	
		hasWorked=1;	
}
	}
if(code==1){
if(answer2.indexOf(x.securityString.value)!=-1)
{
		
		hasWorked=1;	
}
}
if(code==2){
if(answer3.indexOf(x.securityString.value)!=-1)
{
		
		hasWorked=1;	
}
}
}

if(hasWorked==0)
	{
	alert("Please check the spelling of the security question");

	}else if(hasWorked==1){ 
		if(canSubmit())
	{
x.submit();
	}
	}
}

function canSubmit(){

	 var doSubmit=true;

var x=document.getElementById("registermenu")

if(x.lastName.value==""||x.firstName.value==""){

alert("Please enter your name");

x.firstName.focus();

doSubmit=false;

}





if(x.email.value.indexOf('@')==-1||x.email.value.indexOf('.')==-1){

alert("You have not entered a valid email address.");

x.email.focus();


doSubmit=false

}

 


if(x.tsandcs.checked==false){

alert("You must agree to our terms and conditions to register.");

x.tsandcs.focus();

doSubmit=false

}


if(x.telephone.value==""){

alert("Please enter a valid telephone number.");

x.telephone.focus();

doSubmit=false

}
 

if(x.username.value==""){

alert("Please enter a username.");

x.username.focus();

doSubmit=false

}

 

if (x.userPass.value!=x.userPassConf.value){

       alert('Please check that your password and password confirmation match.');

       x.userPass.value='';

       x.userPassConf.value='';

       x.userPass.focus();

       doSubmit=false;}

       else if (x.userPass.value.length <6)

       { alert('Please choose a password of at least six characters.');

        x.userPass.value='';

       x.userPassConf.value='';

       x.userPass.focus();

       doSubmit=false;

       }


       return doSubmit;


}
