<!--

function checkActivate(){

	var mesg = '';
	var email = document.activate.email.value;
	var password = document.activate.password.value;
	var code = document.activate.activation.value;
	var charReg = /[^a-zA-Z0-9]/;
	
	if (!validateEmail(email)){
		mesg += "Please enter a valid email address.\n";
	}

	if(password.length < 6 || password.length > 14){
		mesg += "Your password should be between 6 and 14 characters.\n";
	}

	if(charReg.test(password)){
		mesg += "There are non-alphanumeric characters in your password.\nPlease remove them.";
	}

	if(code.length != 8){
		mesg += "Your activation code should be 8 characters.\n";
	}
	
	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}

}



function checkRegister1(){

	var mesg = '';
	var charReg = /[^a-zA-Z0-9]/;
	var firstname = document.register.firstname.value;
	var lastname = document.register.lastname.value;
	var postcode = document.register.postcode.value;
	var password = document.register.password.value;
	var email = document.register.email.value;
	var terms = document.register.terms;

	if(firstname.length == 0){
		mesg += "Please enter your firstname.\n";
	}
	if(lastname.length == 0){
		mesg += "Please enter your lastname.\n";
	}
	if(postcode.length == 0){
		mesg += "Please enter your postcode.\n";
	}

	if (!validateEmail(email)){
		mesg += "Please enter a valid email address.\n";
	}

	if(password.length == 0){
		mesg += "Please enter a password.\n";
	}else if(password.length < 6 || password.length > 14){
		mesg += "Your password should be between 6 and 14 characters.\n";
	}else if(charReg.test(password)){
		mesg += "There are non-alphanumeric characters in your password.\nPlease remove them.";
	}else{
		if(password != document.register.confirm_password.value){
			mesg += "You have not re-typed your password correctly. Please try again.\n";
		}
	}

	if(terms.checked != true){
		mesg += "You must agree to the terms of use to continue.\n";
	}

	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}
}


function checkRegister2(){

	var mesg = '';
	var charReg = /[^a-zA-Z0-9]/;
	if(document.register.company){
		var company = document.register.company.value;
		if(company.length == 0){
			mesg += "Please enter your company or trading name.\n";
		}
	}

	if(document.register.tel){
		var tel = document.register.tel.value;
		if(tel.length == 0){
			mesg += "Please enter a contact telephone number.\n";
		}
	}

	var inputs = document.getElementsByTagName("input");
	var groups = false;
	for(i=0; i<inputs.length; i++){
		if(inputs[i].type == 'checkbox'){
			if(inputs[i].checked == true){
				groups = true;
			}
		}
	}
	if(!groups){
		mesg += "Please choose at least one category.\n";
	}

	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}
}


function checkRegister3(){

	var mesg = '';
	var charReg = /[^a-zA-Z0-9]/;
	var name = document.register.name.value;
	//var size = document.register.size.value;

	if(name.length == 0){
		mesg += "Please enter a name for your garden.\n";
	}

	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}
}



function checkAccount1(){
	var mesg = '';
	var charReg = /[^a-zA-Z0-9]/;
	var firstname = document.account.firstname.value;
	var lastname = document.account.lastname.value;
	var postcode = document.account.postcode.value;
	var password = document.account.new_password.value;
	var email = document.account.email.value;

	if(firstname.length == 0){
		mesg += "Please enter your firstname.\n";
	}
	if(lastname.length == 0){
		mesg += "Please enter your lastname.\n";
	}
	if(postcode.length == 0){
		mesg += "Please enter your postcode.\n";
	}

	if (!validateEmail(email)){
		mesg += "Please enter a valid email address.\n";
	}

	if(password.length >= 1){

		if(password.length < 6 || password.length > 14){
			mesg += "Your password should be between 6 and 14 characters.\n";
		}else if(charReg.test(password)){
			mesg += "There are non-alphanumeric characters in your password.\nPlease remove them.";
		}
	}

	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}
}


function checkAccount2(){
	var mesg = '';
	var charReg = /[^a-zA-Z0-9]/;
	var address1 = document.account.address1.value;
	var company = document.account.company.value;
	var description = document.account.description.value;
	var tel = document.account.tel.value;

	if(company.length == 0){
		mesg += "Please enter your company or trading name.\n";
	}

	if(description.length == 0){
		mesg += "Please enter a brief description of your services.\n";
	}

	if(address1.length == 0){
		mesg += "Please enter at least one line of your address.\n";
	}
	if(tel.length == 0){
		mesg += "Please enter a contact telephone number.\n";
	}

	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}
}


function checkAccount3(){
	var mesg = '';
	var charReg = /[^a-zA-Z0-9]/;
	var name = document.account.name.value;

	if(name.length == 0){
		mesg += "Please enter a name for your garden.\n";
	}

	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}
}


function manageName(){
	var garden = document.getElementById("gardenid");
	if(garden.selectedIndex != 0){
		document.getElementById("new_name").value = 'Copy of ' + garden[garden.selectedIndex].text;
	}else{
		document.getElementById("new_name").value = '';
	}
}


function manageCopy(){
	if(document.getElementById("copy").checked == true){
		document.getElementById("new_name").disabled = false;
	}else{
		document.getElementById("new_name").disabled = true;
	}
}

function checkTransfer(){
	var mesg = '';
	if(document.getElementById("gardenid").selectedIndex == 0){
		mesg += "Please select a garden to send.\n";
	}
	if(document.getElementById("to_name").value == ''){
		mesg += "Please enter the recipient's name.\n";
	}
	
	if(document.getElementById("to_email").value == ''){
		mesg += "Please enter the recipient's email address.\n";
	}
	
	if(mesg){
		alert(mesg);
		return false;
	}else{
		return true;
	}	
}

function userDetails(type){
	openWin('serviceAccountDetail.php?&type=' + type, 'accountDetails', 'width=400, height=400, scrollbars, status');
}

function gardenDetails(gardenid, type){
	openWin('serviceAccountDetail.php?item=garden&gardenid=' + gardenid + '&type=' + type, 'accountDetails', 'width=400, height=400, scrollbars, status');
}

// -->