function validateLogin(){
	var root = document.registerForm;
	
	var username = root.username.value;
	var password = root.password.value;
	if (username == ''){
		alert('Please give your username.');
		root.username.focus();
		return false;
	}
	if (password == ''){
		alert('Please give your password.');
		root.password.focus();
		return false;
	}
	
	root.submit();
}

function validUpdateProfile(){
	var root = document.updateProfile;
	
	if(root.name.value==''){
		alert("Please enter your name");
		root.name.focus();
		return false;
	}
	if (root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if (root.phone.value==''){
		alert('Please enter your phone number');
		root.phone.focus();
		return false;
	}
	if (root.address.value==''){
		alert('Please enter your address address');
		root.address.focus();
		return false;
	}
	return true;
}

function validateChangePass(){
	var root=document.changePass;
	if(root.oldpass.value==''||root.newpass.value==''||root.confirmpass.value==''){
		alert('Please fill up all the fields');
		return false;
	}
	return true;
}

function validateForgotPass(){
	var root = document.forgotPass;
	if(root.username.value==''){
		alert('Please enter your username');
		root.username.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = root.email;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.focus();
		return false;
	}
	return true;
}

function validateAddMember(){
	var root = document.register;
	if (root.username.value==''){
		alert('Please enter your Username');
		root.username.focus();
		return false;
	}
	if (root.name.value==''){
		alert('Please enter your name');
		root.name.focus();
		return false;
	}
	if(root.password.value==''){
		alert('Please enter your password');
		root.password.focus();
		return false;
	}
	if(root.password.value != root.confirm.value){
		alert('Please confirm the Password');
		root.confirm.select();
		return false;
	}
	if (root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if (root.phone.value==''){
		alert('Please enter your phone');
		root.phone.focus();
		return false;
	}
	if (root.address.value==''){
		alert('Please enter your address');
		root.address.focus();
		return false;
	}
}