<?php include "headerLink.php"?>
<!DOCTYPE html>
<html lang="en">


<body class="animsition">
    <div class="page-wrapper">
        <!-- HEADER MOBILE-->
        <?php include "menuSideBar_mobile.php" ;?>
        <!-- END HEADER MOBILE-->
		
        <!-- MENU SIDEBAR-->
        <?php include "menuSideBar.php" ;?>
        <!-- END MENU SIDEBAR-->

        <!-- PAGE CONTAINER-->
        <div class="page-container">
            <!-- HEADER DESKTOP-->
			<?php include "headerPage.php"?>
            <!-- END HEADER DESKTOP-->
			
			
			
			<!-- MAIN CONTENT-->
			
            <!--main content upper start-->
			<?php include "main-content-upper.php"?>
            <!--main content upper end-->
			<!--main content middle start-->
						<div class="row" >
							<div class="col-lg-12">
								<div class="card">
									<div class="card-header">
										<strong>Tenant Registration</strong> Form
									</div>
									<div class="card-body card-block" style="background-color: white;">
										<?php 	
											if($_POST['projectName'] != ""){
												$_SESSION['projectName']=$_POST['projectName'];
												$_SESSION['locationName'] = "";
												$_SESSION['propertiesParentsUnit'] = "";
											 }
											else{
												//echo "project name 0";
											$_SESSION['projectName']= "";
											$_SESSION['locationName'] = "";
											$_SESSION['propertiesParentsUnit'] = "";
											}
										
											if($projectLocation != ""){
												$_SESSION['projectName']= $projectName;
												$_SESSION['locationName']= $locationName;
											}?>
										<form action="" method="post" class="form-horizontal">
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">Project</label>
												</div>
												<div class="col-12 col-md-3">
													<input type="text" id="text-input" class="form-control" list="projectName" name="projectName" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['projectName']?>" readonly placeholder="Select Project"/>
													<datalist id="projectName">
													<?php
														if($_SESSION["username"] != "admin"){
															
															$sqlProject = "select EL.location_id, locations.location_name, locations.project_id, projects.project_name from extra_locations as EL 
																			inner join locations on locations.id = EL.location_id 
																			left join projects on locations.project_id = projects.id 
																			where staff_id = '".$_SESSION['staff_id']."' group by `projects`.`project_name` ORDER BY `projects`.`project_name` ASC  
																			";
														}
														else if($_SESSION["username"] == "admin"){
															
															 $sqlProject = "select * from projects where (project_code <> '000') order by project_name ASC ";
															
														}
														$runProject = mysqli_query($link, $sqlProject);
														if($runProject === FALSE){
															die(mysqli_error($link));
														}
														while($resultProject = mysqli_fetch_array($runProject)){
															
															$project_name = $resultProject["project_name"];
															if($_SESSION["username"] != "admin"){
																$project_name = $resultProject["project_name"];
															}
																?>
																
																<option value="<?php echo strtoupper($project_name); ?>">
																<?php
														}
													?>
													</datalist>
													<?php if($_SESSION['projectName'] == ""){?>
													<span class="help-block">Please choose project</span>
													<?php } ?>
												</div>
											</div>
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">Location</label>
												</div>
												<div class="col-12 col-md-3">
													
													<input type="text" id="text-input" class="form-control" list="locationName" name="locationName" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['locationName']?>" readonly placeholder="Select Location" autocomplete="off"/>
													<datalist id="locationName">
													<?php
														if($_SESSION["username"] <> "admin"){
															$sqlLocations = "select EL.location_id, locations.location_name, projects.project_name from extra_locations as EL 
																	inner join locations on locations.id = EL.location_id 
																	left join projects on locations.project_id = projects.id 
																	where projects.project_name = '".$_SESSION["projectName"]."' and staff_id = '".$_SESSION['staff_id']."'";
														}
														else if($_SESSION["username"] == "admin"){
															//ECHO $sqlLocations = "SELECT * FROM `locations`  ";
															 $sqlLocations = "SELECT id, 
																					location_code , 
																					location_name FROM `locations`
																					where project_id = '".$_SESSION["project_id"]. "' 
																					ORDER BY `location_name` ASC ";

														}
														
														$runLocations = mysqli_query($link, $sqlLocations);
														if($runLocations === FALSE){
															die(mysqli_error($link));
														}
														while($resultLocations = mysqli_fetch_array($runLocations)){
															$location_id = $resultLocations["id"];
															$location_code = $resultLocations["location_code"];
															$location_name = $resultLocations["location_name"];
															
																?>
																
															<option value="<?php echo strtoupper($location_name); ?>">
															<?php
														}
													?>
													</datalist>
													<?php if($_SESSION['locationName'] == ""){?>
													<span class="help-block">Please choose location</span>
													<?php } ?>
												</div>
											</div>
											<input type="hidden" name="projectLocation" value="<?php echo $_SESSION["projectLocation"]?>">
											<input type="hidden" name="menu" value="<?php echo $_SESSION["menu"]?>">
											<input type="hidden" name="submenu" value="<?php echo $_SESSION["submenu"]?>">
											<?php if($_SESSION["projectName"] == "PPR"){ ?>
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">Unit No.</label>
												</div>
												<div class="col-12 col-md-3">
													<?php $_SESSION['properties_unitno'] = $_POST["properties_unitno"]?>
													<input class="form-control" type="text"  id="properties_unitno_input" list="properties_unitno" name="properties_unitno" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['properties_unitno']?>" placeholder="Select Unit No" autocomplete="off"/>
													<datalist id="properties_unitno">
													<?php
														if($_SESSION["username"] <> "admin"){
															
																$sqlPropertiesUnitNo = "select properties.* from properties 
																	inner join locations on properties.location_id = locations.id 
																	where locations.location_name = '".$_SESSION["locationName"]."' 
																	and locations.project_id = ".$_SESSION["project_id"]." 
																	and properties.status = 'enable'
																	";
														}
														else if($_SESSION["username"] == "admin"){
															
															 $sqlPropertiesUnitNo = "select properties.* from properties 
																	inner join locations on properties.location_id = locations.id 
																	where locations.location_name = '".$_SESSION["locationName"]."' 
																	and locations.project_id = ".$_SESSION["project_id"]."
																	and properties.status = 'enable'
																	";
														}
														
														$runProeprtiesUnit  = mysqli_query($link, $sqlPropertiesUnitNo );
													if($runProeprtiesUnit === FALSE){
														die(mysqli_error($link));
													}
													
													
														while($resultPropertiesUnit = mysqli_fetch_array($runProeprtiesUnit)){
															$propertiesID = $resultPropertiesUnit["id"];
															$properties_unitno = $resultPropertiesUnit["unit_no"];
															
																?>
																
															<option value="<?php echo strtoupper($properties_unitno); ?>">
															<?php
														}
														
													?>
													</datalist>
												</div>
											</div>
											<?php }
											else if($_SESSION["projectName"] != "PPR"){ ?>
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">Parent's Unit No.</label>
												</div>
												<div class="col-12 col-md-3">
													<?php $_SESSION['propertiesParentsUnit'] = $_POST["propertiesParentsUnit"]?>
													<input class="form-control" type="text"  id="propertiesParentsUnit_input" list="propertiesParentsUnit" name="propertiesParentsUnit" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['propertiesParentsUnit']?>" placeholder="Select Parent's Unit" autocomplete="off"/>
													<datalist id="propertiesParentsUnit">
													<?php
														if($_SESSION["username"] <> "admin"){
															
																$sqlParentsUnit = "select properties.* from properties 
																	inner join locations on properties.location_id = locations.id 
																	where locations.location_name = '".$_SESSION["locationName"]."' 
																	and locations.project_id = ".$_SESSION["project_id"]."
																	";
														}
														else if($_SESSION["username"] == "admin"){
															
															 $sqlParentsUnit = "select properties.* from properties 
																	inner join locations on properties.location_id = locations.id 
																	where locations.location_name = '".$_SESSION["locationName"]."' 
																	and locations.project_id = ".$_SESSION["project_id"]."
																	";
														}
														
														$runParentsUnit  = mysqli_query($link, $sqlParentsUnit );
													if($runParentsUnit === FALSE){
														die(mysqli_error($link));
													}
													
													
														while($resultParentsUnit = mysqli_fetch_array($runParentsUnit)){
															$propertiesID = $resultParentsUnit["id"];
															$properties_parents_unit = $resultParentsUnit["unit_no"];
															
																?>
																
															<option value="<?php echo strtoupper($properties_parents_unit); ?>">
															<?php
														}
														
													?>
													</datalist>
													<div class="col-12 col-md-9">
														<?php 
															if($_SESSION["project_id"] == 1){
														?>
														&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="skipParentsUnit"  onclick="alert();" name="skipParentsUnit" value="yes" class="form-check-input">Skip Parent's Unit No.
															<?php } ?>
													</div>
												</div>
											</div>
											
											<input type="hidden" name="sqlParentsUnit" value="<?php echo $sqlParentsUnit;?>">
										
											<input type="hidden" name = "location_id_selected" value="<?php echo $location_id_selected?>">
											<input name="staff_id" type="hidden" size="20" value="<?php echo htmlspecialchars($_SESSION["staff_id"]); ?>">
											<?php 
												$sqlLocationID = "select id from locations where location_name = '".$_SESSION['locationName']."'";
												$runLocationID  = mysqli_query($link, $sqlLocationID );
												if($runLocationID === FALSE){
													die(mysqli_error($link));
												}
												$resultLocationID = mysqli_fetch_assoc($runLocationID);
												$location_id_selected = $resultLocationID["id"];
												$_SESSION['location_id_selected']=$location_id_selected;
												?>
												<input type="hidden" name = "projectName" value="<?php echo $_GET["projectName"]?>">
												<input type="hidden" name = "project_id" value="<?php echo $projectID_selected?>">
												<input type="hidden" name = "location_id_selected" value="<?php echo $location_id_selected?>">
												<input type="hidden" name="property_id" value="<?php echo $property_id?>">
											<!--<div >
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">Child's Unit No.</label>
													</div>
													<div class="col-12 col-md-3">
														<?php $_SESSION['propertiesChildsUnit'] = $_POST["propertiesChildsUnit"]?>
														<input class="form-control" type="text" list="propertiesChildsUnit" name="propertiesChildsUnit" required="" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['propertiesChildsUnit']?>" placeholder="Select Child's Unit" autocomplete="off"/>
														<datalist id="propertiesChildsUnit">
														<?php 
															//sql get parents info from selected parents unit
															$sqlParentsUnit = "";
															if($_POST["sqlParentsUnit"] != "" && $_SESSION["propertiesParentsUnit"] != ""){
																 $sqlParentsUnit = $_POST["sqlParentsUnit"] . " and properties.unit_no = '".$_SESSION["propertiesParentsUnit"]."' ";
																
																$runParentsUnit = mysqli_query($link, $sqlParentsUnit );
																if($runParentsUnit === FALSE){
																	die(mysqli_error($link));
																}
																$resultParentsUnit = mysqli_fetch_assoc($runParentsUnit);
																$parentsUnitID = $resultParentsUnit["id"];
																
																//sql child unit
																 $sqlChildInfo = "select * from properties_unit where property_id = $parentsUnitID and unit_status = 'enable' ";
																$runChildInfo = mysqli_query($link, $sqlChildInfo );
																if($runChildInfo === FALSE){
																	die(mysqli_error($link));
																}
																
																while($resultChildInfo = mysqli_fetch_array($runChildInfo)){
																	$unit_no = $resultChildInfo["unit_no"];
																	$childUnitID = $resultChildInfo["id"];
																	?>
																	<option value="<?php echo $unit_no; ?>">
																<?php } 
															}
															else{
																
															
																$sqlChildUnit = "select properties.*, properties_unit.* from properties_unit
																	inner join properties on properties_unit.property_id = properties.id
																	inner join locations on properties.location_id = locations.id 
																	where locations.location_name = '".$_SESSION["locationName"]."' 
																	and locations.project_id = ".$_SESSION["project_id"]." and properties_unit.unit_status = 'enable'
																	";
																
																
																$runChildUnit  = mysqli_query($link, $sqlChildUnit );
																if($runChildUnit === FALSE){
																	die(mysqli_error($link));
																}
																
																
																	while($resultChildUnit = mysqli_fetch_array($runChildUnit)){
																		$propertiesChildID = $resultChildUnit["id"];
																		$properties_child_unit = $resultChildUnit["unit_no"];
																		
																			?>
																			
																		<option value="<?php echo strtoupper($properties_child_unit); ?>">
																		<?php
																	}
																}
															
															?>
															
														</datalist>
													</div>
												</div>
											</div>-->
											<?php }?>
											</form>
											<form action="tenant_registerNew_save.php" method="post" enctype="multipart/form data" >
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">Start Rental</label>
												</div>
												<div class="col-12 col-md-3">
													<input type="date" name="start_rent" required=""  class="form-control"  value="<?php echo $_SESSION['start_rent']?>" autocomplete="off" >
												</div>
											</div>
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">End Rental</label>
												</div>
												<div class="col-12 col-md-3">
													<input type="date" name="end_rent"  required="" class="form-control"  value="<?php echo $_SESSION['start_rent']?>" autocomplete="off" >
												</div>
											</div>
											<div class="row form-group">
												<div class="col col-md-3">
													<label for="text-input" class=" form-control-label">Register Type</label>
												</div>
												<div class="col col-md-3">
													<div class="form-check">
														<div class="radio">
															<label for="radio1" class="form-check-label ">
																<input type="radio" id="radio1" name="type_reg" value="Individu" class="form-check-input" onclick="individuClick()">Individual
															</label>
														</div>
														<div class="radio">
															<label for="radio2" class="form-check-label ">
																<input type="radio" id="radio2" name="type_reg" value="Syarikat" class="form-check-input" onclick="syarikatClick()">Company
															</label>
														</div>
													</div>
												</div>
											</div>
									</div>	
								</div>
							</div>
						</div>
						<div class="row">
								<div  class="col-lg-12" >
									<!--sini<div class="card" >-->
									<div id="individuClick" style='display:none;'>
										<!--<div class="col-lg-12">-->
											<div class="card">
												<div class="card-header">
													<h4>Individual</h4>
												</div>
												<div class="card-body">
													<div class="default-tab">
														<nav>
															<div class="nav nav-tabs" id="nav-tab" role="tablist">
																<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home"
																 aria-selected="true"><b>Tenant</b> </a>
																<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile"
																 aria-selected="false"><b>Spouse</b></a>
																<a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact"
																 aria-selected="false"><b>Salary</b></a>
																 <a class="nav-item nav-link" id="nav-selangorku-tab" data-toggle="tab" href="#nav-selangorku" role="tab" aria-controls="nav-selangorku"
																 aria-selected="false"><b>Info Rumah SelangorKU</b></a>
																  <a class="nav-item nav-link" id="nav-harta-tab" data-toggle="tab" href="#nav-harta" role="tab" aria-controls="nav-harta"
																 aria-selected="false"><b>Holding Property Information</b></a>
																 <a class="nav-item nav-link" id="nav-kesihatan-tab" data-toggle="tab" href="#nav-kesihatan" role="tab" aria-controls="nav-kesihatan"
																 aria-selected="false"><b>Health Info</b></a>
																 <a class="nav-item nav-link" id="nav-keluarga-tab" data-toggle="tab" href="#nav-keluarga" role="tab" aria-controls="nav-keluarga"
																 aria-selected="false"><b>Tenant's Family Members</b></a>
															</div>
														</nav>
														<div class="tab-content pl-3 pt-2" id="nav-tabContent">
															<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">
																<div class="card-body card-block">
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Name</label>
																			</div>
																			<div class="col-12 col-md-9">
																				<input type="text" name="name"   class="form-control" required="" value="<?php echo $_SESSION['name']?>" >
																				<?php if($_SESSION['name'] == ""){?>
																				<span class="help-block">Please insert Tenant's name </span>
																				<?php } ?>
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">NRIC</label>
																			</div>
																			<div class="col-12 col-md-9">
																				<input type="text" name="ic"   class="form-control" required="" value="<?php echo $_SESSION['ic']?>" onChange="myIC(this.value);" placeholder="xxxxxx-xx-xxxx" pattern="[0-9]{6}-[0-9]{2}-[0-9]{4}" title="xxxxxx-xx-xxxx" >
																				<?php if($_SESSION['ic'] == ""){?>
																				<span class="help-block">Please insert Tenant's NRIC </span>
																				<?php } ?>
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">D.O.B</label>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" id="dob" name="dob"  class="form-control"  value="<?php echo $_SESSION['dob']?>" required="" readonly>
																				<?php if($_SESSION['dob'] == ""){?>
																				<span class="help-block">Tenant's Date of Birth (DOB): auto </span>
																				<?php } ?>
																			</div>
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Age</label>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" id="age" name="age"  class="form-control"  value="<?php echo $_SESSION['age']?>" required="" readonly>
																				<?php if($_SESSION['age'] == ""){?>
																				<span class="help-block">Tenant's Age: auto </span>
																				<?php } ?>
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Gender</label>
																			</div>
																			<div class="col col-md-3">
																				
																					<select id="gender" name="gender" class="form-control form-control" required="" disabled="">
																						<option>-</option>
																						<option value="Male">Male</option>
																						<option value="Female">Female</option>
																					</select>
																				
																			</div>
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Nationality</label>
																			</div>
																			<div class="col col-md-3">
																				
																					<select id="nationality" name="nationality" class="form-control form-control" required="" disabled="">
																						<option>-</option>
																						<option value="Warganegara">Warganegara</option>
																						<option value="Bukan Warganegara">Bukan Warganegara</option>
																					</select>
																			</div>	
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Religion</label>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" id="religion" name="religion"  class="form-control" required="" value="<?php echo $_SESSION['religion']?>" >
																				<?php if($_SESSION['religion'] == ""){?>
																				<span class="help-block">Tenant's Religion </span>
																				<?php } ?>
																			</div>
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Race</label>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" id="race" name="race"  class="form-control" required="" value="<?php echo $_SESSION['race']?>" >
																				<?php if($_SESSION['race'] == ""){?>
																				<span class="help-block">Tenant's Race </span>
																				<?php } ?>
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Marital Status</label>
																			</div>
																			<div class="col col-md-9">
																				<select id="marital_status" name="marital_status" required="" class="form-control form-control" >
																					<option>-</option>
																					<option value="Bujang">Single</option>
																					<option value="Berkahwin">Maried</option>
																					<option value="Duda/Janda">Widow</option>
																				</select>
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Mailing address</label>
																			</div>
																			<div class="col-12 col-md-9">
																				<input type="text" name="line1"   class="form-control" required=""  value="<?php echo $_SESSION['line1']?>" placeholder="P.O. Box/ Company Name/ Unit No for Address Line 1." >
																				
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">&nbsp;</label>
																			</div>
																			<div class="col-12 col-md-9">
																				<input type="text" name="line2"   class="form-control"  required="" value="<?php echo $_SESSION['line2']?>" placeholder="Floor/Apartment/Building/Street Name for Address Line 2. ">
																				
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">&nbsp;</label>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" name="postcode"   class="form-control"  required="" value="<?php echo $_SESSION['postcode']?>" placeholder="Postcode ">
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" name="city"   class="form-control" required="" value="<?php echo $_SESSION['city']?>" placeholder="City  ">
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" name="state"   class="form-control" required=""  value="<?php echo $_SESSION['state']?>" placeholder="State ">
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Contact No.</label>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" name="home_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['home_tel_no']?>" onChange="myTelNo(this.value);" placeholder="+6xx-xxxxxxxx" pattern="(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}" title="+6xx-xxxxxxxx" >
																				<span class="help-block">Home Tel. No. </span>
																			</div>
																			<div class="col-12 col-md-3">
																				<input type="text" name="mobile_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['mobile_tel_no']?>"  onChange="myPhoneNo(this.value);" placeholder="+6xxx-xxxxxxxx" pattern="(\+?6?01)[0|1|2|3|4|6|7|8|9]\-*[0-9]{7,8}" title="+6xxx-xxxxxxxx" >
																				<span class="help-block">Mobile Tel. No. </span>
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">&nbsp;</label>
																			</div>
																			<div class="col-12 col-md-9">
																				<input type="email" name="email_address"   class="form-control"  required="" value="<?php echo $_SESSION['email_address']?>" placeholder="abc@test.com ">
																			</div>
																		</div>
																		<div class="row form-group">
																			<div class="col col-md-3">
																				<label for="text-input" class=" form-control-label">Polling Place</label>
																				
																				<span class="help-block"><p><i>(Tempat Mengundi)</i></p></span>
																			</div>
																			<div class="col col-md-9">
																				<div class="form-check">
																					<div class="radio">
																						<label for="radioSelangor" class="form-check-label ">
																							<input type="radio" id="radioSelangor" name="tempat_mengundi" value="Selangor" class="form-check-input" onclick="selangorClick()"> Selangor
																						</label>
																					</div>
																					<div class="radio">
																						<label for="radioBknSelangor" class="form-check-label ">
																							<input type="radio" id="radioBknSelangor" name="tempat_mengundi" value="Not In Selangor" class="form-check-input" onclick="bukanSelangorClick()">Not In Selangor
																							<input style="display:none" type="text" name="tempat_mengundi" id="textBukanSelangor_tenant"  class="form-control"   >
																						</label>
																					</div>
																				</div>
																			</div>
																		</div>
																		
																</div>
															</div>
															<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
																<div class="card-body card-block">
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Name</label>
																		</div>
																		<div class="col-12 col-md-9">
																			<input type="text" name="name"   class="form-control" required="" value="<?php echo $_SESSION['name']?>" >
																			<?php if($_SESSION['name'] == ""){?>
																			<span class="help-block">Please insert Spause's name </span>
																			<?php } ?>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">NRIC</label>
																		</div>
																		<div class="col-12 col-md-9">
																			<input type="text" name="ic"   class="form-control" required="" value="<?php echo $_SESSION['ic']?>" onChange="myIC(this.value);" placeholder="xxxxxx-xx-xxxx" pattern="[0-9]{6}-[0-9]{2}-[0-9]{4}" title="xxxxxx-xx-xxxx" >
																			<?php if($_SESSION['ic'] == ""){?>
																			<span class="help-block">Please insert Spause's NRIC </span>
																			<?php } ?>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">D.O.B</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="text" id="dob" name="dob"  class="form-control"  value="<?php echo $_SESSION['dob']?>" required="" readonly>
																			<?php if($_SESSION['dob'] == ""){?>
																			<span class="help-block">Spouse's Date of Birth (DOB): auto </span>
																			<?php } ?>
																		</div>
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Age</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="text" id="age" name="age"  class="form-control"  value="<?php echo $_SESSION['age']?>" required="" readonly>
																			<?php if($_SESSION['age'] == ""){?>
																			<span class="help-block">Spouse's Age: auto </span>
																			<?php } ?>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Gender</label>
																		</div>
																		<div class="col col-md-3">
																			
																				<select id="gender" name="gender" class="form-control form-control" required="" disabled="">
																					<option>-</option>
																					<option value="Male">Male</option>
																					<option value="Female">Female</option>
																				</select>
																			
																		</div>
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Nationality</label>
																		</div>
																		<div class="col col-md-3">
																			
																				<select id="nationality" name="nationality" class="form-control form-control" required="" disabled="">
																					<option>-</option>
																					<option value="Warganegara">Warganegara</option>
																					<option value="Bukan Warganegara">Bukan Warganegara</option>
																				</select>
																		</div>	
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Religion</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="text" id="religion" name="religion"  class="form-control" required="" value="<?php echo $_SESSION['religion']?>" >
																			<?php if($_SESSION['religion'] == ""){?>
																			<span class="help-block">Spouse's Religion </span>
																			<?php } ?>
																		</div>
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Race</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="text" id="race" name="race"  class="form-control" required="" value="<?php echo $_SESSION['race']?>" >
																			<?php if($_SESSION['race'] == ""){?>
																			<span class="help-block">Spouse's Race </span>
																			<?php } ?>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Contact No.</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="text" name="home_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['home_tel_no']?>" onChange="myTelNo(this.value);" placeholder="+6xx-xxxxxxxx" pattern="(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}" title="+6xx-xxxxxxxx" >
																			<span class="help-block">Home Tel. No. </span>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="text" name="mobile_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['mobile_tel_no']?>"  onChange="myPhoneNo(this.value);" placeholder="+6xxx-xxxxxxxx" pattern="(\+?6?01)[0|1|2|3|4|6|7|8|9]\-*[0-9]{7,8}" title="+6xxx-xxxxxxxx" >
																			<span class="help-block">Mobile Tel. No. </span>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">&nbsp;</label>
																		</div>
																		<div class="col-12 col-md-9">
																			<input type="email" name="email_address"   class="form-control"  required="" value="<?php echo $_SESSION['email_address']?>" placeholder="abc@test.com ">
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Polling Place</label>
																			<span class="help-block"><p><i>(Tempat Mengundi)</i></p></span>
																		</div>
																		<div class="col col-md-9">
																			<div class="form-check">
																				<div class="radio">
																					<label for="radioSelangor_pasangan" class="form-check-label ">
																						<input type="radio" id="radioSelangor_pasangan" name="tempat_mengundi_pasangan" value="Selangor" class="form-check-input" onclick="selangorClick_pasangan()">Selangor
																					</label>
																				</div>
																				<div class="radio">
																					<label for="radioBknSelangor_pasangan" class="form-check-label ">
																						<input type="radio" id="radioBknSelangor_pasangan" name="tempat_mengundi_pasangan" value="" class="form-check-input" onclick="bukanSelangorClick_pasangan()">Not in Selangor
																						<input style="display:none" type="text" name="tempat_mengundi_pasangan" id="textBukanSelangor_pasangan"  class="form-control"   >
																					</label>
																				</div>
																			</div>
																		</div>
																	</div>
																	
																</div>
															</div>
															<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">
																<div class="card-body card-block">
																	<div class="row form-group">
																		<div class="col col-md-6">
																			<div class="card">
																				<div class="card-header">
																					<h4>Tenant's Job Information</h4>
																				</div>
																				<div class="card-body">
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Company Name</label>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_tenant_company_name"   class="form-control" required="" value="<?php echo $_SESSION['job_tenant_company_name']?>" placeholder="Please insert company name">
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Mailing Address</label>
																							<span class="help-block"><p><i>(Alamat Surat Menyurat)</i></p></span>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_tenant_line1"   class="form-control" required=""  value="<?php echo $_SESSION['job_tenant_line1']?>" placeholder="P.O. Box/ Company Name/ Unit No for Address Line 1." >
																							
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">&nbsp;</label>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_tenant_line2"   class="form-control"  required="" value="<?php echo $_SESSION['job_tenant_line2']?>" placeholder="Floor/Apartment/Building/Street Name for Address Line 2. ">
																							
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">&nbsp;</label>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_tenant_postcode"   class="form-control"  required="" value="<?php echo $_SESSION['job_tenant_postcode']?>" placeholder="Postcode ">
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_tenant_city"   class="form-control" required="" value="<?php echo $_SESSION['job_tenant_city']?>" placeholder="City  ">
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_tenant_state"   class="form-control" required=""  value="<?php echo $_SESSION['job_tenant_state']?>" placeholder="State ">
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Position</label>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_tenant_position"   class="form-control" required=""  value="<?php echo $_SESSION['job_tenant_position']?>" placeholder="Position" >
																							
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Tenant Salary</label>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="number" id="tenant_gross_salary"  name="tenant_gross_salary" step="0.01" onchange="countTotalGrossSalary();" class="form-control" required="" value="<?php echo $_SESSION['tenant_gross_salary']?>" placeholder="Gross Salary">
																						</div>
																						
																						<div class="col-12 col-md-3">
																							<input type="number" id="tenant_net_salary" name="tenant_net_salary" step="0.01" onchange="countTotalNetSalary();" class="form-control" required="" value="<?php echo $_SESSION['tenant_net_salary']?>" placeholder="Net Salary">
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Contact No.</label>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_tenant_office_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['job_tenant_office_tel_no']?>" onChange="myTelNo(this.value);" placeholder="+6xx-xxxxxxxx" pattern="(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}" title="+6xx-xxxxxxxx" >
																							<span class="help-block">Office Tel. No. </span>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_tenant_fax_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['job_tenant_fax_tel_no']?>"  onChange="myTelNo(this.value);" placeholder="+6xx-xxxxxxxx" pattern="(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}" title="+6xx-xxxxxxxx" >
																							<span class="help-block">Fax No. </span>
																						</div>
																					</div>
																				</div>
																			</div>
																		</div>
																		<div class="col col-md-6">
																			<div class="card">
																				<div class="card-header">
																					<h4>Spouse's Job Information</h4>
																				</div>
																				<div class="card-body">
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Company Name</label>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_spouse_company_name"   class="form-control" required="" value="<?php echo $_SESSION['job_spouse_company_name']?>" placeholder="Please insert company name">
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Mailing Address</label>
																								<span class="help-block"><p><i>(Alamat Surat Menyurat)</i></p></span>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_spouse_line1"   class="form-control" required=""  value="<?php echo $_SESSION['job_spouse_line1']?>" placeholder="P.O. Box/ Company Name/ Unit No for Address Line 1." >
																							
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">&nbsp;</label>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_spouse_line2"   class="form-control"  required="" value="<?php echo $_SESSION['job_spouse_line2']?>" placeholder="Floor/Apartment/Building/Street Name for Address Line 2. ">
																							
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">&nbsp;</label>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_spouse_postcode"   class="form-control"  required="" value="<?php echo $_SESSION['job_spouse_postcode']?>" placeholder="Postcode ">
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_spouse_city"   class="form-control" required="" value="<?php echo $_SESSION['job_spouse_city']?>" placeholder="City  ">
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_spouse_state"   class="form-control" required=""  value="<?php echo $_SESSION['job_spouse_state']?>" placeholder="State ">
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Position</label>
																						</div>
																						<div class="col-12 col-md-9">
																							<input type="text" name="job_spouse_position"   class="form-control" required=""  value="<?php echo $_SESSION['job_spouse_position']?>" placeholder="Position" >
																							
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Spouse Salary</label>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="number" id="spouse_gross_salary" name="spouse_gross_salary" step="0.01" onchange="countTotalGrossSalary();" class="form-control" required="" value="<?php echo $_SESSION['spouse_gross_salary']?>" placeholder="Gross Salary">
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="number" id="spouse_net_salary" name="spouse_net_salary" step="0.01" onchange="countTotalNetSalary();" class="form-control" required="" value="<?php echo $_SESSION['spouse_net_salary']?>" placeholder="Net Salary">
																						</div>
																					</div>
																					<div class="row form-group">
																						<div class="col col-md-3">
																							<label for="text-input" class=" form-control-label">Contact No.</label>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_spouse_office_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['job_spouse_office_tel_no']?>" onChange="myTelNo(this.value);" placeholder="+6xx-xxxxxxxx" pattern="(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}" title="+6xx-xxxxxxxx" >
																							<span class="help-block">Office Tel. No. </span>
																						</div>
																						<div class="col-12 col-md-3">
																							<input type="text" name="job_spouse_fax_tel_no"   class="form-control" required="" value="<?php echo $_SESSION['job_spouse_fax_tel_no']?>"  onChange="myTelNo(this.value);" placeholder="+6xx-xxxxxxxx" pattern="(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}" title="+6xx-xxxxxxxx" >
																							<span class="help-block">Fax No. </span>
																						</div>
																					</div>
																				</div>
																			</div>
																		</div>
																	</div>	
																		
																	
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Tenant Salary</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="number" id="tenant_gross_salary"  name="tenant_gross_salary" step="0.01" onchange="countTotalGrossSalary();" class="form-control" required="" value="<?php echo $_SESSION['tenant_gross_salary']?>" placeholder="Gross Salary">
																		</div>
																		
																		<div class="col-12 col-md-3">
																			<input type="number" id="tenant_net_salary" name="tenant_net_salary" step="0.01" onchange="countTotalNetSalary();" class="form-control" required="" value="<?php echo $_SESSION['tenant_net_salary']?>" placeholder="Net Salary">
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Spouse Salary</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="number" id="spouse_gross_salary" name="spouse_gross_salary" step="0.01" onchange="countTotalGrossSalary();" class="form-control" required="" value="<?php echo $_SESSION['spouse_gross_salary']?>" placeholder="Gross Salary">
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="number" id="spouse_net_salary" name="spouse_net_salary" step="0.01" onchange="countTotalNetSalary();" class="form-control" required="" value="<?php echo $_SESSION['spouse_net_salary']?>" placeholder="Net Salary">
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Total Salary</label>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="number" id="total_gross_salary" name="total_gross_salary" step="0.01"  class="form-control" required="" value="<?php echo $_SESSION['total_gross_salary']?>" placeholder="Gross Salary" disabled>
																		</div>
																		<div class="col-12 col-md-3">
																			<input type="number" id = "total_net_salary" name="total_net_salary" step="0.01"  class="form-control" required="" value="<?php echo $_SESSION['total_net_salary']?>" placeholder="Net Salary" disabled>
																		</div>
																	</div>
																</div>	
															</div>
															<div class="tab-pane fade" id="nav-selangorku" role="tabpanel" aria-labelledby="nav-selangorku-tab">
																<div class="card-body card-block">
																<div class="row form-group">
																	<div class="col col-md-3">
																		<label for="text-input" class=" form-control-label">Tenant</label>
																	</div>
																	<div class="col col-md-9">
																		<div class="form-check">
																			<div class="radio">
																				<label for="radiobelumMemohon" class="form-check-label ">
																					<input type="radio" id="radiobelumMemohon" name="permohonan_rsku" value="Belum Memohon" class="form-check-input" onclick="belumMemohon_click()">Not Apply Yet
																				</label>
																			</div>
																			<div class="radio" class="col-12 col-md-9">
																				<label for="radiotelahMemohon" class="form-check-label ">
																					<input type="radio" id="radiotelahMemohon" name="permohonan_rsku" value="Telah Memohon" class="form-check-input" onclick="telahMemohon_click()">Applied
																					<span id="textLokasiRSKU" style="display:none" >Lokasi yang dipohon: <input type="text" name="lokasi_rsku"   class="form-control"  size="50" ></span>
																				</label>
																				<div class="row form-group" id="statuspermohonan" style="display:none">
																					<div class="col col-md-3">
																						<label for="text-input" class=" form-control-label">&nbsp;</label>
																					</div>
																					<div class="col col-md-9">
																						<div class="form-check">
																							<div class="col-12 col-md-9">
																								<label for="text-input" class=" form-control-label">Status Permohonan</label>
																							</div>
																							<div class="col col-md-9">
																								<div class="form-check">
																									<div class="radio">
																										<label for="status_permohonan_menunggu" class="form-check-label ">
																											<input type="radio" id="status_permohonan_menunggu" name="status_permohonan" value="Menunggu" class="form-check-input" onclick="statusMenunggu_click()">Menunggu
																										</label>
																									</div>
																									<div class="radio" class="col-12 col-md-9">
																										<label for="status_permohonan_berjaya" class="form-check-label ">
																											<input type="radio" id="status_permohonan_berjaya" name="status_permohonan" value="Berjaya" class="form-check-input" onclick="statusBerjaya_click()">Berjaya
																											<span id="jangkaanSiapProject" style="display:block" >Jangkaan Siap Projek<input type="month" id="monthYear_jangkaanSiapProject" name="monthYear_jangkaanSiapProject" min="2018-03" value="<?php echo date("m/Y")?>" class="form-control"></span>
																										</label>
																									</div>
																									<div class="radio" class="col-12 col-md-9">
																										<label for="status_permohonan_tidakberjaya" class="form-check-label ">
																											<input type="radio" id="status_permohonan_tidakberjaya" name="status_permohonan" value="Tidak Berjaya" class="form-check-input" onclick="statusTidakBerjaya_click()">Tidak Berjaya
																										</label>
																									</div>
																									<div  id="statusTakBerjaya_display" style="display:none">
																										<div class="col col-md-9">
																											<div class="form-check">
																												<div class="radio" class="col-12 col-md-3">
																													<label for="tidakberjayaLoan" class="form-check-label ">
																														<input type="radio" id="tidakberjaya_Loan" name="status_permohonan" value="Gagal Pinjaman Bank" class="form-check-input" onclick="tidakberjayaLoan_click()">Gagal Pinjaman Bank
																													</label>
																												</div>
																												<div class="radio" class="col-12 col-md-3">
																													<label for="tidakberjayaAdaRumah" class="form-check-label ">
																														<input type="radio" id="tidakberjaya_AdaRumah" name="status_permohonan" value="Telah Memiliki Rumah" class="form-check-input" onclick="tidakberjayaAdaRumah_click()">Telah Memiliki Rumah
																													</label>
																												</div>
																												<div class="radio" class="col-12 col-md-3">
																													<label for="tidakberjayaLainlain" class="form-check-label ">
																														<input type="radio" id="tidakberjaya_Lainlain" name="status_permohonan" value="" class="form-check-input" onclick="tidakberjayaLainlain_click()">Lain-lain
																														<span id="textLokasiRSKU" style="display:none" >Lokasi yang dipohon: <input type="text" name="lokasi_rsku"   class="form-control"   ></span>
																													</label>
																												</div>
																											</DIV>
																										</DIV>
																									</div>
																								</div>
																							</div>
																						</div>
																					</div>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
																
															</div>
															</div>
															<div class="tab-pane fade" id="nav-harta" role="tabpanel" aria-labelledby="nav-harta-tab">
																<div class="card-body card-block">
																
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Home</label>
																			<span class="help-block"><p><i>(Rumah Kediaman)</i></p></span>
																		</div>
																		<div class=" col-md-9">
																			<div class="form-check">
																				<div class="radio">
																					<label for="statusAdaRumah" class="form-check-label ">
																						<input type="radio" id="statusAdaRumah" name="status_rumah" value="ada_rumah" class="form-check-input" onclick="adaRumahClick()">Yes
																						<div id="info_rumah" style="display:none">
																							<label for="text-input" class=" form-control-label">Type Of House</label>
																							<span class="help-block"><p><i>(Jenis Rumah: Bungalow /  Teres / Apartment)</i></p></span>
																							<input  type="text" name="jenis_rumah" id="jenis_rumah" size="40"  class="form-control"   >
																							<label for="text-input" class=" form-control-label">Address</label>
																							<span class="help-block"><p><i>(Alamat Rumah)</i></p></span>
																							<textarea name="alamat_rumah" id="alamat_rumah" rows="4" cols="30" placeholder="Alamat rumah..." class="form-control"></textarea>
																						</div>
																					</label>
																				</div>
																				<div class="radio">
																					<label for="statusTiadaRumah" class="form-check-label ">
																						<input type="radio" id="statusTiadaRumah" name="status_rumah" value="tiada_rumah" class="form-check-input" onclick="tiadaRumahClick()">No
																						
																					</label>
																				</div>
																			</div>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Private Vehicles</label>
																			<span class="help-block"><p><i>(Kenderaan Persendirian)</i></p></span>
																		</div>
																		<div class=" col-md-9">
																			<div class="form-check">
																				<div class="radio">
																					<label for="statusAdaKenderaan" class="form-check-label ">
																						<input type="radio" id="statusAdaKenderaan" name="status_kenderaan" value="ada_kenderaan" class="form-check-input" onclick="adaKenderaanClick()">Yes
																						<div id="info_kenderaan" style="display:none">
																							<table >
																								<thead>
																									<th>
																										Type Of Vehicle
																										<i>(Jenis Kenderaan)</i>
																									</th>
																									<th>
																										Plate No.
																										<i>(No. Pendaftaran)</i>
																									</th>
																									<th>
																										Ownership
																										<i>(Pemilikan)</i>
																									</th>
																									<th></th>
																								</thead>
																								<tbody id="input_unitNo">
																									<tr>
																										<td><input  type="text" name="jenis_kenderaan[]" id="jenis_kenderaan" size="40"  class="form-control" ></td>
																										<td><input  type="text" name="noplate_kenderaan[]" id="noplate_kenderaan" size="40"  class="form-control" ></td>
																										<td><input  type="text" name="pemilikan_kenderaan[]" id="pemilikan_kenderaan" size="40"  class="form-control" ></td>
																										<td>
																											<span class="help-block">
																												<a href="#"  alt="Add More Unit No." onclick="addNewLinkAcc();" id="add"><i class="fas fa-plus-square" ></a></i>
																											</span>
																										</td>
																									</tr>
																								</tbody>
																							</table>
																						</div>
																					</label>
																				</div>
																				<div class="radio">
																					<label for="statusTiadaKenderaan" class="form-check-label ">
																						<input type="radio" id="statusTiadaKenderaan" name="status_kenderaan" value="tiada_kenderaan" class="form-check-input" onclick="tiadaKenderaanClick()">No
																						
																					</label>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
															</div>
															<div class="tab-pane fade" id="nav-kesihatan" role="tabpanel" aria-labelledby="nav-kesihatan-tab">
																<div class="card-body card-block">
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Health Info</label>
																		</div>
																		<div class=" col-md-9">
																			<div class="form-check">
																				<div class="radio">
																					<label for="statusAdaMasalahKesihatan" class="form-check-label ">
																						<input type="radio" id="statusAdaMasalahKesihatan" name="masalah_kesihatan" value="ada_masalahkesihatan" class="form-check-input" onclick="adaMasalahKesihatanClick()">Yes
																						<div id="info_kesihatan" style="display:none">
																							<label for="text-input" class=" form-control-label">Type of Disease</label>
																							<input  type="text" name="jenis_penyakit" id="jenis_penyakit" size="40"  class="form-control"   >
																							
																							<input type="file" name="proofDiseaseFromClinic" id="proofDiseaseFromClinic" class="form-control">
																							<span class="help-block">Please include proof from the government health hospital/clinic <i>(Sila sertakan bukti dari hospital/klinik kesihatan kerajaan)</i></span>
																						</div>
																					</label>
																				</div>
																				<div class="radio">
																					<label for="statusTiadaMasalahKesihatan" class="form-check-label ">
																						<input type="radio" id="statusTiadaMasalahKesihatan" name="masalah_kesihatan" value="tiada_masalahkesihatan" class="form-check-input" onclick="tiadaMasalahKesihatanClick()">No
																					</label>
																				</div>
																			</div>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-3">
																			<label for="text-input" class=" form-control-label">Disability <i>(Kecacatan)</i></label>
																		</div>
																		<div class=" col-md-9">
																			<div class="form-check">
																				<div class="radio">
																					<label for="statusAdaKecacatan" class="form-check-label ">
																						<input type="radio" id="statusAdaKecacatan" name="kecacatan" value="ada_kecacatan" class="form-check-input" onclick="adaKecacatanClick()">Yes
																						<div id="info_kecacatan" style="display:none">
																							<label for="text-input" class=" form-control-label">Please State Tenant's Disability <i>(Sila Nyatakan)</i></label>
																							<input  type="text" name="jenis_kecacatan" id="jenis_kecacatan" size="40"  class="form-control"   >
																							<input type="file" name="proofOKUCard" id="proofOKUCard" class="form-control">
																							<span class="help-block">Please attach a copy of the Disabled Persons card (OKU Card) <i>(Sila lampirkan salinan kad Orang Kelainan Upaya (OKU))</i></span>
																						</div>
																					</label>
																				</div>
																				<div class="radio">
																					<label for="statusTiadaKecacatan" class="form-check-label ">
																						<input type="radio" id="statusTiadaKecacatan" name="kecacatan" value="tiada_kecacatan" class="form-check-input" onclick="tiadaKecacatanClick()">No
																					</label>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
															</div>
															<div class="tab-pane fade" id="nav-keluarga" role="tabpanel" aria-labelledby="nav-keluarga-tab">
																<div class="card-body card-block">
																	<div class="row form-group">
																		<div class="col col-md-12">
																			<label for="text-input" class=" form-control-label">Family member's Info (Please attach the Copy of IC and latest Payslip)</label>
																		</div>
																		<div class=" col-md-12">
																			<div id="butiranTanggungan" class="form-check">
																				<table >
																					<thead>
																						<th>Name</th>
																						<th>My Kad / My Kid </th>
																						<th>Relationship</th>
																						<th>Occupation</th>
																						<th>Salary (RM)</th>
																						<th>Upload Copy of My Kad / My Kid </th>
																						<th>Upload Latest PaySlip</th>
																						<th></th>
																					</thead>
																					<tbody id="infoButiranTanggungan">
																						<tr>
																							<td><input  type="text" name="ahliKeluarga_nama[]" id="ahliKeluarga_nama" size="40"  class="form-control" ></td>
																							<td><input  type="text" name="ahliKeluarga_ic[]" id="ahliKeluarga_ic"  size="40"  class="form-control" ></td>
																							<td><input  type="text" name="ahliKeluarga_hubungan[]" id="ahliKeluarga_hubungan" size="40"  class="form-control" ></td>
																							<td><input  type="text" name="ahliKeluarga_statusbekerja[]" id="ahliKeluarga_statusbekerja" size="40"  class="form-control" ></td>
																							<td><input  type="number" step="0.01" name="ahliKeluarga_gaji[]" id="ahliKeluarga_gaji"   class="form-control" ></td>
																							<td><input type="file" name="upload_proven_ahliKeluarga_ic[]" style="float:right;text-align: right;" class="form-control"></td>
																							<td><input type="file" name="upload_proven_ahliKeluarga_salary[]" style="float:right;text-align: right;" class="form-control"></td>
																							<td>
																								<span class="help-block">
																									<a href="#"  alt="Add More Unit No." onclick="addNewTanggungan();" id="add"><i class="fas fa-plus-square" ></a></i>
																								</span>
																							</td>
																						</tr>
																					</tbody>
																				</table>
																			</div>
																		</div>
																	</div>
																	<div class="row form-group">
																		<div class="col col-md-12">
																			<label for="text-input" class=" form-control-label">Other Commitments</label>
																		</div>
																		<div class=" col-md-9">
																			<div class="form-check">
																				<div class="radio">
																					<label for="statusYesCommitments" class="form-check-label ">
																						<input type="radio" id="statusYesCommitments" name="status_Commitments" value="yes" class="form-check-input" onclick="yesCommitmentsClick()">Yes
																						<div id="info_Commitments" style="display:none">
																							<label for="text-input" class=" form-control-label">Please justify the Commitments</label>
																							<!--<input  type="text" name="typeOfCommitments" id="typeOfCommitments" size="40"  class="form-control"   >-->
																							<textarea name="typeOfCommitments" id="typeOfCommitments" rows="4" cols="30" placeholder="Please justify your commitments here..." class="form-control"></textarea>
																						</div>
																					</label>
																				</div>
																				<div class="radio">
																					<label for="statusNoCommitments" class="form-check-label ">
																						<input type="radio" id="statusNoCommitments" name="status_Commitments" value="no" class="form-check-input" onclick="noCommitmentsClick()">No
																						
																					</label>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
															</div>
														</div>

													</div>
												</div>
											</div>
										<!--</div>-->
									</div>
								
							
								
								
								
								
								
								
								
								<div  id="syarikatClick" style='display:none;'>
										<div class="card-header">
											<strong>Company Info</strong> Form
										</div>
										<div class="card-body card-block">
											<?php 	
												if($_POST['projectName'] != ""){
													$_SESSION['projectName']=$_POST['projectName'];
													$_SESSION['locationName'] = "";
													$_SESSION['propertiesParentsUnit'] = "";
												 }
												else{
													//echo "project name 0";
												$_SESSION['projectName']= "";
												$_SESSION['locationName'] = "";
												$_SESSION['propertiesParentsUnit'] = "";
												}
											
												if($projectLocation != ""){
													$_SESSION['projectName']= $projectName;
													$_SESSION['locationName']= $locationName;
												}?>
											<form action="" method="post" class="form-horizontal">
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">Project</label>
													</div>
													<div class="col-12 col-md-9">
														<input type="text" id="text-input" class="form-control" list="projectName" name="projectName" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['projectName']?>" placeholder="Select Project"/>
														<datalist id="projectName">
														<?php
															if($_SESSION["username"] != "admin"){
																
																$sqlProject = "select EL.location_id, locations.location_name, locations.project_id, projects.project_name from extra_locations as EL 
																				inner join locations on locations.id = EL.location_id 
																				left join projects on locations.project_id = projects.id 
																				where staff_id = '".$_SESSION['staff_id']."' group by `projects`.`project_name` ORDER BY `projects`.`project_name` ASC  
																				";
															}
															else if($_SESSION["username"] == "admin"){
																
																 $sqlProject = "select * from projects where (project_code <> '000') order by project_name ASC ";
																
															}
															$runProject = mysqli_query($link, $sqlProject);
															if($runProject === FALSE){
																die(mysqli_error($link));
															}
															while($resultProject = mysqli_fetch_array($runProject)){
																
																$project_name = $resultProject["project_name"];
																if($_SESSION["username"] != "admin"){
																	$project_name = $resultProject["project_name"];
																}
																	?>
																	
																	<option value="<?php echo strtoupper($project_name); ?>">
																	<?php
															}
														?>
														</datalist>
														<?php if($_SESSION['projectName'] == ""){?>
														<span class="help-block">Please choose project</span>
														<?php } ?>
													</div>
												</div>
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">Location</label>
													</div>
													<div class="col-12 col-md-9">
														
														<input type="text" id="text-input" class="form-control" list="locationName" name="locationName" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['locationName']?>" placeholder="Select Location" autocomplete="off"/>
														<datalist id="locationName">
														<?php
															if($_SESSION["username"] <> "admin"){
																$sqlLocations = "select EL.location_id, locations.location_name, projects.project_name from extra_locations as EL 
																		inner join locations on locations.id = EL.location_id 
																		left join projects on locations.project_id = projects.id 
																		where projects.project_name = '".$_SESSION["projectName"]."' and staff_id = '".$_SESSION['staff_id']."'";
															}
															else if($_SESSION["username"] == "admin"){
																//ECHO $sqlLocations = "SELECT * FROM `locations`  ";
																 $sqlLocations = "SELECT id, 
																						location_code , 
																						location_name FROM `locations`
																						where project_id = '".$_SESSION["project_id"]. "' 
																						ORDER BY `location_name` ASC ";

															}
															
															$runLocations = mysqli_query($link, $sqlLocations);
															if($runLocations === FALSE){
																die(mysqli_error($link));
															}
															while($resultLocations = mysqli_fetch_array($runLocations)){
																$location_id = $resultLocations["id"];
																$location_code = $resultLocations["location_code"];
																$location_name = $resultLocations["location_name"];
																
																	?>
																	
																<option value="<?php echo strtoupper($location_name); ?>">
																<?php
															}
														?>
														</datalist>
														<?php if($_SESSION['locationName'] == ""){?>
														<span class="help-block">Please choose location</span>
														<?php } ?>
													</div>
												</div>
												<input type="hidden" name="projectLocation" value="<?php echo $_SESSION["projectLocation"]?>">
												<input type="hidden" name="menu" value="<?php echo $_SESSION["menu"]?>">
												<input type="hidden" name="submenu" value="<?php echo $_SESSION["submenu"]?>">
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">Parent's Unit No.</label>
													</div>
													<div class="col-12 col-md-9">
														<?php $_SESSION['propertiesParentsUnit'] = $_POST["propertiesParentsUnit"]?>
														<input class="form-control" type="text" list="propertiesParentsUnit" name="propertiesParentsUnit" onChange="javascript: submit();" size="50" value="<?php echo $_SESSION['propertiesParentsUnit']?>" placeholder="Select Parent's Unit" autocomplete="off"/>
														<datalist id="propertiesParentsUnit">
														<?php
															if($_SESSION["username"] <> "admin"){
																
																	$sqlParentsUnit = "select properties.* from properties 
																		inner join locations on properties.location_id = locations.id 
																		where locations.location_name = '".$_SESSION["locationName"]."' 
																		and locations.project_id = ".$_SESSION["project_id"]."
																		";
															}
															else if($_SESSION["username"] == "admin"){
																
																echo $sqlParentsUnit = "select properties.* from properties 
																		inner join locations on properties.location_id = locations.id 
																		where locations.location_name = '".$_SESSION["locationName"]."' 
																		and locations.project_id = ".$_SESSION["project_id"]."
																		";
															}
															
															$runParentsUnit  = mysqli_query($link, $sqlParentsUnit );
														if($runParentsUnit === FALSE){
															die(mysqli_error($link));
														}
														
														
															while($resultParentsUnit = mysqli_fetch_array($runParentsUnit)){
																$propertiesID = $resultParentsUnit["id"];
																$properties_parents_unit = $resultParentsUnit["unit_no"];
																
																	?>
																	
																<option value="<?php echo strtoupper($properties_parents_unit); ?>">
																<?php
															}
															
														?>
														</datalist>
														
													</div>
												</div>
												<input type="hidden" name="sqlParentsUnit" value="<?php echo $sqlParentsUnit;?>">
												<input type="hidden" name = "location_id_selected" value="<?php echo $location_id_selected?>">
												<input name="staff_id" type="hidden" size="20" value="<?php echo htmlspecialchars($_SESSION["staff_id"]); ?>">
												<?php 
													$sqlLocationID = "select id from locations where location_name = '".$_SESSION['locationName']."'";
													$runLocationID  = mysqli_query($link, $sqlLocationID );
													if($runLocationID === FALSE){
														die(mysqli_error($link));
													}
													$resultLocationID = mysqli_fetch_assoc($runLocationID);
													$location_id_selected = $resultLocationID["id"];
													$_SESSION['location_id_selected']=$location_id_selected;
													?>
													<input type="hidden" name = "projectName" value="<?php echo $_GET["projectName"]?>">
													<input type="hidden" name = "project_id" value="<?php echo $projectID_selected?>">
													<input type="hidden" name = "location_id_selected" value="<?php echo $location_id_selected?>">
													<input type="hidden" name="property_id" value="<?php echo $property_id?>">
												<div >
													<div class="row form-group">
														<div class="col col-md-3">
															<label for="text-input" class=" form-control-label">Child's Unit No.</label>
														</div>
														<div class="col-12 col-md-6">
															<?php $_SESSION['propertiesChildsUnit'] = $_POST["propertiesChildsUnit"]?>
															<input class="form-control" type="text" list="propertiesChildsUnit" name="propertiesChildsUnit"  size="50" value="<?php echo $_SESSION['propertiesChildsUnit']?>" placeholder="Select Child's Unit" autocomplete="off"/>
															<datalist id="propertiesChildsUnit">
															<?php 
																//sql get parents info from selected parents unit
																$sqlParentsUnit = "";
																if($_POST["sqlParentsUnit"] != "" && $_SESSION["propertiesParentsUnit"] != ""){
																	echo $sqlParentsUnit = $_POST["sqlParentsUnit"] . " and properties.unit_no = '".$_SESSION["propertiesParentsUnit"]."' ";
																	
																	$runParentsUnit = mysqli_query($link, $sqlParentsUnit );
																	if($runParentsUnit === FALSE){
																		die(mysqli_error($link));
																	}
																	$resultParentsUnit = mysqli_fetch_assoc($runParentsUnit);
																	$parentsUnitID = $resultParentsUnit["id"];
																	
																	//sql child unit
																	echo $sqlChildInfo = "select * from properties_unit where property_id = $parentsUnitID and unit_status = 'enable' ";
																	$runChildInfo = mysqli_query($link, $sqlChildInfo );
																	if($runChildInfo === FALSE){
																		die(mysqli_error($link));
																	}
																	
																	while($resultChildInfo = mysqli_fetch_array($runChildInfo)){
																		$unit_no = $resultChildInfo["unit_no"];
																		$childUnitID = $resultChildInfo["id"];
																		?>
																		<option value="<?php echo $unit_no; ?>">
																	<?php } 
																}?>
																
															</datalist>
														</div>
													</div>
												</div>
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">Start Rental</label>
													</div>
													<div class="col-12 col-md-6">
														<input type="date" name="start_rent"   class="form-control"  value="<?php echo $_SESSION['start_rent']?>" autocomplete="off" >
													</div>
												</div>
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">End Rental</label>
													</div>
													<div class="col-12 col-md-6">
														<input type="date" name="end_rent"   class="form-control"  value="<?php echo $_SESSION['start_rent']?>" autocomplete="off" >
													</div>
												</div>
												<div class="row form-group">
													<div class="col col-md-3">
														<label for="text-input" class=" form-control-label">Register Type</label>
													</div>
													<div class="col col-md-9">
														<div class="form-check">
															<div class="radio">
																<label for="radio1" class="form-check-label ">
																	<input type="radio" id="radio1" name="type_reg" value="Individu" class="form-check-input">Individual
																</label>
															</div>
															<div class="radio">
																<label for="radio2" class="form-check-label ">
																	<input type="radio" id="radio2" name="type_reg" value="Syarikat" class="form-check-input">Company
																</label>
															</div>
															
														</div>
													</div>
												</div>
										</div>
									</div>	
									<div class="card-footer"  id="footerDisplay" style='display:none;float:right;'>
											<button type="submit" class="btn btn-primary btn-sm">
												<i class="fa fa-dot-circle-o"></i> Save
											</button>
											<button type="reset" class="btn btn-danger btn-sm">
												<i class="fa fa-ban"></i> Reset
											</button>
									</div>
																		
								<!--</div>-->
								
							</div>	
						</form>

						</div>
							
							
            <!--main content middle end-->
			<!--main content bottom start-->
				<?PHP include "main-content-bottom.php";?>
			<!--main content bottom end-->
			
            <!-- END MAIN CONTENT-->
            <!-- END PAGE CONTAINER-->
        </div>
    </div>
    <?PHP include "footerLink.php";?>
</body>
</html>
<!-- end document-->

<script>


function adaRumahClick(){
  document.getElementById('info_rumah').style.display ='block';
  document.getElementById("jenis_rumah").setAttribute("required","required");
  document.getElementById("alamat_rumah").setAttribute("required","required");
}
function tiadaRumahClick(){
  document.getElementById('info_rumah').style.display ='none';
  document.getElementById("jenis_rumah").removeAttribute("required");
  document.getElementById("alamat_rumah").removeAttribute("required");
  document.getElementById("jenis_rumah").value = "";
  document.getElementById("alamat_rumah").value = "";
 // document.getElementById("monthYear_jangkaanSiapProject_1").value = "";
  
}


document.getElementById("skipParentsUnit").onclick = function() {skipParentsUnit()};

function skipParentsUnit() {
	if(document.getElementById("propertiesParentsUnit_input").disabled === true){
		document.getElementById("propertiesParentsUnit_input").removeAttribute("disabled");
		document.getElementById("propertiesParentsUnit_input").setAttribute("required","required");
	}
	else{
		document.getElementById("propertiesParentsUnit_input").setAttribute("disabled","disabled");
		document.getElementById("propertiesParentsUnit_input").removeAttribute("required");
		
	}
		
}
function addNewTanggungan(){
	//alert();
	var divWrap = document.createElement('tr');
	var div1 = document.createElement('td');
	var div2 = document.createElement('td');
	var div3 = document.createElement('td');
	var div4 = document.createElement('td');
	var div5 = document.createElement('td');
	var div6 = document.createElement('td');
	var div7 = document.createElement('td');
	var div8 = document.createElement('td');
    //divWrap.className = 'row form-group';
    //div1.className = 'col col-md-3';
    //div2.className = 'col-12 col-md-6';
    //div3.className = 'col col-md-3';
	divWrap.id = 'divRow';
	div8.id = 'deleteButton_ahliKeluarga';
	
	var div1_html = "<input  type='text' name='ahliKeluarga_nama[]' id='ahliKeluarga_nama' size='40'  class='form-control' >";
	var div2_html = "<input  type='text' name='ahliKeluarga_ic[]' id='ahliKeluarga_ic' size='40'  class='form-control' >";
	var div3_html = "<input  type='text' name='ahliKeluarga_hubungan[]' id='ahliKeluarga_hubungan'   class='form-control' >";
	var div4_html = "<input  type='text' name='ahliKeluarga_statusbekerja[]' id='ahliKeluarga_statusbekerja' size='40'  class='form-control' >";
	var div5_html = "<input  type='number' step='0.01' name='ahliKeluarga_gaji[]' id='ahliKeluarga_gaji' size='40'  class='form-control' >";
	var div6_html = "<input  type='file' name='upload_proven_ahliKeluarga_ic[]'  size='40'  class='form-control' >";
	var div7_html = "<input  type='file' name='upload_proven_ahliKeluarga_salary[]'  size='40'  class='form-control' >";
	var div8_html = "<span class='help-block'><a href='#' id='del' onclick='deleteRow_ahlikeluarga(this)'><i class='fas fa-minus-square' ></a></i></span>";
	
	div1.innerHTML = div1_html;
	div2.innerHTML = div2_html;
	div3.innerHTML = div3_html;
	div4.innerHTML = div4_html;
	div5.innerHTML = div5_html;
	div6.innerHTML = div6_html;
	div7.innerHTML = div7_html;
	div8.innerHTML = div8_html;
	
	divWrap.append(div1,div2,div3,div4,div5,div6,div7,div8);
	document.getElementById("infoButiranTanggungan").appendChild(divWrap);	
	
}
function deleteRow_ahlikeluarga(row){ 
	
	var x = document.querySelectorAll("#deleteButton_ahliKeluarga");
	
	var remove = function(){
		this.parentNode.remove();
	};

	var button = document.querySelectorAll('#del');
	for (var i = 0, len = x.length; i < len; i++) {
		x[i].addEventListener('click', remove, false);
	}


}

function addNewLinkAcc(){
	//alert();
	var divWrap = document.createElement('tr');
	var div1 = document.createElement('td');
	var div2 = document.createElement('td');
	var div3 = document.createElement('td');
	var div4 = document.createElement('td');
    //divWrap.className = 'row form-group';
    //div1.className = 'col col-md-3';
    //div2.className = 'col-12 col-md-6';
    //div3.className = 'col col-md-3';
	divWrap.id = 'divRow';
	div4.id = 'deleteButton';
	
	var div1_html = "<input  type='text' name='jenis_kenderaan[]' id='jenis_kenderaan' size='40'  class='form-control' >";
	var div2_html = "<input  type='text' name='noplate_kenderaan[]' id='noplate_kenderaan' size='40'  class='form-control' >";
	var div3_html = "<input  type='text' name='pemilikan_kenderaan[]' id='pemilikan_kenderaan' size='40'  class='form-control' >";
	var div4_html = "<span class='help-block'><a href='#' id='del' onclick='deleteRow(this)'><i class='fas fa-minus-square' ></a></i></span>";
	
	div1.innerHTML = div1_html;
	div2.innerHTML = div2_html;
	div3.innerHTML = div3_html;
	div4.innerHTML = div4_html;
	
	divWrap.append(div1,div2,div3,div4);
	document.getElementById("input_unitNo").appendChild(divWrap);	
	
}
function deleteRow(row){ 
	
	var x = document.querySelectorAll("#deleteButton");
	
	var remove = function(){
		this.parentNode.remove();
	};

	var button = document.querySelectorAll('#del');
	for (var i = 0, len = x.length; i < len; i++) {
		x[i].addEventListener('click', remove, false);
	}


}

function adaKecacatanClick(){
	document.getElementById('info_kecacatan').style.display ='block';
	document.getElementById("proofOKUCard").setAttribute("required","required");
}
function tiadaKecacatanClick(){
	document.getElementById('info_kecacatan').style.display ='none';
	document.getElementById("proofOKUCard").removeAttribute("required");
	document.getElementById("proofOKUCard").value="";
}

function adaMasalahKesihatanClick(){
	document.getElementById('info_kesihatan').style.display ='block';
	document.getElementById("proofDiseaseFromClinic").setAttribute("required","required");
}
function tiadaMasalahKesihatanClick(){
	document.getElementById('info_kesihatan').style.display ='none';
	document.getElementById("proofDiseaseFromClinic").removeAttribute("required");
	document.getElementById("proofDiseaseFromClinic").value="";
}

function adaKenderaanClick(){
	document.getElementById('info_kenderaan').style.display ='block';
}

function tiadaKenderaanClick(){
	document.getElementById('info_kenderaan').style.display ='none';
}

function yesCommitmentsClick(){
  document.getElementById('info_Commitments').style.display ='block';
  document.getElementById("typeOfCommitments").setAttribute("required","required");
  
}
function noCommitmentsClick(){
  document.getElementById('info_Commitments').style.display ='none';
  document.getElementById("typeOfCommitments").removeAttribute("required");
}

function adaRumahClick(){
  document.getElementById('info_rumah').style.display ='block';
  document.getElementById("jenis_rumah").setAttribute("required","required");
  document.getElementById("alamat_rumah").setAttribute("required","required");
}
function tiadaRumahClick(){
  document.getElementById('info_rumah').style.display ='none';
  document.getElementById("jenis_rumah").removeAttribute("required");
  document.getElementById("alamat_rumah").removeAttribute("required");
  document.getElementById("jenis_rumah").value = "";
  document.getElementById("alamat_rumah").value = "";
 // document.getElementById("monthYear_jangkaanSiapProject_1").value = "";
  
}
function belumMemohon_click(){
  document.getElementById('statuspermohonan').style.display ='none';
  document.getElementById('textLokasiRSKU').style.display ='none';
  document.getElementById("textLokasiRSKU").removeAttribute("required");
  document.getElementById("status_permohonan_menunggu").checked = false;
  document.getElementById("status_permohonan_berjaya").checked = false;
  document.getElementById("status_permohonan_tidakberjaya").checked = false;
  document.getElementById("tidakberjayaLoan").checked = false;
  document.getElementById("tidakberjayaAdaRumah").checked = false;
  document.getElementById("monthYear_jangkaanSiapProject").value = "";
}
function telahMemohon_click(){
  document.getElementById('statuspermohonan').style.display ='block';
  document.getElementById('textLokasiRSKU').style.display ='block';
  document.getElementById("textLokasiRSKU").setAttribute("required","required");
}
function statusMenunggu_click(){
  document.getElementById('statuspermohonan').style.display ='block';
  document.getElementById('textLokasiRSKU').style.display ='block';
  document.getElementById("textLokasiRSKU").removeAttribute("required");
   document.getElementById("monthYear_jangkaanSiapProject").value = "";
}
function statusBerjaya_click(){ alert();
  document.getElementById('statuspermohonan').style.display ='block';
  document.getElementById('textLokasiRSKU').style.display ='none';
  document.getElementById('jangkaanSiapProject').style.display ='none';
  document.getElementById("textLokasiRSKU").removeAttribute("required");
}
function statusTidakBerjaya_click(){
  document.getElementById('statuspermohonan').style.display ='block';
  document.getElementById('textLokasiRSKU').style.display ='block';
  document.getElementById('statusTakBerjaya_display').style.display ='block';
  document.getElementById("textLokasiRSKU").removeAttribute("required");
  document.getElementById("monthYear_jangkaanSiapProject").value = "";
}
function tidakberjayaLoan_click(){
	document.getElementById("monthYear_jangkaanSiapProject").value = "";
  document.getElementById("status_permohonan_tidakberjaya").checked = true;
}
function tidakberjayaAdaRumah_click(){
	document.getElementById("monthYear_jangkaanSiapProject").value = "";
}
function tidakberjayaLainlain_click(){
	document.getElementById("monthYear_jangkaanSiapProject").value = "";
}

document.getElementById("status_permohonan_berjaya").onclick = function() {myFunction()};
function myfunction(){
	alert();
	 document.getElementById('sebabLainLain_show').style.display ='none';
}

function sebabLainLain_click(){ alert();
	//document.getElementById("sebabLainLain_show").style.display ='block';
	 document.getElementById('sebabLainLain_show').style.display ='block';
}
function sebabLoan_click(){
	document.getElementById("sebabLainLain_show").style.display ='none';
}
function sebabAdaRumah_click(){
	document.getElementById("sebabLainLain_show").style.display ='none';
}

function countTotalGrossSalary(){
	 var total=0;
	 var tenant_gross_salary = document.getElementById("tenant_gross_salary").value;
	 var spouse_gross_salary = document.getElementById("spouse_gross_salary").value;
	 
	 if(tenant_gross_salary == "") 
		 tenant_gross_salary=0;
	 if(spouse_gross_salary == "") 
		 spouse_gross_salary=0;
	 
	 total= parseFloat(tenant_gross_salary) +  parseFloat(spouse_gross_salary);
	
	 document.getElementById("total_gross_salary").value = total.toFixed(2);
	 
}

function countTotalNetSalary(){
	 var total=0;
	 var tenant_net_salary = document.getElementById("tenant_net_salary").value;
	 var spouse_net_salary = document.getElementById("spouse_net_salary").value;
	 
	  if(tenant_net_salary == "") 
		 tenant_net_salary=0;
	 if(spouse_net_salary == "") 
		 spouse_net_salary=0;
	 
	 total= parseFloat(tenant_net_salary) +  parseFloat(spouse_net_salary);
	
	 document.getElementById("total_net_salary").value = total.toFixed(2);
	 
}

function individuClick(){
  document.getElementById('individuClick').style.display ='block';
  document.getElementById('footerDisplay').style.display ='block';
  document.getElementById('syarikatClick').style.display ='none';
}
function syarikatClick(){
  document.getElementById('individuClick').style.display ='none';
  document.getElementById('syarikatClick').style.display ='block';
  document.getElementById('footerDisplay').style.display ='block';
}

function selangorClick(){
  document.getElementById('textBukanSelangor_tenant').style.display ='none';
  document.getElementById("textBukanSelangor_tenant").setAttribute("required","required");
 
}
function bukanSelangorClick(){
  document.getElementById('textBukanSelangor_tenant').style.display ='block';
  document.getElementById("textBukanSelangor_tenant").removeAttribute("required");
}
function selangorClick_pasangan(){
  document.getElementById('textBukanSelangor_pasangan').style.display ='none';
  document.getElementById("textBukanSelangor_pasangan").setAttribute("required","required");
 
}
function bukanSelangorClick_pasangan(){
  document.getElementById('textBukanSelangor_pasangan').style.display ='block';
  document.getElementById("textBukanSelangor_pasangan").removeAttribute("required");
}


function rentalenddate(){
	var x = document.getElementById("start_rent").value;
	var input = document.getElementById("end_rent");
    input.setAttribute("min", x);
}

function getAge(dateString) 
{
    var today = new Date();
    var birthDate = new Date(dateString);
    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) 
    {
        age--;
    }
    return age;
}
function myIC(icnumber){ 
	var re = new RegExp(/(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))-([0-9]{2})-([0-9]{4})/g);
	if (re.test(icnumber)) {
		
		icnumber_6front = icnumber.split("-")[0];
		var year = icnumber_6front.substring(0,2);
		var month = icnumber_6front.substring(2,4);
		var day = icnumber_6front.substring(4,6);
		const currentyear = new Date().getFullYear();
		let currentyearToString = currentyear.toString();
		var currentYearSplit = currentyearToString.substring(2,4);

		if(currentYearSplit < year){
			year = "19" + year;
		}
		else{
			year = "20" + year;
		}
		
		var intYear = parseInt(year); 
		var intCurrYear = parseInt(currentyear); 
		var age = intCurrYear - intYear; 
		var select = document.getElementById('gender');
		var last_icnumber = parseInt(icnumber.charAt(icnumber.length-1)); //Outputs: last number ic
		//check even or odd number
		//check if the number is even
		if(last_icnumber % 2 == 0) {
			document.getElementById('gender').selectedIndex = '2';
			//alert("even");
		}
			
		// if the number is odd
		else {
			document.getElementById('gender').selectedIndex = '1';
			//alert("odd");
		}
		document.getElementById('nationality').selectedIndex = '1';
		document.getElementById("dob").value = day + "/" + month + "/" + year;
		document.getElementById("age").value = age;
		alert(document.getElementById("age").value);
	} else {
		alert("Invalid IC Number");
		
	}
	 

}
function myTelNo(telNo){
	var telephone_no  = new RegExp(/^(\+?60)[0|1|2|3|4|6|7|8|9]\-*[0-9]{8,9}$/);
	if (telephone_no.test(telNo)){
		
	}
	else{
		alert("Invalid Phone Number - format: +603-34567892");
	}
}
function myPhoneNo(phoneNo){
	var mobile_no  = new RegExp(/^(\+?601)[0|1|2|3|4|6|7|8|9]\-*[0-9]{7,8}$/g);
	if (mobile_no.test(phoneNo)){
	}
	else{
		alert("Invalid Mobile Number - format: +6012-34567892");
	}
}
function ValidateEmail(mail) 
{
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value))
  {
    return (true)
  }
    alert("You have entered an invalid email address!")
    return (false)
}
function mypassword(password_2){
	var password_1  = document.getElementById("password_1");
	if (password_1 != password_2){
		alert("	Re-type Password not same - please re-type again");
	}
}
</script>