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 HowmanylessonsSwitch(flag) {
	var count=document.OnlineApplication.Howmanylessons.length; //Start Date （单选）
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.Howmanylessons[i].checked) 
		document.OnlineApplication.Howmanylessonsotherscontent.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 count=document.OnlineApplication.Program.length; //Program （单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.Program[i].checked) 
	++j; 
	} 
	if(j==0) 
	{alert("Please select A Program!"); 
	return false;} 
	
	var count=document.OnlineApplication.StartDate.length; //Start Date （单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
	if (document.OnlineApplication.StartDate[i].checked) 
	++j; 
	} 
	if(j==0) 
	{alert("Please select Start Date!!"); 
	return false;} 

	if (document.OnlineApplication.FinishDate.value.length == 0) {//Finish Date（日期输入框）
		alert("Please select Finish Date");
		document.OnlineApplication.FinishDate.focus();
		return false;
	}
	
	var R1s = document.getElementsByName("Program");//Housing Arrangement 先判断单选，再继续下一步
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if(R1s[i].checked && R1s[i].value == "General Chinese Private Tuition (Flexible time)" || R1s[i].checked && R1s[i].value == "Business Chinese Private Tuition (Flexible time)" || R1s[i].checked && R1s[i].value == "HSK Preparation Private Tuition  (Flexible time)")
		{
			var count=document.OnlineApplication.Howmanylessons.length; //Start Date （单选）
			var j=0; 
			for(var i=0;i<count;i++) 
			{ 
			if (document.OnlineApplication.Howmanylessons[i].checked) 
				{
					if (document.OnlineApplication.Howmanylessons[i].value == "Others" && document.OnlineApplication.Howmanylessonsotherscontent.value.length == 0) 
					{
					alert("Please specify Private Tuition other lessons!");
					document.OnlineApplication.Howmanylessonsotherscontent.focus();
					return false;
					}
				}
			++j; 
			} 
			if(j==0) 
			{alert("You have select a private tuition program,so you have to select the For Private Tuition Only information!"); 
			return false;} 
			
			var count=document.OnlineApplication.Howmanystudents.length; //Start Date （单选）
			var j=0; 
			for(var i=0;i<count;i++) 
			{ 
			if (document.OnlineApplication.Howmanystudents[i].checked) 
			++j; 
			} 
			if(j==0) 
			{alert("You have select a private tuition program,so you have to select the For Private Tuition Only information!"); 
			return false;} 
		}
	}
	
	var count=document.OnlineApplication.Howmanylessons.length; //Start Date （单选）
	var j=0; 
	for(var i=0;i<count;i++) 
	{ 
		if (document.OnlineApplication.Howmanylessons[i].checked) 
			{
				if (document.OnlineApplication.Howmanylessons[i].value == "Others" && document.OnlineApplication.Howmanylessonsotherscontent.value.length == 0) 
				{
					alert("Please specify Private Tuition other lessons!");
					document.OnlineApplication.Howmanylessonsotherscontent.focus();
					return false;
				}
			}
		++j; 
	} 

	
	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;} 
	
	var R1s = document.getElementsByName("HousingArrangement");//Housing Arrangement 先判断单选，再继续下一步
	var j=0;
	for(i=0;i<R1s.length;i++)
	{
		if (R1s[i].checked) 
		++j; 
		if(R1s[i].checked && R1s[i].value == "No")
		{
		}
		if(R1s[i].checked && R1s[i].value == "Yes")
		{
			var count=document.OnlineApplication.HousingArrangementyes.length; //HousingArrangement-yes
			var j=0; 
			for(var i=0;i<count;i++) 
			{ 
			if (document.OnlineApplication.HousingArrangementyes[i].checked) 
				{
					if (document.OnlineApplication.HousingArrangementyes[i].value == "Others") 	
					{
						if (document.OnlineApplication.HousingArrangementOthers.value.length == 0)
						{
							alert("Please specify the Housing Arrangement Others Content!"); 
							return false;	
						}
					}
				}
			++j; 
			} 
			if(j==0) 
			{alert("Please select Housing Arrangement Content!!"); 
			return false;} 
			
			if (document.OnlineApplication.CheckinDate.value.length == 0) {//Housing Arrangement Check in Date（日期输入框）
				alert("Please select Housing Arrangement Check in Date");
				document.OnlineApplication.CheckinDate.focus();
				return false;
			}
	
			if (document.OnlineApplication.CheckoutDate.value.length == 0) {//Housing Arrangement Check out Date（日期输入框）
				alert("Please select Housing Arrangement Check out Date");
				document.OnlineApplication.CheckoutDate.focus();
				return false;
			}
		}
	}
	if(j==0) 
	{alert("Please select Housing Arrangement!!"); 
	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.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;} 
	
} 
