
function checkPasswords () {
	valid = true;
	if (document.getElementById('db_password').value != document.getElementById('password2').value) {
		document.getElementById('password_warn').style.display = 'block';
		valid = false;
	}
	else
		document.getElementById('password_warn').style.display = 'none';
	return valid;
}

function checkEmail() {
	valid = true;

	var str=document.getElementById('db_email').value;
	var illegalChars =/^.+@.+\..{2,3}$/;
	if (!illegalChars.test(str)) {
		document.getElementById('email_warn').style.display = 'block';
		valid = false;
	} else
		document.getElementById('email_warn').style.display = 'none';
	
	return valid;
}

function checkUsernameSyntax() {
	valid = true;

	var str=document.getElementById('db_username').value;
	var filter=/([A-Za-z0-9_])$/i;
	var illegalChars= /[\(\)\<\>\@\*\$\#\%\^\(\)\!\&\ \,\;\:\\\/\"\[\]]/
	
	if (!filter.test(str) || str.match(illegalChars)) {
		document.getElementById('username_syntax_warn').style.display = 'block';
		valid = false;
	} else
		document.getElementById('username_syntax_warn').style.display = 'none';
	
	return valid;
}

function checkRegistration () {
	valid = false;
	
	if (checkPasswords() == true && 
		checkEmail() == true && 
		checkUsernameSyntax() == true && 
		document.getElementById('username_warn').style.display == 'none')
		valid = true;
	
	return valid;
}