// JavaScript Document

function Window_Status()
{
	window.status ="Faida Girls Center. Website designed and maintained by: Websights. E-mail: websights2006@yahoo.com"; 
}

function ValidateForm(f)
{
	//check if mandatory fields are empty
	if(f.DName.value=="")
	{
	alert("Please fill in daughter's name!");
	f.DName.focus();	
	return false;
	}
	if(f.Dage.value=="")
	{
	alert("Please fill in daughter's age!");
	f.Dage.focus();	
	return false;
	}
	else
	{
		if(f.Dage.value<"15")
		{
			alert("Sorry retreats are only available to those aged 15 and over!");
			f.Dage.focus();	
			return false;
		}
	}
	if(f.PName.value=="")
	{
	alert("Please fill in parent's name!");
	f.PName.focus();	
	return false;
	}
	if(f.PhoneNumber.value=="")
	{
	alert("Please enter your phone number!");
	f.PhoneNumber.focus();	
	return false;
	}
	else
	{
		if(f.code.value=="")
		{
			alert("You have to enter an area phonecode or the prefix for your mobile number e.g. 020 or 0722 or 0733");
			f.code.focus();	
			return false;
		}
	}
			
	//check if a retreat schedule has been picked
	if(f.retreat.value=="none")
	{
	alert("Please Pick a retreat schedule date!");
	return false;
	}
	
	
	//checking if a payment mode has been checked
	
	var index;
	var count=0;
	for(index=0; index<2; index++)
	{
    	if(!f.Payment[index].checked)
      	count++;
    }
	if(count==2)
	{
	alert("You have to pick a payment mode!");
	return false;
	}
	
	//check if phone number is valid 
		
	for(var i=0; i<f.PhoneNumber.value.length; i++)
	{
		var d=f.PhoneNumber.value.charAt(i);
		
		if(d==" "||d=="\n"||d=="\t")
		{
			alert("Invalid phone number Entry. It should not have any white spaces");
			f.PhoneNumber.focus();
			return false;
		}
		if(isNaN(d))
		{
			alert("The PhoneNumber Entry can only be comprised of numbers!. Please re-enter again");
			f.PhoneNumber.focus();
			return false;
		}
	}
	
	
}