function IsEmpty(aTextField) 
{
	if ( (aTextField.value.length==0 ) || (aTextField.value==null) ) 
		return true;
	else
		return false;
}

function isEmail ( emailField ) {
 emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
 if( !emailpat.test( emailField.value ) ) {
  return false;
 }
 return true;
}

function check_register_form()
{
	var msg="";
	if ( IsEmpty(document.register_form.username) ) 	msg += "- please fill out the user name.\n";
	if ( IsEmpty(document.register_form.email) ) 	msg += "- please fill out the email address.\n";
		else if ( !isEmail(document.register_form.email) )	msg += "- please enter a valid email address.\n";
	if ( IsEmpty(document.register_form.pass1) ) 	msg += "- please fill out the password.\n";
	if ( IsEmpty(document.register_form.pass2) ) 	msg += "- please fill out the retype password.\n";
	if ( !IsEmpty(document.register_form.pass1) && !IsEmpty(document.register_form.pass2) )
		if ( document.register_form.pass1.value != document.register_form.pass2.value )
			msg += "- password and retype password do not match.\n";
	
	if ( msg.length > 1 )
	{
		alert ( msg );
		return false;
	}
	return true;
}

function check_login_form()
{
	var msg="";
	if ( IsEmpty(document.register_form.email) ) 	msg += "- please fill out the email address.\n";
		else if ( !isEmail(document.register_form.email) )	msg += "- please enter a valid email address.\n";
	if ( IsEmpty(document.register_form.pass1) ) 	msg += "- please fill out the password.\n";
	
	if ( msg.length > 1 )
	{
		alert ( msg );
		return false;
	}
	return true;
}