
function check_email ()
{
	var email = document.forms['form1'].email.value;
	var length = email.length;
	var result = true;
	var at_first_position = email.indexOf("@") + 1;
	var at_last_position = email.lastIndexOf("@") + 1;
	var dot_first_position = email.indexOf(".") + 1;
	var dot_last_position = email.lastIndexOf(".") + 1;
	if ((at_first_position == at_last_position)					/* Only one "@" */
			&& (at_first_position != 1)							/* "@" is not the first character */
			&& (dot_first_position != 1)						/* "." is not the first character  */
			&& (dot_last_position < length)						/* "." is not the last character  */
			&& ((at_first_position - dot_first_position) != 1)
					/* If there is a "." before the "@", there is an other character between both*/
			&& ((at_first_position + 1) < dot_last_position)
					/* There is a "." after the "@" and a charcater between both*/
			&& (length >= 7))									/*The email adress is 7 char. long or more*/
	{
		/*alert("Your email is correct.");*/
	}
	else
	{
		
		text = (text + "Please enter a real mail adress. \n" );
		correct = "Error";
		return false;
	}
}

function check_password ()
{
	var pass1 = document.forms['form1'].password_1.value;
	var pass2 = document.forms['form1'].password_2.value;
	var length_pass1 = pass1.length;
	if (length_pass1 < 6)
	{
		text = (text + "Your password must be at least 6 characters long. \n" );
		correct = "Error";
		return false;
	}
	for (i=0; i<length_pass1 ; i++ )
	{
		if (pass1.charAt(i) != pass2.charAt(i))
		{
			text = (text + "Please re enter your password. \n" );
			correct = "Error";
			return false;
			i = length_pass1;
		}
		else
		{
			/*alert("Right password.");*/
			i = length_pass1;
		}
	}

}

function check_filled (id)
{
	/*var element_value = document.forms['form1'].element.value;
	alert("AAAAAAA15/06/2007");
	var element_length = element_value.length;
	alert("Re");*/
	var element = document.getElementById(id);
	if (element.value != "")
	{
		null;
	}
	else
	{
		text = (text + "Please fill in the following element: " + id + ". \n" );
		correct = "Error";
		return false;
	}
}

	var text = "";
	var correct = "Correct";

function check_submit ()
{
	check_filled("name");
	check_filled("email");
	check_filled("postcode");
	check_filled("name-of-child");
	check_filled("password_1");
	check_filled("password_2");
	check_email();
	check_password ();
	if (correct == "Correct")
	{
		return true;
	}
	else
	{
		alert(text);
		text = "";
		correct = "Correct";
		return false;
	}
}


function change_background(id)
{
	document.getElementById(id).style.background="#C0EAA6";
}

function reset_background(id)
{
	document.getElementById(id).style.background="#FBFAE9";
}

function over_submit(id)
{
	document.getElementById(id).style.border="2px inset";
}

function out_submit(id)
{
	document.getElementById(id).style.border="2px outset";
}