


	function openPolicy()
	{
		window.open('../privacy_en.htm','Mywin','left=20,top=20,width=430,height=400,toolbar=0,resizable=0, status=no, left=50, top=50, scrollbars=yes,dependent=yes');

	}

	function validate()
	{
		theform = document.register
		var daysInMonth = DaysArray(12)
		var BirthMonth;
		var BirthDay;
		var BirthYear;

		
		if(theform.name.value=="")
		{
			alert(localize["ENTER_NAME"]);
			return false;
		}

		if(theform.name.value.length < 1 || theform.name.value.length > 16)
		{
			alert(localize["NAME_CHAR_ERROR"]);
			return false;
		}

		name_val = theform.name.value;

		var valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

		for (var i=0; i<name_val.length; i++) 
		{
			if (valid.indexOf(name_val.charAt(i)) < 0) 
			{
				alert(localize["NAME_INVALID_CHARS"]);
				return false;
			}
		}
		
		if(theform.email.value=="")
		{
			alert(localize["ENTER_EMAIL_ADDRESS"]);
			return false;
		}

		


		
		if (!validEmail(theform.email.value)) 
		{
			alert(localize["INVALID_EMAIL_ADDRESS"])
			return false;
		}		

		if(theform.password.value=="")
		{
			alert(localize["INVALID_PASSWORD"]);
			return false;
		}

		if(theform.password.value.length < 4 || theform.password.value.length > 16)
		{
			alert(localize["PASSWORD_TOO_SMALL"]);
			return false;
		}
		valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		if(theform.password.value != theform.password2.value)
		{
			alert(localize["PASSWORDS_DONT_MATCH"]);
			return false;
		}
		
		pass_val = theform.password.value;

		for (var i=0; i<pass_val.length; i++) 
		{
			if (valid.indexOf(pass_val.charAt(i)) < 0) 
			{
				alert(localize["PASSWORD_INVALID_CHARS"]);
				return false;
			}
		}
		
		
		if(theform.BirthDay.selectedIndex == 0)
		{
			alert(localize["SELECT_DOB"]);
			return false;
		}
		else
		{
			BirthDay = theform.BirthDay.options[theform.BirthDay.selectedIndex].value;
		}
		if(theform.BirthMonth.selectedIndex == 0)
		{
			alert(localize["SELECT_DOB_MONTH"]);
			return false;
		}
		else
		{
			BirthMonth = theform.BirthMonth.options[theform.BirthMonth.selectedIndex].value;
		}

		if(theform.BirthYear.selectedIndex == 0)
		{
			alert(localize["SELECT_DOB_YEAR"]);
			return false;
		}
		else
		{
			BirthYear = theform.BirthYear.options[theform.BirthYear.selectedIndex].value;
		}

		
		if (BirthDay<1 || BirthDay>31 || (BirthMonth==2 && BirthDay>daysInFebruary(BirthYear)) || BirthDay > daysInMonth[BirthMonth])
		{
			alert(localize["INVALID_DOB"]);
			return false;
		}

		
		genderoption = -1
		for (i=0; i<theform.gender.length; i++) 
		{
			if (theform.gender[i].checked) 
			{
				genderoption = i
			}
		}
		if (genderoption == -1) 
		{
			alert(localize["SELECT_GENDER"]);
			return false;
		}

		connoption = -1
		for (i=0; i<theform.connection.length; i++) 
		{
			if (theform.connection[i].checked) 
			{
				connoption = i
			}
		}
		if (connoption == -1) 
		{
			alert(localize["SELECT_CONNECTION"])
			return false;
		}

		
		if (!theform.agreement.checked) 
		{
			alert(localize["CONFIRM_TERMS_AND_CONDITIONS"])
			return false;
		}
		
		//for (i = 0; i < theform.length; i++) 
		//{
		//	var tempobj = theform.elements[i];
		//	if (tempobj.type.toLowerCase() == "button" )
		//		tempobj.disabled = true;
		//}
		//theform.submit();

	}

	function validEmail(email) 
	{
		invalidChars = " /:,;"

		if (email == "") 
		{
			return false
		}
		for (i=0; i<invalidChars.length; i++) {
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) > -1) {
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			return false
		}
		if (periodPos+3 > email.length)	{
			return false
		}
		return true
	}


	function daysInFebruary (year)
	{
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}

	function DaysArray(n) 
	{
		for (var i = 1; i <= n; i++) 
		{
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
		} 
		return this
	}