function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    //alert("Invalid E-mail ID")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 return true					
}

function LeapYear(year)
{
	if (year % 4 == 0)
	{
		if (year % 100 == 0)
		{
			if (year % 1000 == 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return true;	
		}
	}
}

function LoadDaysCI()
{
	var iyear;
	iyear = document.rf.ciyear.value;

	document.rf.ciday.length = 0;
	
	if ((document.rf.cimonth.selectedIndex == 0) || (document.rf.cimonth.selectedIndex == 2) || (document.rf.cimonth.selectedIndex == 4) || (document.rf.cimonth.selectedIndex == 6) || (document.rf.cimonth.selectedIndex == 7) || (document.rf.cimonth.selectedIndex == 9) || (document.rf.cimonth.selectedIndex == 11)) //jan mar may jul aug oct dec
	{
		document.rf.ciday.length = 31;
		
		for (var i = 1; i < 32; i++)
		{
			if (i < 10)
			{
				document.rf.ciday.options[i-1] = new Option(i.toString(), '0' + i.toString());
			}
			else
			{
				document.rf.ciday.options[i-1] = new Option(i.toString(), i.toString());
			}
		}
	}
	
	if (document.rf.cimonth.selectedIndex == 1)  //feb
	{		
		if (LeapYear(iyear))
		{
			document.rf.ciday.length = 29;
			
			for (var i = 1; i < 30; i++)
			{
				if (i < 10)
				{
					document.rf.ciday.options[i-1] = new Option(i.toString(), '0' + i.toString());
				}
				else
				{
					document.rf.ciday.options[i-1] = new Option(i.toString(), i.toString());
				}
			}			
		}
		else
		{
			for (var i = 1; i < 29; i++)
			{
				if (i < 10)
				{
					document.rf.ciday.options[i-1] = new Option(i.toString(), '0' + i.toString());
				}
				else
				{
					document.rf.ciday.options[i-1] = new Option(i.toString(), i.toString());
				}
			}
		}//*/
	}
	
	if ((document.rf.cimonth.selectedIndex == 3) || (document.rf.cimonth.selectedIndex == 5) || (document.rf.cimonth.selectedIndex == 8) || (document.rf.cimonth.selectedIndex == 10)) //apr jun sep nov
	{
		document.rf.ciday.length = 30;
		
		for (var i = 1; i < 31; i++)
		{
			if (i < 10)
			{
				document.rf.ciday.options[i-1] = new Option(i.toString(), '0' + i.toString());
			}
			else
			{
				document.rf.ciday.options[i-1] = new Option(i.toString(), i.toString());
			}
		}
	}
	
	document.rf.ciday.disabled = false;
}

function LoadDaysCO()
{
	var iyear;
	iyear = document.rf.coyear.value;

	document.rf.coday.length = 0;
	
	if ((document.rf.comonth.selectedIndex == 0) || (document.rf.comonth.selectedIndex == 2) || (document.rf.comonth.selectedIndex == 4) || (document.rf.comonth.selectedIndex == 6) || (document.rf.comonth.selectedIndex == 7) || (document.rf.comonth.selectedIndex == 9) || (document.rf.comonth.selectedIndex == 11)) //jan mar may jul aug oct dec
	{
		document.rf.coday.length = 31;
		
		for (var i = 1; i < 32; i++)
		{
			if (i < 10)
			{
				document.rf.coday.options[i-1] = new Option(i.toString(), '0' + i.toString());
			}
			else
			{
				document.rf.coday.options[i-1] = new Option(i.toString(), i.toString());
			}
		}
	}
	
	if (document.rf.comonth.selectedIndex == 1)  //feb
	{		
		if (LeapYear(iyear))
		{
			document.rf.coday.length = 29;
			
			for (var i = 1; i < 30; i++)
			{
				if (i < 10)
				{
					document.rf.coday.options[i-1] = new Option(i.toString(), '0' + i.toString());
				}
				else
				{
					document.rf.coday.options[i-1] = new Option(i.toString(), i.toString());
				}
			}			
		}
		else
		{
			for (var i = 1; i < 29; i++)
			{
				if (i < 10)
				{
					document.rf.coday.options[i-1] = new Option(i.toString(), '0' + i.toString());
				}
				else
				{
					document.rf.coday.options[i-1] = new Option(i.toString(), i.toString());
				}
			}
		}//*/
	}
	
	if ((document.rf.comonth.selectedIndex == 3) || (document.rf.comonth.selectedIndex == 5) || (document.rf.comonth.selectedIndex == 8) || (document.rf.comonth.selectedIndex == 10)) //apr jun sep nov
	{
		document.rf.coday.length = 30;
		
		for (var i = 1; i < 31; i++)
		{
			if (i < 10)
			{
				document.rf.coday.options[i-1] = new Option(i.toString(), '0' + i.toString());
			}
			else
			{
				document.rf.coday.options[i-1] = new Option(i.toString(), i.toString());
			}
		}
	}
	
	document.rf.coday.disabled = false;
}

function DoCheck()
{
	
	
	if (document.rf.name.value.length == 0)
	{
		alert('Please enter your name.');
		document.rf.name.focus();
	}
	else if (document.rf.surname.value.length == 0)
	{
		alert('Please enter your Family Name.');
		document.rf.surname.focus();
	}
	else if (document.rf.email.value.length == 0)
	{
		alert('Please enter a email address.');
		document.rf.email.focus();		
	}
	else if (!echeck(document.rf.email.value))
	{
		alert('Please enter a VALID email address.');
		document.rf.email.focus();
	}
	else if (document.rf.pwd.value.length < 6)
	{
		alert('Please enter a password of at least 6 characters.');
		document.rf.pwd.focus();
	}	
	else if (document.rf.pwd.value != document.rf.retypepwd.value)
	{
		alert('The passwords do not match');
		document.rf.pwd.focus();
	}
	else
	{
		document.rf.submit();
	}
}