function ClearCharity(clear_type){
	if(clear_type=="all"){
		document.frm.target_all.value = "";
		document.frm.charity_name.value = "";
		document.frm.target.value = "";	
	}
	if(clear_type=="charity"){
		document.frm.charity_name.value = "";
		document.frm.target.value = "";	
	}
	if(clear_type=="target") document.frm.target_all.value = "";	
}

function ClearGroup(clear_type){
	if(clear_type=="all"){
		document.frm.own_group_count.value = "";
		document.frm.adult_GL.selectedIndex = 0;
		document.frm.own_group_name.value = "";	

		document.frm.under16_group_count.value = "";
		document.frm.under16_GL.selectedIndex = 0;
		document.frm.under16_group_name.value = "";	
	}
	if(clear_type=="under16"){
		document.frm.under16_group_count.value = "";
		document.frm.under16_GL.selectedIndex = 0;
		document.frm.under16_group_name.value = "";	
	}
	if(clear_type=="adult"){
		document.frm.own_group_count.value = "";
		document.frm.adult_GL.selectedIndex = 0;
		document.frm.own_group_name.value = "";	
	}
}

function CheckCharity(){
	var target_all, charity_name, target, dataRight = true;
	message = "";
	if((document.frm.charity_option[0].checked == false) && (document.frm.charity_option[1].checked == false) && (document.frm.charity_option[2].checked == false)){
		message += "\n -  Select Charity Option";
		dataRight=false;
	}

	if(document.frm.charity_option[0].checked){
		target_all = document.frm.target_all.value;
		if(target_all.length == 0){
			message += "\n -  Enter Target";
			dataRight=false;
		}
	}

	if(document.frm.charity_option[1].checked){
		charity_name = document.frm.charity_name.value;
		target = document.frm.target.value;
		if(charity_name.length == 0){
			message += "\n -  Enter Charity Name";
			dataRight=false;
		}
		if(target.length == 0){
			message += "\n -  Enter Target";
			dataRight=false;
		}
	}

	if (!dataRight){
		if (message != ""){
		   message ="\n" + "You failed to correctly fill in the form:\n" + message + "\n" + "\nPlease re-enter and click the Next button again!";
	   }
	   alert(message);
	}
	return dataRight;	
}

function CheckPeople(){
	var own_group_count, adult_GL, own_group_name, under16_group_count, under16_GL, under16_group_name, dataRight = true;
	message = "";
	if((document.frm.people_option[0].checked == false) && (document.frm.people_option[1].checked == false) && (document.frm.people_option[2].checked == false)){
		message += "\n -  Select People Option";
		dataRight=false;
	}

	if(document.frm.people_option[1].checked){
		own_group_count = document.frm.own_group_count.value;
		adult_GL = document.frm.adult_GL.value;
		own_group_name = document.frm.own_group_name.value;
		if(own_group_count.length == 0){
			message += "\n -  Enter Number of people in the group";
			dataRight=false;
		}
		if(adult_GL.length == 0){
			message += "\n -  Select group";
			dataRight=false;
		}
		if(own_group_name.length == 0){
			message += "\n -  Enter Group name";
			dataRight=false;
		}
	}

	if(document.frm.people_option[2].checked){
		under16_group_count = document.frm.under16_group_count.value;
		under16_GL = document.frm.under16_GL.value;
		under16_group_name = document.frm.under16_group_name.value;
		if(under16_group_count.length == 0){
			message += "\n -  Enter Number of people in the group";
			dataRight=false;
		}
		if(under16_GL.length == 0){
			message += "\n -  Select group";
			dataRight=false;
		}
		if(under16_group_name.length == 0){
			message += "\n -  Enter Group name";
			dataRight=false;
		}
	}

	if (!dataRight){
		if (message != ""){
		   message ="\n" +  "You failed to correctly fill in the form:\n" + message + "\n" + "\nPlease re-enter and click the Next button again!";
	   }
	   alert(message);
	}
	return dataRight;	
}

function CheckPersonalDetails(people_count){
	re = /([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)/;
	var own_sex, own_first_name, own_surname, own_email, own_birthday, own_address, dataRight = true;
	message = "";

	own_first_name = document.frm.own_first_name.value;
	own_surname = document.frm.own_surname.value;
	own_email = document.frm.own_email.value;
	own_birthday = document.frm.own_birthday.value;
	own_address = document.frm.own_address.value;

	if((document.frm.own_sex[0].checked == false) && (document.frm.own_sex[1].checked == false)){
		message += "\n -  Select Your Gender";
		dataRight=false;
	}

	if(own_first_name.length == 0){
		message += "\n -  Enter Your Name";
		dataRight=false;
	}
	if(own_surname.length == 0){
		message += "\n -  Enter Your Surname";
		dataRight=false;
	}
	if(own_email.length == 0){
		message += "\n -  Enter Your Email";
		dataRight=false;
	}
	if(own_birthday.length == 0){
		message += "\n -  Enter Your Date of Birth";
		dataRight=false;
	}
	if(own_address.length == 0){
		message += "\n -  Enter Your Contact Address";
		dataRight=false;
	}
	if (own_email.length!=0 && own_email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your email is incorrect";
	}

	for(i=1;i<=people_count;i++){
		other_sex = "other_sex_"+i;
		other_s = document.getElementsByName(other_sex);
		if((other_s[0].checked == false) && (other_s[1].checked == false)){
			message += "\n -  Select Other #" + i + " Gender";
			dataRight=false;
		}		

		other_first_name = "other_first_name_"+i;
		other_f_n = document.getElementById(other_first_name);
		first_name_value = other_f_n.value;
		if(first_name_value.length == 0){
			message += "\n -  Enter Other #" + i + " First Name";
			dataRight=false;
		}

		other_surname = "other_surname_"+i;
		other_s_n = document.getElementById(other_surname);
		surname_value = other_s_n.value;
		if(surname_value.length == 0){
			message += "\n -  Enter Other #" + i + " Surname";
			dataRight=false;
		}	
	}

	if (!dataRight){
		if (message != ""){
		   message ="\n" +  "You failed to correctly fill in the form:\n" + message + "\n" + "\nPlease re-enter and click the Next button again!";
	   }
	   alert(message);
	}
	return dataRight;	
}