
function ClearHNValue(){	
		alert(form.HN.value);
}


function checkRegisterNull(){
   form = document.registerForm;
   
	if(form.Bmc[0].checked == true){
		if(form.Hn.value == ""){
		 alert('please fill in Hospital Number');
		 form.Hn.focus();
		 return false;
	   }
	}

   if(form.Title.value == ""){
     alert('please fill in title');
	 form.Title.focus();
	 return false;
   }
   if(form.Firstname.value == ""){
     alert('please fill in firstname');
	 form.Firstname.focus();
	 return false;
   }
   if(form.Lastname.value == ""){
     alert('please fill in lastname');
	 form.Lastname.focus();
	 return false;
   }
   if((form.Gender[0].checked == false) && (form.Gender[1].checked == false)){
     alert('please fill in gender');	
	 return false;
   }   
  if(form.MaritalStatus.value == ""){
     alert('please select marital status');
	 form.MaritalStatus.focus();
	 return false;
   }	
   if(form.dbDay.value == ""){
     alert('please select date of birth');
	 form.dbDay.focus();
	 return false;
   }
   if(form.dbMonth.value == ""){
     alert('please select month of birth');
	 form.dbMonth.focus();
	 return false;
   }
   if(form.dbYear.value == ""){
     alert('please select year of birth');
	 form.dbYear.focus();
	 return false;
   }
   if(form.Passport.value == ""){
     alert('please fill in passport No. / ID No.');
	 form.Passport.focus();
	 return false;
   }
   if(form.Nation.value == ""){
     alert('please fill in nationality');
	 form.Nation.focus();
	 return false;
   }
   if(form.language.value == ""){
     alert('please fill in primary language');
	 form.language.focus();
	 return false;
   }
   if(form.CountryR.value == ""){
     alert('please fill in country of residence');
	 form.CountryR.focus();
	 return false;
   }
   if(form.CurrentStreet.value == ""){
     alert('please fill in current street address');
	 form.CurrentStreet.focus();
	 return false;
   }
   if(form.City.value == ""){
     alert('please fill in city');
	 form.City.focus();
	 return false;
   }
   if(form.Province.value == ""){
     alert('please fill in state / province');
	 form.Province.focus();
	 return false;
   }
   if(form.Country.value == ""){
     alert('please select your country');
	 form.Country.focus();
	 return false;
   }
   if(form.Zipcode.value == ""){
     alert('please fill in zip / post code ');
	 form.Zipcode.focus();
	 return false;
   }
   if(form.Homeno.value == ""){
     alert('please fill in home no.');
	 form.Homeno.focus();
	 return false;
   }
   if(form.Mobileno.value == ""){
     alert('please fill in mobile no.');
	 form.Mobileno.focus();
	 return false;
   }
   if(form.Allergic[1].checked == true){
		if(form.AllergicSpecify.value == ""){
		 alert('please specify information');
		form.AllergicSpecify.focus();
		return false;
	   }
   }

   //Contact Person;
   if(form.e_person.value == ""){
     alert('please fill in contact person');
	 form.e_person.focus();
	 return false;
   }
   if(form.e_relation.value == ""){
     alert('please fill in relationship to patient');
	 form.e_relation.focus();
	 return false;
   }
   if(form.e_phone.value == ""){
     alert('please fill in home phone no.');
	 form.e_phone.focus();
	 return false;
   }
   if(form.e_mobile.value == ""){
     alert('please fill in mobile phone no.');
	 form.e_mobile.focus();
	 return false;
   }
   /*
   if(form.FaxnoE.value == ""){
     alert('please fill in Fax No.');
	 form.FaxnoE.focus();
	 return false;
   }
   */
   if(form.e_address.value == ""){
     alert('please fill in current street address');
	 form.e_address.focus();
	 return false;
   }
   if(form.e_city.value == ""){
     alert('please fill in city');
	 form.e_city.focus();
	 return false;
   }
   if(form.e_state.value == ""){
     alert('please fill in state / province');
	 form.e_state.focus();
	 return false;
   }
   if(form.e_country.value == ""){
     alert('please fill in country ');
	 form.e_country.focus();
	 return false;
   }
   if(form.e_zipcode.value == ""){
     alert('please fill in zip / post code');
	 form.e_zipcode.focus();
	 return false;
   }
   if(form.email.value == ""){
     alert('please fill in email address');
	 form.email.focus();
	 return false;
   }

   if(echeck(form.email.value)==1){
		alert("Invalid your email is not correct!");
		form.email.focus() ;
		return false;
	}

   if(form.pass.value == ""){
     alert('please fill in password');
	 form.pass.focus();
	 return false;
   }
   if(form.confirmpass.value == ""){
     alert('please fill in confirm password');
	 form.confirmpass.focus();
	 return false;
   }
   if(form.secretQuestion.value == ""){
     alert('please fill in security question');
	 form.secretQuestion.focus();
	 return false;
   }
  if(form.answer.value == ""){
     alert('please fill in security answer');
	 form.answer.focus();
	 return false;
   }
  if(form.captchatext.value == ""){
     alert('please fill in security text');
	 form.captchatext.focus();
	 return false;
   }  
  if(form.pass.value != form.confirmpass.value){
     alert('password and confirm password mismatch, please try again.');
	 form.confirmpass.focus();
	 return false;
   }
   if(form.captchatext.value != form.captchapix.value){
     alert('Security text mismatch, please try again.');
	 form.captchatext.focus();
	 return false;
   } 

   return true;

}


function checkRegisterPartialNull(){
   form = document.registerForm;
   
	if(form.Bmc[0].checked == true){
		if(form.Hn.value == ""){
		 alert('please fill in Hospital Number');
		 form.Hn.focus();
		 return false;
	   }
	}

   if(form.Title.value == ""){
     alert('please fill in title');
	 form.Title.focus();
	 return false;
   }
   if(form.Firstname.value == ""){
     alert('please fill in firstname');
	 form.Firstname.focus();
	 return false;
   }
   if(form.Lastname.value == ""){
     alert('please fill in lastname');
	 form.Lastname.focus();
	 return false;
   }
   if((form.Gender[0].checked == false) && (form.Gender[1].checked == false)){
     alert('please fill in gender');	
	 return false;
   }   
 
   if(form.dbDay.value == ""){
     alert('please select date of birth');
	 form.dbDay.focus();
	 return false;
   }
   if(form.dbMonth.value == ""){
     alert('please select month of birth');
	 form.dbMonth.focus();
	 return false;
   }
   if(form.dbYear.value == ""){
     alert('please select year of birth');
	 form.dbYear.focus();
	 return false;
   }
   if(form.Passport.value == ""){
     alert('please fill in passport No. / ID No.');
	 form.Passport.focus();
	 return false;
   }
   if(form.CountryR.value == ""){
     alert('please fill in country of residence');
	 form.CountryR.focus();
	 return false;
   }
   if(form.Nation.value == ""){
     alert('please fill in nationality');
	 form.Nation.focus();
	 return false;
   } 
  
   if(form.email.value == ""){
     alert('please fill in email address');
	 form.email.focus();
	 return false;
   }

   if(echeck(form.email.value)==1){
		alert("Invalid your email is not correct!");
		form.email.focus() ;
		return false;
	}

   if(form.pass.value == ""){
     alert('please fill in password');
	 form.pass.focus();
	 return false;
   }
   //check pass less than 6 charactor

  if(form.pass.value.length < 6){
     alert('password at lease 6 charactors');
	 form.pass.focus();
	 return false;
   }

   
   return true;

}

//check email
function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);

		if ((str==null)||(str=="")){
			return -1;
		}

		if (str.indexOf(at)==-1){
			return 1;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			return 1;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return 1;
		}

		if (str.indexOf(at,(lat+1))!=-1){
			return 1;
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return 1;
		}

		if (str.indexOf(dot,(lat+2))==-1){
			return 1;
		}

		if (str.indexOf(" ")!=-1){
			return 1;
		}

		return 0;

	}


function checkAdmissionNull(){
   form = document.admissionForm;
   if(form.arrivalDate.value == ""){
     alert('please fill in Arrival Date');
	 form.arrivalDate.focus();
	 return false;
   }
   if(form.arrivalTime.value == ""){
     alert('please fill in Arrival Time');
	 form.arrivalTime.focus();
	 return false;
   }
   if(form.flightDetails.value == ""){
     alert('please fill in Flight Details');
	 form.flightDetails.focus();
	 return false;
   }
/*
   if(form.attendPhR.value == ""){
     alert('please fill in Attending Physician Request');
	 form.attendPhR.focus();
	 return false;
   }
*/
   if(form.personalCheck.value == ""){
     alert('please fill in Has patient ever seen a doctor at bangkok hospital?');
	 form.personalCheck.focus();
	 return false;
   }
   if(form.hn.value == ""){
     alert('please fill in Hospital Number (H.N.)');
	 form.hn.focus();
	 return false;
   }
   if(form.title.value == ""){
     alert('please fill in Title');
	 form.title.focus();
	 return false;
   }
   if(form.firstName.value == ""){
     alert('please fill in First Name');
	 form.firstName.focus();
	 return false;
   }
   if(form.lastName.value == ""){
     alert('please fill in Last Name');
	 form.lastName.focus();
	 return false;
   }
   if((form.sex[0].checked == false) && (form.sex[1].checked == false)){
     alert('please fill in Gender');	
	 return false;
   }
   if(form.dd.value == ""){
     alert('please fill in Date of Birth');
	 form.dd.focus();
	 return false;
   }
   if(form.MM.value == ""){
     alert('please fill in Date of Birth');
	 form.MM.focus();
	 return false;
   }
   if(form.YY.value == ""){
     alert('please fill in Date of Birth');
	 form.YY.focus();
	 return false;
   }
   if(form.passNo.value == ""){
     alert('please fill in Passport No.');
	 form.passNo.focus();
	 return false;
   }
   if(form.nation.value == ""){
     alert('please fill in Nationality ');
	 form.nation.focus();
	 return false;
   }
   if(form.address.value == ""){
     alert('please fill in Current address');
	 form.address.focus();
	 return false;
   }
   if(form.district.value == ""){
     alert('please fill in District');
	 form.district.focus();
	 return false;
   }
   if(form.city.value == ""){
     alert('please fill in City');
	 form.city.focus();
	 return false;
   }
   if(form.state.value == ""){
     alert('please fill in State / Province');
	 form.state.focus();
	 return false;
   }
   if(form.country.value == ""){
     alert('please fill in Country');
	 form.country.focus();
	 return false;
   }
   if(form.zipcode.value == ""){
     alert('please fill in Mobile Zip Code');
	 form.zipcode.focus();
	 return false;
   }
   if(form.homeNo.value == ""){
     alert('please fill in Home No.');
	 form.homeNo.focus();
	 return false;
   }
   if(form.mobile.value == ""){
     alert('please fill in Mobile No.');
	 form.mobile.focus();
	 return false;
   }
   if(form.email.value == ""){
     alert('please fill in Email Address');
	 form.email.focus();
	 return false;
   }

   if(echeck(form.email.value)==1){
		alert("Invalid your Email is not correct!");
		form.email.focus() ;
		return false;
	}

   if(form.diagnosis.value == ""){
     alert('please fill in Diagnosis');
	 form.diagnosis.focus();
	 return false;
   }
   if(form.medicalHistory.value == ""){
     alert('please fill in Medical History and Treatment');
	 form.medicalHistory.focus();
	 return false;
   }
   if(form.conditionM.value == ""){  
     alert('please fill in Current Condition & Medications ');
	 form.conditionM.focus();
	 return false;
   }
   if(form.evacaution[0].checked == true){
	 //alert(form.evacaution[0].checked);
	 return checkAdmissionYesNull();
   }

   return true;

}

function checkAdmissionYesNull(){
   form = document.admissionForm;
   if((!form.Significant.checked) && (!form.Confuse.checked) && (!form.Depress.checked) && (!form.Drowsy.checked) && (!form.Anxious.checked) && (!form.Unresponsive.checked) && (!form.Disorient.checked) && (!form.Appearance.checked)){
	 alert('please fill in Appearance');
	 return false;
   }
   if((!form.significant2.checked) && (!form.Stridor.checked) && (!form.OralAirway.checked) && (!form.Secretion.checked) && (!form.Nasalairway.checked) && (!form.Injury.checked) && (!form.TrachealTube.checked)&& (!form.TracheostomyTube.checked)&& (!form.Airway.checked)){
	 alert('please fill in Airway');
	 return false;
   }
   if((!form.Significant3.checked) && (!form.Tachycardia.checked) && (!form.Dyspnea.checked) && (!form.Respiratory.checked)){
	 alert('please fill in Respiratory & CVS');
	 return false;
   }
   if((!form.Cannula.checked) && (!form.CollarMask.checked) && (!form.Mask.checked) && (!form.Ventilator.checked)){
	 alert('please fill in Oxygen');
	 return false;
   }
   if((!form.Walking.checked) && (!form.WakingAid.checked) && (!form.Assistance.checked) && (!form.CannotWalk.checked)){
	 alert('please fill in Walking');
	 return false;
   }
   if((!form.SittingLess60.checked) && (!form.SittingMore60.checked) && (!form.SittingOnly.checked) && (!form.Cannotsit.checked)){
	 alert('please fill in Sitting');
	 return false;
   }


   return true;

}

function checkLemousineNull(){
   form = document.lemousineForm;
   if(form.firstname.value == ""){
     alert('please fill in first name');
	 form.firstname.focus();
	 return false;
   }
   if(form.lastname.value == ""){
     alert('please fill in last name');
	 form.lastname.focus();
	 return false;
   }
   if((form.sex[0].checked == false) && (form.sex[1].checked == false)){
     alert('please fill in gender');	
	 return false;
   }
   if(form.dbDay.value == ""){
     alert('please fill in date of birth');
	 form.dbDay.focus();
	 return false;
   }
   if(form.dbMonth.value == ""){
     alert('please fill in month of birth');
	 form.dbMonth.focus();
	 return false;
   }
   if(form.dbYear.value == ""){
     alert('please fill in year of birth');
	 form.dbYear.focus();
	 return false;
   }
   if(form.nation.value == ""){
     alert('please fill in Nationality');
	 form.nation.focus();
	 return false;
   }
   if(form.address.value == ""){
     alert('please fill in Current Street Address');
	 form.address.focus();
	 return false;
   }
   if(form.city.value == ""){
     alert('please fill in City');
	 form.city.focus();
	 return false;
   }
   if(form.province.value == ""){
     alert('please fill in State / Province');
	 form.province.focus();
	 return false;
   }
   if(form.country.value == ""){
     alert('please fill in Country');
	 form.country.focus();
	 return false;
   }

   if(form.email.value == ""){
     alert('please fill in Email Address');
	 form.email.focus();
	 return false;
   }

   if(echeck(form.email.value)==1){
		alert("Invalid your Email is not correct!");
		form.email.focus() ;
		return false;
	}

   if(form.arrivalDate.value == ""){
     alert('please fill in Arrival Date');
	 form.arrivalDate.focus();
	 return false;
   }
   if(form.arrivalHr.value == ""){
     alert('please fill in Arrival Time (local time)');
	 form.arrivalHr.focus();
	 return false;
   }
   if(form.arrivalFlight.value == ""){
     alert('please fill in Arrival Flight No.');
	 form.arrivalFlight.focus();
	 return false;
   }
   if(form.DepDate.value == ""){
     alert('please fill in Departure date');
	 form.DepDate.focus();
	 return false;
   }
   if(form.depHr.value == ""){
     alert('please fill in Departure time');
	 form.depHr.focus();
	 return false;
   }
   if(form.DepFlight.value == ""){
     alert('please fill in Departure Flight No');
	 form.DepFlight.focus();
	 return false;
   }
   if(form.ofcar.value == ""){
     alert('please fill in Type Of Car');
	 form.ofcar.focus();
	 return false;
   }
   if((form.apToHospital[0].checked == false) && (form.apToHospital[1].checked == false)){
     alert('please fill in Airport To Hospital');	
	 return false;
   }
   if((form.HpToAirport[0].checked == false) && (form.HpToAirport[1].checked == false)){
     alert('please fill in Hospital To Airport');	
	 return false;
   }

   return true;

}

function radioChangeLemousine(radioValue){
		  if (radioValue =="0"){
			window.location= 'index.php?p=serviceLimousine&flag=0';
		  }
		  
		  if (radioValue =="1"){
			window.location= 'index.php?p=serviceLimousine&flag=1';
		  }
}

function checkChivaRenewalNull(){ 
		 form = document.chivaForm;
		   if(form.Title.value == ""){
			 alert('please select Title');
			 form.Title.focus();
			 return false;
		   }
		   if(form.Firstname.value == ""){
			 alert('please fill in First Name');
			 form.Firstname.focus();
			 return false;
		   }	  
			if(form.Lastname.value == ""){
			 alert('please fill in Last Name');
			 form.Lastname.focus();
			 return false;
		   }	   
		   if(form.hn.value == ""){
			 alert('please fill in Hospital Number');
			 form.hn.focus();
			 return false;
		   }	  
			 if(form.Passport.value == ""){
			 alert('please fill in Passport No.');
			 form.Passport.focus();
			 return false;
		   }	 
			if(form.dd.value == ""){
			 alert('please select Date.');
			 form.dd.focus();
			 return false;
		   }	     
			if(form.MM.value == ""){
			 alert('please select Month.');
			 form.MM.focus();
			 return false;
		   }	
			if(form.yy.value == ""){
			 alert('please select Year.');
			 form.yy.focus();
			 return false;
		   }	   
			 if(form.address.value == ""){
			 alert('please fill in Address.');
			 form.address.focus();
			 return false;
		   }	
			 if(form.City.value == ""){
			 alert('please fill in City.');
			 form.City.focus();
			 return false;
		   }	
			 if(form.Province.value == ""){
			 alert('please fill in Province.');
			 form.Province.focus();
			 return false;
		   }
			 if(form.Country.value == ""){
			 alert('please fill in Country.');
			 form.Country.focus();
			 return false;
		   }  
			 if(form.Zipcode.value == ""){
			 alert('please fill in Zipcode.');
			 form.Zipcode.focus();
			 return false;
		   }  
			 if(form.Telephone.value == ""){
			 alert('please fill in Telephone No.');
			 form.Telephone.focus();
			 return false;
		   }  
			 if(form.Email.value == ""){
			 alert('please fill in Email.');
			 form.Email.focus();
			 return false;
		   }  
		   if(echeck(form.Email.value)==1){
				alert("Invalid your Email is not correct!");
				form.Email.focus() ;
				return false;
			}
			
			 if(form.cardtype.value == ""){
			 alert('please select Type of Card.');
			 form.cardtype.focus();
			 return false;
		   }  

	return true;	  
}

