function parentaddresslogicSwitch(flag) {
	document.OnlineApplication.parentaddressstreet.disabled = flag;
	document.OnlineApplication.parentaddresscity.disabled = flag;
	document.OnlineApplication.parentaddresscityzipcode.disabled = flag;
	document.OnlineApplication.parentaddresscountry.disabled = flag;
}

function AccompanyingparentsSwitch(flag) {
	document.OnlineApplication.ParentsNum.disabled = flag;
}

function ProgramlogicSwitch(flag) {
	for (var i=0; i<document.OnlineApplication.Accompanyingparents.length; i++) {
		document.OnlineApplication.Accompanyingparents[i].disabled = flag;
		}
}

function AirportPickuplogicSwitch(flag) {
	document.OnlineApplication.ArrivalDate.disabled = flag;
	document.OnlineApplication.Comingfrom.disabled = flag;
	document.OnlineApplication.AirportofArrival.disabled = flag;
	document.OnlineApplication.Airline.disabled = flag;
	document.OnlineApplication.FlightNo.disabled = flag;
	document.OnlineApplication.ArrivalTime.disabled = flag;	
}

function HealthConditionlogicSwitch(flag) {
	document.OnlineApplication.HealthConditioncontent.disabled = flag;
	document.OnlineApplication.Symptoms.disabled = flag;
	document.OnlineApplication.Medications.disabled = flag;
}

function HousingArrangementlogicSwitch(flag) {
	for (var i=0; i<document.OnlineApplication.HousingArrangementyes.length; i++) {
			document.OnlineApplication.HousingArrangementyes[i].disabled = flag;
		}
	document.OnlineApplication.CheckinDate.disabled = flag;
	document.OnlineApplication.CheckoutDate.disabled = flag;	
}

function HousingArrangementyeslogicSwitch(flag) {
	document.OnlineApplication.HousingArrangementOthers.disabled = flag;
}

function StartDatelogicSwitch(flag) {
	var count=document.OnlineApplication.StartDate.length; //Start Date （单选）
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.StartDate[i].checked) 
		document.OnlineApplication.StartDateOthersdate.disabled = flag;
	} 
}

function StartDatelogicSwitch2(flag) {
	ocument.OnlineApplication.StartDateOthersdate.disabled = flag;
}

function TakenbeforelogicSwitch(flag) {
	document.OnlineApplication.Takenbeforecontent.disabled = flag;
}

function hearaboutuslogicSwitch(flag) {
	document.OnlineApplication.Advertisementcontent.disabled = flag;
	document.OnlineApplication.Friendcontent.disabled = flag;
	document.OnlineApplication.Agentcontent.disabled = flag;
	document.OnlineApplication.Companycontent.disabled = flag;
}

function hearaboutuscontentlogicSwitch(flag) {
	var R1s = document.getElementsByName("hearaboutus");//Housing Arrangement 先判断单选，再继续下一步
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if(R1s[i].checked && R1s[i].value == "Advertisement")
		{
			document.OnlineApplication.Advertisementcontent.disabled = flag;
			document.OnlineApplication.Friendcontent.disabled = true;
			document.OnlineApplication.Agentcontent.disabled = true;
			document.OnlineApplication.Companycontent.disabled = true;
		}
		if(R1s[i].checked && R1s[i].value == "Friend")
		{
			document.OnlineApplication.Advertisementcontent.disabled = true;
			document.OnlineApplication.Friendcontent.disabled = flag;
			document.OnlineApplication.Agentcontent.disabled = true;
			document.OnlineApplication.Companycontent.disabled = true;
		}
		if(R1s[i].checked && R1s[i].value == "Agent")
		{
			document.OnlineApplication.Advertisementcontent.disabled = true;
			document.OnlineApplication.Friendcontent.disabled = true;
			document.OnlineApplication.Agentcontent.disabled = flag;
			document.OnlineApplication.Companycontent.disabled = true;
		}
		if(R1s[i].checked && R1s[i].value == "Company")
		{
			document.OnlineApplication.Advertisementcontent.disabled = true;
			document.OnlineApplication.Friendcontent.disabled = true;
			document.OnlineApplication.Agentcontent.disabled = true;
			document.OnlineApplication.Companycontent.disabled = flag;
		}
	}
}

function checkinput() { 

	var R1s = document.getElementsByName("Program");//Program 先判断单选，再继续下一步
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if (R1s[i].checked) 
		++j; 
		if(R1s[i].checked && R1s[i].value == "Full Camp (7-25yrs)")
		{
			var R1s = document.getElementsByName("Accompanyingparents");//Program 先判断单选，再继续下一步
			var j=0;
			for(i=0;i<R1s.length;i++)
				{
					if (R1s[i].checked) 
					++j; 
					if(R1s[i].checked && R1s[i].value == "Yes")
						{
							if (document.OnlineApplication.ParentsNum.value.length == 0)
								{
									alert("Please specify the number of accompanying parents!"); 
									return false;	
								}
						 } 			
				 }
			if(j==0) 
			{alert("Please select the Accompanying parents!!"); 
			return false;} 
		 } 			
	}
	if(j==0) 
	{alert("Please select a program!!"); 
	return false;} 


	var R1s = document.getElementsByName("StartDate");//Program 先判断单选，再继续下一步
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if (R1s[i].checked) 
		++j; 
		if(R1s[i].checked && R1s[i].value == "Others")
		{
			if (document.OnlineApplication.StartDateOthersdate.value.length == 0)
				{
					alert("Please specify the Start Date Others date!"); 
					return false;	
				}
		 } 			
	}
	if(j==0) 
	{alert("Please select a Start Date!!"); 
	return false;} 
		
	
	var count=document.OnlineApplication.AirportPickup.length; //Airport Pick-up（单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.AirportPickup[i].checked) 
	++j; 
	} 
	if(j==0) 
	{alert("Please select Airport Pick-up!!"); 
	return false;} 
		

	if (document.OnlineApplication.FirstName.value.length == 0) {//Personal Information First Name（输入框）
		alert("Please specify your First Name");
		document.OnlineApplication.FirstName.focus();
		return false;
	}
	
	if (document.OnlineApplication.FamilyName.value.length == 0) {//Personal Information Family Name（输入框）
		alert("Please specify your Family Name");
		document.OnlineApplication.FamilyName.focus();
		return false;
	}
	
	var count=document.OnlineApplication.Gender.length; //Personal Information Gender（单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.Gender[i].checked) 
	++j; 
	} 
	if(j==0) 
	{alert("Please select Gender!!"); 
	return false;} 
	
	if (document.OnlineApplication.Nationality.value.length == 0) {//Personal Information Nationality（输入框）
		alert("Please specify your Nationality");
		document.OnlineApplication.Nationality.focus();
		return false;
	}
	
	if (document.OnlineApplication.Nativelanguage.value.length == 0) {//Personal Information Native language（输入框）
		alert("Please specify your Native language");
		document.OnlineApplication.Nativelanguage.focus();
		return false;
	}
	
	if (document.OnlineApplication.telnocountry.value.length == 0) {//Personal Information telno. country（输入框）
		alert("Please specify your telno. country");
		document.OnlineApplication.telnocountry.focus();
		return false;
	}
	
	if (document.OnlineApplication.telnoarea.value.length == 0) {//Personal Information telno. area（输入框）
		alert("Please specify your telno. area");
		document.OnlineApplication.telnoarea.focus();
		return false;
	}
	
	if (document.OnlineApplication.telnophone.value.length == 0) {//Personal Information telno. phone（输入框）
		alert("Please specify your tel no. phone");
		document.OnlineApplication.telnophone.focus();
		return false;
	}
		
	if (document.OnlineApplication.Addressstreet.value.length == 0) {//Personal Information Address street（输入框）
		alert("Please specify your Address street");
		document.OnlineApplication.Addressstreet.focus();
		return false;
	}
	
	if (document.OnlineApplication.Addresscity.value.length == 0) {//Personal Information Address city（输入框）
		alert("Please specify your Address city");
		document.OnlineApplication.Addresscity.focus();
		return false;
	}
	
	if (document.OnlineApplication.Addresszipcode.value.length == 0) {//Personal Information Address zip code（输入框）
		alert("Please specify your Address zip code");
		document.OnlineApplication.Addresszipcode.focus();
		return false;
	}
	
	if (document.OnlineApplication.Addresscountry.value.length == 0) {//Personal Information Address country（输入框）
		alert("Please specify your Address country");
		document.OnlineApplication.Addresscountry.focus();
		return false;
	}
		
	var count=document.OnlineApplication.CurrentlevelofChinese.length; //Personal Information Current level of Chinese（单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.CurrentlevelofChinese[i].checked) 
	++j; 
	} 
	if(j==0) 
	{alert("Please select Current level of Chinese!!"); 
	return false;} 
	
	var count=document.OnlineApplication.HealthCondition.length; //Personal Information Health Condition（单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.HealthCondition[i].checked) 
		{
			if (document.OnlineApplication.HealthCondition[i].value == "Yes")
			{
				if (document.OnlineApplication.HealthConditioncontent.value.length == 0)
					{
						alert("Please specify the medical conditions!"); 
						return false;	
					}	
			}
		}
	++j; 
	} 
	if(j==0) 
	{alert("Please select Health Condition!!"); 
	return false;} 
	
	if (document.OnlineApplication.EmergencyContactName.value.length == 0) {//Personal Information Emergency Contact Name（输入框）
		alert("Please specify your Emergency Contact Name");
		document.OnlineApplication.EmergencyContactName.focus();
		return false;
	}
	
	if (document.OnlineApplication.EmergencyContactRelationship.value.length == 0) {//Personal Information Emergency Contact Relationship（输入框）
		alert("Please specify your Emergency Contact Relationship");
		document.OnlineApplication.EmergencyContactRelationship.focus();
		return false;
	}
	
	if (document.OnlineApplication.EmergencyContactCountry.value.length == 0) {//Personal Information Emergency Contact Country（输入框）
		alert("Please specify your Emergency Contact Country");
		document.OnlineApplication.EmergencyContactCountry.focus();
		return false;
	}
	
	if (document.OnlineApplication.EmergencyContactCountry.value.length == 0) {//Personal Information Emergency Contact Country（输入框）
		alert("Please specify your Emergency Contact Country");
		document.OnlineApplication.EmergencyContactCountry.focus();
		return false;
	}
	
	if (document.OnlineApplication.EmergencyContactArea.value.length == 0) {//Personal Information Emergency Contact Area（输入框）
		alert("Please specify your Emergency Contact Area");
		document.OnlineApplication.EmergencyContactArea.focus();
		return false;
	}
	
	if (document.OnlineApplication.EmergencyContactPhone.value.length == 0) {//Personal Information Emergency Contact Phone（输入框）
		alert("Please specify your Emergency Contact Phone");
		document.OnlineApplication.EmergencyContactPhone.focus();
		return false;
	}
		
	var count=document.OnlineApplication.Takenbefore.length; //Taken any programs with Mandarinrocks before?（单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.Takenbefore[i].checked) 
		{
			if (document.OnlineApplication.Takenbefore[i].value == "Yes") 
			{
				if (document.OnlineApplication.Takenbeforecontent.value.length == 0)
				{
					alert("Please specify the programs you have taken with Mandarinrocks before.");
					document.OnlineApplication.Takenbeforecontent.focus();
					return false;
				}
			}
		}
	++j; 
	} 
	if(j==0) 
	{alert("Please select Taken any programs with Mandarinrocks before?"); 
	return false;} 
	
	var R1s = document.getElementsByName("hearaboutus");//How did you hear about us? 先判断单选，再继续下一步判断
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if (R1s[i].checked) 
		++j; 
		if(R1s[i].checked && R1s[i].value == "Advertisement")//Advertisement（输入框）
		{
			if (document.OnlineApplication.Advertisementcontent.value.length == 0) 
			{
			alert("Please specify your Advertisement content");
			document.OnlineApplication.Advertisementcontent.focus();
			return false;
			}
		}
		if(R1s[i].checked && R1s[i].value == "Friend")//Friend（输入框）
		{
			if (document.OnlineApplication.Friendcontent.value.length == 0) {
				alert("Please specify your Friend content");
				document.OnlineApplication.Friendcontent.focus();
				return false;
			}
		}
		if(R1s[i].checked && R1s[i].value == "Agent")//Agent（输入框）
		{
			if (document.OnlineApplication.Agentcontent.value.length == 0) 
			{
			alert("Please specify your Agent content");
			document.OnlineApplication.Agentcontent.focus();
			return false;
			}
		}
		if(R1s[i].checked && R1s[i].value == "Company")//Company（输入框）
		{
			if (document.OnlineApplication.Companycontent.value.length == 0) 
			{
			alert("Please specify your Company content");
			document.OnlineApplication.Companycontent.focus();
			return false;
			}
		}
	}
	if(j==0) 
	{alert("Please select How did you hear about us?!!"); 
	return false;} 

	if (document.OnlineApplication.Fathername.value.length == 0) {//Parent Information Nationality（输入框）
		alert("Please specify parent's or guardian's name");
		document.OnlineApplication.Fathername.focus();
		return false;
	}
	
	if (document.OnlineApplication.FatherRelationship.value.length == 0) {//Parent Information Nationality（输入框）
		alert("Please specify parent's or guardian's Relationship");
		document.OnlineApplication.FatherRelationship.focus();
		return false;
	}
	
	if (document.OnlineApplication.FatherNationality.value.length == 0) {//Parent Information Nationality（输入框）
		alert("Please specify parent's or guardian's Nationality");
		document.OnlineApplication.FatherNationality.focus();
		return false;
	}
	
	if (document.OnlineApplication.FatherAge.value.length == 0) {//Parent Information Native language（输入框）
		alert("Please specify parent's or guardian's Age");
		document.OnlineApplication.FatherAge.focus();
		return false;
	}
	
	if (document.OnlineApplication.FatherOccupation.value.length == 0) {//Parent Information telno. country（输入框）
		alert("Please specify parent's or guardian's Occupation");
		document.OnlineApplication.FatherOccupation.focus();
		return false;
	}
	
	if (document.OnlineApplication.Fathertelnocountry.value.length == 0) {//Parent Information telno. area（输入框）
		alert("Please specify parent's or guardian's tel no. country");
		document.OnlineApplication.Fathertelnocountry.focus();
		return false;
	}
	
	if (document.OnlineApplication.Fathertelnoarea.value.length == 0) {//Parent Information telno. area（输入框）
		alert("Please specify parent's or guardian's tel no. area");
		document.OnlineApplication.Fathertelnoarea.focus();
		return false;
	}
	
	if (document.OnlineApplication.Fathertelnophone.value.length == 0) {//Parent Information telno. phone（输入框）
		alert("Please specify parent's or guardian's tel no. phone");
		document.OnlineApplication.Fathertelnophone.focus();
		return false;
	}
	
	var count=document.OnlineApplication.FatherAccompanyingparent.length; //Parent Information Accompanying parent（单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.FatherAccompanyingparent[i].checked) 
	++j; 
	} 
	if(j==0) 
	{alert("Please select Accompanying parent"); 
	return false;} 
		

	var R1s = document.getElementsByName("parentaddress");//Program 先判断单选，再继续下一步
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if (R1s[i].checked) 
		++j; 
		if(R1s[i].checked && R1s[i].value == "No")
		{
			if (document.OnlineApplication.parentaddressstreet.value.length == 0) {//Personal Information Address street（输入框）
				alert("Please specify Parents's address street");
				document.OnlineApplication.parentaddressstreet.focus();
				return false;
				}
							
			if (document.OnlineApplication.parentaddresscity.value.length == 0) {//Personal Information Address city（输入框）
				alert("Please specify Parents's address city");
				document.OnlineApplication.parentaddresscity.focus();
				return false;
				}
							
			if (document.OnlineApplication.parentaddresscityzipcode.value.length == 0) {//Personal Information Address zip code（输入框）
				alert("Please specify Parents's address city zipcode");
				document.OnlineApplication.parentaddresscityzipcode.focus();
				return false;
				}
							
			if (document.OnlineApplication.parentaddresscountry.value.length == 0) {//Personal Information Address country（输入框）
				alert("Please specify Parents's address country");
				document.OnlineApplication.parentaddresscountry.focus();
				return false;
				}
		} 			
	}
	if(j==0) 
	{alert("Please select Parents's address!!"); 
	return false;} 
	
	if (document.OnlineApplication.email.value.length == 0) {//Personal Information Emergency Contact Phone
		alert("Please enter your email");
		document.OnlineApplication.email.focus();
		return false;
	}
	
	if (document.OnlineApplication.email.value.length > 0 && !document.OnlineApplication.email.value.match( /^.+@.+$/ ) ) {//CHECK EMAIL 格式
		alert("Please enter correct Email address");
		document.OnlineApplication.email.focus();
		return false;
	}
	
	if (document.OnlineApplication.reemail.value.length > 0 && !document.OnlineApplication.reemail.value.match( /^.+@.+$/ ) ) {//CHECK RE-EMAIL 格式
		alert("Please enter correct Re-enter Email address");
		document.OnlineApplication.reemail.focus();
		return false;
	}
	
	if (document.OnlineApplication.email.value!=document.OnlineApplication.reemail.value ) {//CHECK EMAIL 2次是否输入一致
		alert("The emial address you entered is not the same!");
		document.OnlineApplication.reemail.focus();
		return false;
	}
	
	if (!document.OnlineApplication.agreed.checked) 
	{alert("have you read and agreed to Mandarinrocks'Terms and Conditions?"); 
	return false;} 
	
} 