function checkuser(){

var theName=$('newuserForm').newusername.value;
$('checkText').innerHTML= 'checking database...';
new Ajax.Request("checkuser.php", {
 onSuccess : function(resp){
 if (resp.responseText=='valid'){
//$('checkText').innerHTML= 'username available!';
$('checkText').innerHTML= resp.responseText;
 }
 else {
 $('checkText').innerHTML= resp.responseText;
 //$('checkText').innerHTML= 'username taken, please try another';
 }
 
 },
 onFailure : function(resp) { 
   alert("There has been an error."); 
 }, 
method: "post",
contentType: "text/html",
postBody: 'newusername='+theName

});

}

function showother(){
var otherValue=$('newuserForm').heardabout.value;
if (otherValue=='other'){
$('other').style.visibility='visible';
}
else {
$('other').style.visibility='hidden';
$('newuserForm').otherheard.value='';
}
}

function showothercountry(){
var otherValue=$('newuserForm').country.value;
if (otherValue=='other'){
$('othercountry').style.visibility='visible';
}
else {
$('othercountry').style.visibility='hidden';
$('newuserForm').othercountry.value='';
}
}

function checkForm(){
var userName=$('newuserForm').newusername.value;
if (userName.length<6 || userName.length>20){
var error=true;
var theMessage='User name must be between 6 and 20 characters';
alert(theMessage);
$('newuserForm').newusername.focus();
return false;
}



var passWord=$('newuserForm').newpassword.value;
if (passWord.length<6 || passWord.length>10){
var error=true;
var theMessage='Password must be between 6 and 10 characters';
alert(theMessage);
$('newuserForm').newpassword.focus();
return false;
}
var copyPass=$('newuserForm').repeatpassword.value;
if (copyPass!=passWord){
var error=true;
var theMessage='Passwords do not match';
alert(theMessage);
$('newuserForm').newpassword.focus();
return false;
}
var email=$('newuserForm').email.value;
if (email.length<6){
var error=true;
var theMessage='Your email address does not appear to be valid';
alert(theMessage);
$('newuserForm').email.focus();
return false;
}
var first_name=$('newuserForm').first_name.value;
if (first_name.length<1){
var error=true;
var theMessage='You have not entered your first name';
alert(theMessage);
$('newuserForm').first_name.focus();
return false;
}
var last_name=$('newuserForm').last_name.value;
if (last_name.length<1){
var error=true;
var theMessage='You have not entered your last name';
alert(theMessage);
$('newuserForm').last_name.focus();
return false;
}
var address1=$('newuserForm').address1.value;
if (address1.length<1){
var error=true;
var theMessage='You have not entered line 1 of the address';
alert(theMessage);
$('newuserForm').address1.focus();
return false;
}
var address2=$('newuserForm').address2.value;
if (address2.length<1){
var error=true;
var theMessage='You have not entered line 2 of the address';
alert(theMessage);
$('newuserForm').address2.focus();
return false;
}
var postcode=$('newuserForm').postcode.value;
if (postcode.length<1){
var error=true;
var theMessage='You have not entered a postcode';
alert(theMessage);
$('newuserForm').postcode.focus();
return false;
}
var country=$('newuserForm').country.value;
if (country.length<1){
var error=true;
var theMessage='You have not chosen a country';
alert(theMessage);
return false;
}

if(!$('newuserForm').terms[0].checked){
var error=true;
var theMessage='You must agree to our terms and conditions to continue';
alert(theMessage);
return false;
}


return true;


}

//////////////
function checkForma(){
var first_name=$('newuserForm').first_name.value;
if (first_name.length<1){
var error=true;
var theMessage='You have not entered your first name';
alert(theMessage);
$('newuserForm').first_name.focus();
return false;
}
var last_name=$('newuserForm').last_name.value;
if (last_name.length<1){
var error=true;
var theMessage='You have not entered your last name';
alert(theMessage);
$('newuserForm').last_name.focus();
return false;
}
var address1=$('newuserForm').address1.value;
if (address1.length<1){
var error=true;
var theMessage='You have not entered line 1 of the address';
alert(theMessage);
$('newuserForm').address1.focus();
return false;
}
var address2=$('newuserForm').address2.value;
if (address2.length<1){
var error=true;
var theMessage='You have not entered line 2 of the address';
alert(theMessage);
$('newuserForm').address2.focus();
return false;
}
var postcode=$('newuserForm').postcode.value;
if (postcode.length<1){
var error=true;
var theMessage='You have not entered a postcode';
alert(theMessage);
$('newuserForm').postcode.focus();
return false;
}
var country=$('newuserForm').country.value;
if (country.length<1){
var error=true;
var theMessage='You have not chosen a country';
alert(theMessage);
return false;
}
else if (country=='other'){
var othercountry=$('newuserForm').othercountry.value;
if (othercountry.length<1){
var error=true;
var theMessage='You have not chosen a country';
alert(theMessage);
return false;
}

}
return true;
}