function ResetForm(){
	HideObject('Marital_1');
	HideObject('Employee_1');
	HideObject('Employee_2');
	HideObject('Employee_3');
	HideObject('Employee_4');
	HideObject('Responsible_1');
	HideObject('Responsible_2');
	HideObject('Responsible_3');
	HideObject('Responsible_4');
	HideObject('Responsible_5');
	HideObject('Responsible_6');
	HideObject('Employee_1');
	HideObject('Employee_2');
	HideObject('Employee_3');
	HideObject('Employee_4');
	HideObject('Insured_1');
	HideObject('Insured_2');
	HideObject('Insured_3');
	HideObject('Insured_4');
	HideObject('Insured_5');
	HideObject('Insured_6');
	HideObject('Insured_7');
	HideObject('Insured_8');
	HideObject('Insured_9');
	HideObject('AddInsured_1');
	HideObject('AddInsured_2');
	HideObject('AddInsured_3');
	HideObject('AddInsured_4');
	HideObject('AddInsured_5');
	HideObject('AddInsured_6');
	HideObject('Accident_1');
	HideObject('Accident_2');
	HideObject('Attorney_1');
	HideObject('Ack_1');
}

function ShowObject(ObjectId){
obj = document.getElementById(ObjectId);
obj.style.position = 'relative';
obj.style.visibility= 'visible';
}

function HideObject(ObjectId){
obj = document.getElementById(ObjectId);
obj.style.position = 'absolute';
obj.style.visibility= 'hidden';
}

function ShowMaritalDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'Married'){
		ShowObject('Marital_1');
	}
	else{
		HideObject('Marital_1');
	}
}

function ShowEmployeeDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'Yes'){
		ShowObject('Employee_1');
		ShowObject('Employee_2');
		ShowObject('Employee_3');
		ShowObject('Employee_4');
	}
	else{
		HideObject('Employee_1');
		HideObject('Employee_2');
		HideObject('Employee_3');
		HideObject('Employee_4');
	}
}

function ShowResponsibleDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'No'){
		ShowObject('Responsible_1');
		ShowObject('Responsible_2');
		ShowObject('Responsible_3');
		ShowObject('Responsible_4');
		ShowObject('Responsible_5');
		ShowObject('Responsible_6');
	}
	else{
		HideObject('Responsible_1');
		HideObject('Responsible_2');
		HideObject('Responsible_3');
		HideObject('Responsible_4');
		HideObject('Responsible_5');
		HideObject('Responsible_6');
	}
}

function ShowResponsibleEmployeeDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'Yes'){
		ShowObject('ResponsibleEmployee_1');
		ShowObject('ResponsibleEmployee_2');
		ShowObject('ResponsibleEmployee_3');
		ShowObject('ResponsibleEmployee_4');
	}
	else{
		HideObject('ResponsibleEmployee_1');
		HideObject('ResponsibleEmployee_2');
		HideObject('ResponsibleEmployee_3');
		HideObject('ResponsibleEmployee_4');
	}
}

function ShowInsuredDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'No'){
		ShowObject('Insured_1');
		ShowObject('Insured_2');
		ShowObject('Insured_3');
		ShowObject('Insured_4');
		ShowObject('Insured_5');
		ShowObject('Insured_6');
		ShowObject('Insured_7');
		ShowObject('Insured_8');
		ShowObject('Insured_9');
	}
	else{
		HideObject('Insured_1');
		HideObject('Insured_2');
		HideObject('Insured_3');
		HideObject('Insured_4');
		HideObject('Insured_5');
		HideObject('Insured_6');
		HideObject('Insured_7');
		HideObject('Insured_8');
		HideObject('Insured_9');
	}
}

function ShowAdditionaInsuranceDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'Yes'){
		ShowObject('AddInsured_1');
		ShowObject('AddInsured_2');
		ShowObject('AddInsured_3');
		ShowObject('AddInsured_4');
		ShowObject('AddInsured_5');
		ShowObject('AddInsured_6');
	}
	else{
		HideObject('AddInsured_1');
		HideObject('AddInsured_2');
		HideObject('AddInsured_3');
		HideObject('AddInsured_4');
		HideObject('AddInsured_5');
		HideObject('AddInsured_6');
	}
}

function ShowAccidentDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'Yes'){
		ShowObject('Accident_1');
		ShowObject('Accident_2');
	}
	else{
		HideObject('Accident_1');
		HideObject('Accident_2');
	}
}

function ShowAttorneyDetails(obj){
	if (obj.options[obj.selectedIndex].value == 'Yes'){
		ShowObject('Attorney_1');
	}
	else{
		HideObject('Attorney_1');
	}
}
//<!---------------------form validation functions------->
function isBlank(s)
     {    var len=s.length;
          var i;
          for (i=0;i<len;i++)
          {
                if (s.charAt(i)!=" ") return (false);
          }
          return (true);
     }
 function isNumber(theInput)
     {
          var len;
          len = theInput.length;
          for (var i = 0; i < len; i++)
          {
               if (theInput.charAt(i) < "0" || theInput.charAt(i) > "9")
               {     
                    return false;
               }
          }
          return true;
     }
 //Check date validation in mm/dd/yyy format
function checkdate(input){
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
	var returnval=false
	if (!validformat.test(input.value))
		alert("Please Enter Valid Date Format")
	else{ //Detailed check for valid date ranges
		var monthfield=input.value.split("/")[0]
		var dayfield=input.value.split("/")[1]
		var yearfield=input.value.split("/")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
			alert("Invalid Day, Month, or Year range detected.")
		else
			returnval=true
	}
	//if (returnval==false) 
	//	input.select()
	return returnval
}
 
function validate(){ 
	var strStatus;
	strStatus="yes"
	Frm = document.FrmPatientReg;
	//Check Pateint Information
	//Patient First Name
	/*----------if (isBlank(Frm.FirstName.value)==true){   
		alert("Please Enter Patient First Name Name");
		strStatus="no";
		Frm.FirstName.focus();
		return false;
  	}
	//Patient Last Name
	if (isBlank(Frm.LastName.value)==true){   
		alert("Please Enter Patient Last Name Name");
		strStatus="no";
		Frm.LastName.focus();
		return false;
  	}
	//Patient Mailing Address
	if (isBlank(Frm.MailingAddress.value)==true){   
		alert("Please Enter Patient Mailing Address");
		strStatus="no";
		Frm.MailingAddress.focus();
		return false;
  	}
	//Patient City
	if (isBlank(Frm.City.value)==true){   
		alert("Please Enter Patient City");
		strStatus="no";
		Frm.City.focus();
		return false;
  	}
	//Patient State
	if ((Frm.State.selectedIndex == 0)==true){   
		alert("Please Select Patient State");
		strStatus="no";
		Frm.State.focus();
		return false;
  	}
	//Patient Zip Code
	if (isBlank(Frm.ZipCode.value)==true){   
		alert("Please Enter Patient Zip Code");
		strStatus="no";
		Frm.ZipCode.focus();
		return false;
  	}
	//Patient Sex
	if ((Frm.Sex.selectedIndex == 0)==true){   
		alert("Please Select Patient Sex");
		strStatus="no";
		Frm.Sex.focus();
		return false;
  	}
	//Patient Race
	if ((Frm.Race.selectedIndex == 0)==true){   
		alert("Please Select Patient Race");
		strStatus="no";
		Frm.Race.focus();
		return false;
  	}
	//Patient DOB
	if (isBlank(Frm.DOB.value)==true){   
		alert("Please Enter Patient Date Of Birth");
		strStatus="no";
		Frm.DOB.focus();
		return false;
  	}
	//Patient Date of birth
	if (checkdate(Frm.DOB)==false){   
		//alert("Please Enter Patient Date Of Birth");
		strStatus="no";
		Frm.DOB.focus();
		return false;
  	}
	//Patient Social Security Number part 1
	if (isBlank(Frm.SS_1.value)==true){   
		alert("Please Enter Social Security Number");
		strStatus="no";
		Frm.SS_1.focus();
		return false;
  	}
	//Patient Social Security Number part 2
	if (isBlank(Frm.SS_2.value)==true){   
		alert("Please Enter Social Security Number");
		strStatus="no";
		Frm.SS_2.focus();
		return false;
  	}
	//Patient Social Security Number part 3
	if (isBlank(Frm.SS_3.value)==true){   
		alert("Please Enter Social Security Number");
		strStatus="no";
		Frm.SS_3.focus();
		return false;
  	}
	//Patient Home Phone Number part 1
	if (isBlank(Frm.HomePhone_1.value)==true){   
		alert("Please Enter Home Phone Number");
		strStatus="no";
		Frm.HomePhone_1.focus();
		return false;
  	}
	//Patient Home Phone Number part 2
	if (isBlank(Frm.HomePhone_2.value)==true){   
		alert("Please Enter Home Phone Number");
		strStatus="no";
		Frm.HomePhone_2.focus();
		return false;
  	}
	//Patient Home Phone Number part 3
	if (isBlank(Frm.HomePhone_3.value)==true){   
		alert("Please Enter Home Phone Number");
		strStatus="no";
		Frm.HomePhone_3.focus();
		return false;
  	}
	//Patient Marital Status
	if ((Frm.MaritalStatus.selectedIndex == 0)==true){   
		alert("Please Select Patient Marital Status");
		strStatus="no";
		Frm.MaritalStatus.focus();
		return false;
  	}----------------*/
	// if Marital status is true then check
	/*if (Frm.MaritalStatus.options[Frm.MaritalStatus.selectedIndex].value == 'Married'){   
		//check for Spouse Name
		if (isBlank(Frm.SpousesName.value) == true){   
			alert("Please Enter Patient's Spouse Name");
			strStatus="no";
			Frm.SpousesName.focus();
			return false;
		}
	}

	//Patient Employed
	if ((Frm.Employed.selectedIndex == 0)==true){   
		alert("Please Select Patient Employed");
		strStatus="no";
		Frm.Employed.focus();
		return false;
  	}
	// if Employed status is true then check
	if (Frm.Employed.options[Frm.Employed.selectedIndex].value == 'Yes'){   
		//check for Employer Name
		if (isBlank(Frm.EmployerName.value) == true){   
			alert("Please Enter Employer's Name");
			strStatus="no";
			Frm.EmployerName.focus();
			return false;
		}
		//Check Employer Address
		if (isBlank(Frm.EmployerAddress.value) == true){   
			alert("Please Enter Employer's Address");
			strStatus="no";
			Frm.EmployerAddress.focus();
			return false;
		}
		//Check Employer City
		if (isBlank(Frm.EmployerCity.value) == true){   
			alert("Please Enter Employer's City");
			strStatus="no";
			Frm.EmployerCity.focus();
			return false;
		}
		//Check Employer State
		if ((Frm.EmployerState.selectedIndex == 0)==true){   
			alert("Please Select Employer's State");
			strStatus="no";
			Frm.EmployerState.focus();
			return false;
		}
		//check Employer Zip
		if (isBlank(Frm.EmployerZipCode.value) == true){   
			alert("Please Enter Employer's ZipCode");
			strStatus="no";
			Frm.EmployerZipCode.focus();
			return false;
		}
		//Check Employer Job title
		if (isBlank(Frm.JobTitle.value) == true){   
			alert("Please Enter Job Title");
			strStatus="no";
			Frm.JobTitle.focus();
			return false;
		}
		//Check Employer Length of employment
		if (isBlank(Frm.LengthOfEmployment.value) == true){   
			alert("Please Enter Job Length");
			strStatus="no";
			Frm.LengthOfEmployment.focus();
			return false;
		}
	}*/
	//Patient Patient Responsible Party
/*-----------	if ((Frm.PatientResponsibleParty.selectedIndex == 0)==true){   
		alert("Please Select Patient Responsible Party");
		strStatus="no";
		Frm.PatientResponsibleParty.focus();
		return false;
  	}-------------*/
	//if patient responsible party is true then
	/*if (Frm.PatientResponsibleParty.options[Frm.PatientResponsibleParty.selectedIndex].value == 'No'){   
		//check for Responsible First Name
		if (isBlank(Frm.ResponsiblePartyFirstName.value) == true){   
			alert("Please Enter Responsible Party First Name");
			strStatus="no";
			Frm.ResponsiblePartyFirstName.focus();
			return false;
		}
		//check for Responsible Last Name
		if (isBlank(Frm.ResponsiblePartyLastName.value) == true){   
			alert("Please Enter Responsible Party Last Name");
			strStatus="no";
			Frm.ResponsiblePartyLastName.focus();
			return false;
		}
		//Check Responsible Party Address
		if (isBlank(Frm.ResponsiblePartyMailingAddress.value) == true){   
			alert("Please Enter Responsible Party Address");
			strStatus="no";
			Frm.ResponsiblePartyMailingAddress.focus();
			return false;
		}
		//Check Responsible Party City
		if (isBlank(Frm.ResponsiblePartyCity.value) == true){   
			alert("Please Enter Responsible Party City");
			strStatus="no";
			Frm.ResponsiblePartyCity.focus();
			return false;
		}
		//Check Responsible Party State
		if ((Frm.ResponsiblePartyState.selectedIndex == 0)==true){   
			alert("Please Select Responsible Party State");
			strStatus="no";
			Frm.ResponsiblePartyState.focus();
			return false;
		}
		//check Responsible Party Zip
		if (isBlank(Frm.ResponsiblePartyZipCode.value) == true){   
			alert("Please Enter Responsible Party ZipCode");
			strStatus="no";
			Frm.ResponsiblePartyZipCode.focus();
			return false;
		}
		//Responsible Party Sex
		if ((Frm.ResponsiblePartySex.selectedIndex == 0)==true){   
			alert("Please Select Responsible Party Sex");
			strStatus="no";
			Frm.ResponsiblePartySex.focus();
			return false;
		}
		//Responsible Party Race
		if ((Frm.ResponsiblePartyRace.selectedIndex == 0)==true){   
			alert("Please Select Responsible Party Race");
			strStatus="no";
			Frm.ResponsiblePartyRace.focus();
			return false;
		}
		//Responsible Party DOB
		if (isBlank(Frm.ResponsiblePartyDOB.value)==true){   
			alert("Please Enter Responsible Party Date Of Birth");
			strStatus="no";
			Frm.ResponsiblePartyDOB.focus();
			return false;
		}
		//Responsible Party of birth
		if (checkdate(Frm.ResponsiblePartyDOB)==false){   
			//alert("Please Enter Patient Date Of Birth");
			strStatus="no";
			Frm.ResponsiblePartyDOB.focus();
			return false;
		}
		//Responsible Party Social Security Number part 1
		if (isBlank(Frm.ResponsiblePartySS_1.value)==true){   
			alert("Please Enter Responsible Party Social Security Number");
			strStatus="no";
			Frm.ResponsiblePartySS_1.focus();
			return false;
		}
		//Responsible Party Social Security Number part 2
		if (isBlank(Frm.ResponsiblePartySS_2.value)==true){   
			alert("Please Enter Responsible Party Social Security Number");
			strStatus="no";
			Frm.ResponsiblePartySS_2.focus();
			return false;
		}
		//Responsible Party Social Security Number part 3
		if (isBlank(Frm.ResponsiblePartySS_3.value)==true){   
			alert("Please Enter Responsible Party Social Security Number");
			strStatus="no";
			Frm.ResponsiblePartySS_3.focus();
			return false;
		}
		//Responsible Party Home Phone Number part 1
		if (isBlank(Frm.ResponsiblePartyHomePhone_1.value)==true){   
			alert("Please Enter Responsible Party Home Phone Number");
			strStatus="no";
			Frm.HomePhone_1.focus();
			return false;
		}
		//Patient Home Phone Number part 2
		if (isBlank(Frm.ResponsiblePartyHomePhone_2.value)==true){   
			alert("Please Enter Responsible Party Home Phone Number");
			strStatus="no";
			Frm.HomePhone_2.focus();
			return false;
		}
		//Patient Home Phone Number part 3
		if (isBlank(Frm.ResponsiblePartyHomePhone_3.value)==true){   
			alert("Please Enter Responsible Party Home Phone Number");
			strStatus="no";
			Frm.HomePhone_3.focus();
			return false;
		}
	}*/
	//Patient Responsible Party Employed
	/*-------------if ((Frm.ResponsiblePartyEmployed.selectedIndex == 0)==true){   
		alert("Please Select Patient Responsible Party Employed");
		strStatus="no";
		Frm.ResponsiblePartyEmployed.focus();
		return false;
  	}
	//Patient Patient The Insured
	if ((Frm.PatientTheInsured.selectedIndex == 0)==true){   
		alert("Please Select Patient Insured");
		strStatus="no";
		Frm.PatientTheInsured.focus();
		return false;
  	}
	//Primery Insurance
	if ((Frm.PrimaryInsuranceType.selectedIndex == 0)==true){   
		alert("Please Select Patient Primery Insurance Type");
		strStatus="no";
		Frm.PrimaryInsuranceType.focus();
		return false;
  	}
	//Patient Secondary Insurance
	if ((Frm.SecondaryInsurance.selectedIndex == 0)==true){   
		alert("Please Select Patient Secondary Insurance");
		strStatus="no";
		Frm.SecondaryInsurance.focus();
		return false;
  	}
	///Patient Miscellaneous Information
	//Patient Accident Related
	if ((Frm.AccidentRelated.selectedIndex == 0)==true){   
		alert("Please Select Patient Accident Related");
		strStatus="no";
		Frm.AccidentRelated.focus();
		return false;
  	}---------------*/
	// if accident is true then check
	/*if (Frm.AccidentRelated.options[Frm.AccidentRelated.selectedIndex].value == 'Yes'){   
		//check for accident date and time
		if (isBlank(Frm.DateTimeOfInjury.value)==true){   
			alert("Please Enter Date and Time of Injury");
			strStatus="no";
			Frm.DateTimeOfInjury.focus();
			return false;
  		}
		//check for accident place
		if (isBlank(Frm.PlaceInjuryOccurred.value)==true){   
			alert("Please Enter Place of Injury");
			strStatus="no";
			Frm.PlaceInjuryOccurred.focus();
			return false;
  		}
	}*/
	//Patient Durable Power Of Attorney   
/*--------	if ((Frm.DurablePowerOfAttorney.selectedIndex == 0)==true){   
		alert("Please Select Patient Durable Power Of Attorney");
		strStatus="no";
		Frm.DurablePowerOfAttorney.focus();
		return false;
  	}------------*/
	// if Durable Power Of Attorney is true then check
	/*if (Frm.DurablePowerOfAttorney.options[Frm.DurablePowerOfAttorney.selectedIndex].value == 'Yes'){   
		//check for Living Will Power Of Attorney On File At MCH
		if ((Frm.LivingWillPowerOfAttorneyOnFileAtMCH.selectedIndex == 0)==true){   
			alert("Please Select Patient Living Will Power Of Attorney On File At MCH");
			strStatus="no";
			Frm.LivingWillPowerOfAttorneyOnFileAtMCH.focus();
			return false;
		}
	}*/
	//Name of Physician 
	/*----------if (isBlank(Frm.PhysicianName.value)==true){   
		alert("Please Enter Physician Name");
		strStatus="no";
		Frm.PhysicianName.focus();
		return false;
	}
	// Date Of Procedure Or Service
	if (isBlank(Frm.DateOfProcedureOrService.value)==true){   
		alert("Please Enter Patient Date Of Procedure Or Service");
		strStatus="no";
		Frm.DateOfProcedureOrService.focus();
		return false;
  	}
	//Patient Date Of Procedure Or Service
	if (checkdate(Frm.DateOfProcedureOrService)==false){   
		//alert("Please Enter Patient Date Of Birth");
		strStatus="no";
		Frm.DateOfProcedureOrService.focus();
		return false;
  	}----------*/

	if (Frm.EmailWhenRcvd[0].checked){
		if (isBlank(Frm.AcknowledgeEmailAddress.value)==true){   
				alert("Please Enter Email Address ");
				strStatus="no";
				Frm.AcknowledgeEmailAddress.focus();
				return false;
			}
		if(Frm.AcknowledgeEmailAddress.value.indexOf("@")==-1){
		   alert("Please enter Email Address in correct format");
		   strStatus="no";
		   Frm.AcknowledgeEmailAddress.focus();
		   return false;
		}
		if(Frm.AcknowledgeEmailAddress.value.indexOf("@")==0){
			alert("Please enter Email Address in correct format");
			strStatus="no";
			Frm.AcknowledgeEmailAddress.focus();
			return false;
		}
		if(Frm.AcknowledgeEmailAddress.value.indexOf(".")==-1){    
			alert("Please enter Email Address in correct format");
			strStatus="no";
			Frm.AcknowledgeEmailAddress.focus();
			return false;
		}
	}
	else{
		Frm.AcknowledgeEmailAddress.value = "";
	}

	Frm.isPosted.value = "t";

	if(strStatus=="yes"){
		return true;
  	}
	else {
	    return false;
   	}
}
