function DisplayRegErrorNote( name )
{
	switch( name )
	{
		case "reg_email":
			alert( "You haven't specified e-mail for your account.\nPlease type it in the proper field." );
			return;
		case "reg_password":
			alert( "You haven't specified password for your account.\nPlease type it in the proper field." );
			return;
		case "reg_repassword":
			alert( "You haven't confirmed password for your account.\nPlease type it in the proper field." );
			return;
		case "reg_name":
			alert( "You haven't specified your name.\nPlease type it in the proper field." );
			return;
		case "reg_sname":
			alert( "You haven't specified your last name.\nPlease type it in the proper field." );
			return;
		case "reg_birthday":
			alert( "You haven't specified your birthday.\nPlease type it in the proper field." );
			return;
		case "reg_code":
			alert( "You haven't specified registration code.\nPlease type it in the proper field." );
			return;
		default:
			alert( "Unexpected" );
			return;
	}
}

function VerifyAllFields( event )
{
	form=document.getElementById( 'id_regform' );
	for( i=0; i<form.elements.length; i++ )
	{
		if( ( form.elements[i].type=="text" || form.elements[i].type=="password" ) && form.elements[i].value.length < 1 )
		{
			DisplayRegErrorNote( form.elements[i].name );
			if (!event)
			{
				var event = window.event;
				if(event && event.returnValue)
				    event.returnValue = false;
			}

			if (event && event.cancelBubble)
			     event.cancelBubble = true;

			if( event && event.stopPropagation )
			{
				event.stopPropagation();
			}
			return false;
		}
	}
	var note = "!";

	var in_email = document.getElementById( "rid_email" );
	if( !in_email.disabled )
	{
		reg = new RegExp( "[0-9a-zA-Z-._]+@[0-9a-zA-Z-._]+\.[0-9a-zA-Z]{2,4}", "g" );
		ar = reg.exec( in_email.value );
		if( !ar )
		{
			note = "The e-mail You have specified doesn't seem to be a valid e-mail.\r\nPlease check out if You have typed it correctly.";
		}
	}

	in_email.disabled = false;

	reg = new RegExp( "[0-9]{4}", "g" );
	ar = reg.exec( form.reg_code.value );
	if( !ar )
	{
		note = "The digital registration code you have specified is in unappreciable format.\nPlease type it attentively again in the proper field.";
	}

	if( form.reg_password.value.length < 3 )
	{
		note = "In order to increase security for your account, your password should contain at least 3 characters.\r\nPlease type another password in the proper field.";
	}

	if( form.reg_password.value != form.reg_repassword.value )
	{
		note = "Your password confirmation doesn't match your password.\nPlease make sure you've typed it correctly.";
	}
	if( note.length < 2 )
		return true;

	alert( note );
	if (!event)
	{
		var event = window.event;
		if (event && event.returnValue )
		   event.returnValue = false;
	}

	if (event && event.cancelBubble )
	   event.cancelBubble = true;

	if( event && event.stopPropagation )
	{
		event.stopPropagation();
	}
	return false;
}
