


	<script type="text/javascript" src="<?php echo $thisPage; ?>js/messages.js"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo $thisPage; ?>css/messages.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo $thisPage; ?>css/captcha.css" />
	<?php
	function FindData($designName, $tabelName, $resData) {
		global $productTitle;
		$sql7 = "SELECT * FROM $tabelName, form_element_sub WHERE elementSubID = elementSubParentID and valueID = $designName";
		//echo $sql7;
		if ($hasil7 = mysql_query($sql7)) {
			while ($data7 = mysql_fetch_array($hasil7)) {
				$resData = $data7["valueName"]; 
				$productTitle = $data7["elementSubDescription"]; 
				return $resData;
			}
		}
	}
	
	function InsertData($designName, $tabel1, $tabel2, $idNext) {
		global $$designName;
		$Others = "";
		//echo "<br>$designName: ".$$designName;
		foreach ($$designName as &$value) {
			$value = explode('-',$value);
			$elementSubParentID = $value[0];
			$valueID = $value[1];
			if ($elementSubParentID && $valueID) {
				$sql7 = "INSERT INTO ".$tabel1." VALUES (null, '$idNext', '$elementSubParentID', '$valueID')";
				//echo "<br><br>sql: ".$sql;  
				mysql_query($sql7) OR die("Error:".mysql_error());
			}
			
			global ${"Others".$elementSubParentID};
			${"Others".$elementSubParentID} = $_POST["Others".$elementSubParentID];
			if ($Others != ${"Others".$elementSubParentID}) {
				$Others = ${"Others".$elementSubParentID};
				if (${"Others".$elementSubParentID}) {
					$sql7 = "INSERT INTO ".$tabel2." VALUES (null, '$idNext', '$elementSubParentID', '${"Others".$elementSubParentID}')";
					mysql_query($sql7) OR die("Error:".mysql_error());
					//echo "<br><br>sql: ".$sql;  
				}
			}	
		}
	}

	function getNumberOnly($kdNegara, $hslNumber) {
		$start = 0;
		$chars = str_split($kdNegara);
		foreach ($chars as &$value) {			
			if ($value=="(") $start = 1;
			if ($start == 1) {
				$hslNumber .= $value;
			}
			if ($value==")") $start = 0;
		}
		
		return $hslNumber;
	}
	
	$idEvent = "Exhibitor-Add";
		echo "<script>";
		echo "function validate(form) {";	
		$sql = "select designName from form_label, form_design where labelType='".$idEvent."' and labelID=labelParentID and validasi='YES' order by designORDER asc";
		//echo "<br> sql : ".$sql; 
		if ($hasil = mysql_query($sql)) {
			while ($rec = mysql_fetch_array($hasil)) {
				if ($rec["designName"] != "website") {
					echo "var ".$rec["designName"]." = form.".$rec["designName"].".value;";
					echo '
						if('.$rec["designName"].' == "") {
							inlineMsg("'.$rec["designName"].'","Field can not be empty.",2);
							return false;
					  	} else {
							var targetdiv = document.getElementById("'.$rec["designName"].'"); 
					  		targetdiv.style.backgroundColor = "white";
					  	}
					';	
				}
			}
		}	
		echo "
				return true;
			}
		";

	echo "</script>";
	
	
	
	$action = $_POST["action"];
	$ctr = 0;
	if ($action=="Submit") {		
		$email = $_POST["email"];
		
		$query = "select * from exhibitor_register where LOWER(email)=LOWER('$email')";
		$total = mysql_num_rows(mysql_query($query));
		//echo "<br><br>query : ".$query."<br>";
		//echo "<br>Total : ".$total;
		if ($total>0) {
			// Sudah ada 
			echo "<script>";
			echo "location.href = '?res=3'";
			echo "</script>";
		} else {
			// Insert Data
			$sql = "select labelType, labelName, designName from form_label, form_design where labelType='".$idEvent."' and labelID=labelParentID order by designORDER asc";
			//echo "<br>sql: ".$sql;
			if ($hasil = mysql_query($sql)) {
				while ($rec = mysql_fetch_array($hasil)) {
					$ctr++;
					$labelName = $rec["labelName"];				
					$designName = $rec["designName"];					
					$$designName = $_POST[$designName];
					//echo "<br> $designName : ".$$designName;
				}
				$date_register = date("Y-m-d");
				
				$kdNegara7 	= $_POST["kdNegara7"];
				$theNumber = getNumberOnly($kdNegara7, $hslNumber);
				$hpNo = $theNumber." ".$hp;
				
				$kdNegara13 = $_POST["kdNegara13"];
				$theNumber = getNumberOnly($kdNegara13, $hslNumber);
				$telponNo = $theNumber." ".$telpon;
				
				$sql = "INSERT INTO exhibitor_register VALUES (null, '$date_register', '$fullName', '$gender', '$country', '$email', '$telpon', '$perusahaan', '$bidang_usaha', '$luas', '$tipe_area')";
				//echo "<br><br>sql: ".$sql; 
				if ($hasil = mysql_query($sql)) {
					$idNext = mysql_insert_id();

					if ($produk) {
						$designName = "produk";
						InsertData($designName,"exhibitor_register_product","exhibitor_register_product_lain",$idNext);
					}
					
					$body = '
					<table width="100%" cellpadding="6" cellspacing="0" border="0">
						<tr>
							<td colspan="3">
								Dear All, <br>
								Berikut Data Registrasi <strong>Exhibitor TEI 2017</strong> yang Daftar Online:
							</td>
						</tr>
						<tr valign="top">
							<td width="28%">Tanggal Daftar</td>
							<td width="2%" align="center">:</td>
							<td width="70%">'.date("l, d F Y", strtotime($date_register)).'</td>
						</tr>					
						<tr valign="top">
							<td>Nama Lengkap</td>
							<td align="center">:</td>
							<td>'.$fullName.'</td>
						</tr>
						<tr valign="top">
							<td>Jenis Kelamin</td>
							<td align="center">:</td>
							<td>'.FindData($gender, "form_element_value", $resData).'</td>
						</tr>					
						<tr valign="top">
							<td>Negara</td>
							<td align="center">:</td>
							<td>'.FindData($country, "form_element_value", $resData).'</td>
						</tr>
						<tr valign="top">
							<td>Alamat Email</td>
							<td align="center">:</td>
							<td>'.$email.'</td>
						</tr>			
						<tr valign="top">
							<td>Nomor Telpon</td>
							<td align="center">:</td>
							<td>'.$telpon.'</td>
						</tr>					
						<tr valign="top">
							<td>Nama Perusahaan</td>
							<td align="center">:</td>
							<td>'.$perusahaan.'</td>
						</tr>					
						<tr valign="top">
							<td>Luas Area</td>
							<td align="center">:</td>
							<td>'.$luas.' m2</td>
						</tr>					
						<tr valign="top">
							<td>Tipe Area</td>
							<td align="center">:</td>
							<td>'.FindData($tipe_area, "form_element_value", $resData).'</td>
						</tr>		
						<tr valign="top">
							<td>Produk yang akan dipamerkan</td>
							<td align="center">:</td>
							<td>
								';
								$cek = 0;
								foreach ($produk as &$value) {
									$val = FindData($value[1], "form_element_value", $resData);
									if ($cek != $value[0]) {
										if ($cek != 0) {
											if (${"Others".$cek})
												$body .= '
												<li><strong>Others:</strong><br>'.${"Others".$cek}.'</li>';
											$body .= '
											</ul><br>';										
										}
										$body .= '
										<strong>'.$productTitle.'</strong>
										<ul style="margin:0; padding:0px 0px 0px 14px; list-style:disc;">';
										$cek = $value[0];
									}
									$body .= '
									<li>'.$val.'</li>';
								}
								if (${"Others".$cek})
									$body .= '
									<li><strong>Others:</strong><br>'.${"Others".$cek}.'</li>';
								$body .= '
								</ul>
							</td>
						</tr>			
						<tr valign="top">
							<td colspan="3">
								<br>
								Sincerely,<br>
								<strong>Automatic Email Sender Program</strong>						
							</td>
						</tr>
					</table>';
					//echo "<br> body : ".$body;
					
					$message = '
						<html>
							<body>'.$body.'</body>
						</html>
					';

					$from = "From:Trade Expo Indonesia <exhibitor@tradexpoindonesia.com>";
					$to = "debindotei2017@gmail.com";
					$subject = "Trade Expo Indonesia: Daftar Online Exhibitor";
					
					$headers  = "MIME-Version: 1.0" . "\r\n";
					$headers .= "Content-type:text/html" . "\r\n";
					$headers .= $from . "\r\n";
					$headers .= "BCc:chunkhu@gmail.com" . "\r\n";
					if (mail($to, $subject, $body, $headers)) {}
					
					
					$body = '
					<table width="100%" cellpadding="6" cellspacing="0" border="0">
						<tr>
							<td align="center">
								<strong>Trade Expo Indonesia 2017</strong> <br>
								Exhibitor Booking Confirmation Letter
								<p>
									<strong> 11 - 15 October 2017 </strong>
									<br>10.00 am - 8.00 pm (local time)
								</p>
								<p> Indonesian Convention Exhibition (ICE), BSD City </p>
							</td>
						</tr>
						<tr valign="top">
							<td>
								<br>
								<strong>Kepada Yth: '.
								(FindData($gender, "form_element_value", $resData) == "Male (Laki - Laki)" ? "Bpk. " : "Ibu. ").
								$fullName.', </strong> <br><br>
								Dengan Hormat, <br><br>
								Terima kasih banyak telah mendaftar sebagai Peserta Pameran Trade Expo Indonesia 2017. <br><br>
								Tim sales kami akan segera menghubungi Bapak/Ibu.
							</td>
						</tr>					
						<tr valign="top">
							<td colspan="3">
								<br><br>
								Hormat Kami,<br>
								<strong>Trade Expo Indonesia 2017</strong>						
							</td>
						</tr>
					</table>';
					//echo "<br>body : ".$body;

					$message = '
						<html>
							<body>'.$body.'</body>
						</html>
					';

					$from = "From:Trade Expo Indonesia <exhibitor@tradexpoindonesia.com>";
					$to = $email; //echo "<br>to : ".$to;
					$subject = "Trade Expo Indonesia: Email Confirmation";
					$headers  = "MIME-Version: 1.0" . "\r\n";
					$headers .= "Content-type:text/html" . "\r\n";
					$headers .= $from . "\r\n";
					$headers .= "BCc:chunkhu@gmail.com" . "\r\n";
					if (mail($to, $subject, $body, $headers)) {}

					// KIrim Email
					echo "<script>";
					echo "location.href = '?res=1'";
					echo "</script>";

				} else {
					echo "<script>";
					echo "location.href = '?res=2'";
					echo "</script>";
				}
			}	
		}
	}
	
    $res = $_REQUEST["res"];
    if ($res) {
   		if ($res == 1) {
			echo '
			<p>
				<h3 class="h3-teasers">Registration Confirmation</h3>
				<p>
					<strong>Terima Kasih Bapak/Ibu</strong> <br>
					Data Bapak/Ibu sudah kami terima. <br>
					Mohon hubungi kami via telpon atau email ke exhibitor@tradexpoindonesia.com, <br>
					jika dalam 1X24 jam, bapak/ibu belum menerima email konfirmasi dari kami.
				</p>
				<p>
					<strong>Thank you for registering</strong> <br>
					Your registration has been successfully submitted. <br>
					If you do not receive email confirmation within 24 hours, <br>
					please contact us by phone or email at exhibitor@tradexpoindonesia.com.
				</p>
			</p>';
		} else if ($res == 2) {
			echo '
			<p>
				<h3 class="h3-teasers">Registration Confirmation</h3>
				<p>
					<strong>Terima Kasih Bapak/Ibu</strong> <br>
					Mohon maaf, data Bapak/Ibu tidak berhasil kami terima. <br>
					Mohon coba lagi atau hubungi kami via telpon atau email ke exhibitor@tradexpoindonesia.com. <br>
					Kami siap membantu.
				</p>
				<p>
					<strong>Thank you for registering</strong> <br>
					We are very sorry, your registration has not been submitted. <br>
					Please try to register again or contact us by phone or email at exhibitor@tradexpoindonesia.com.
					We are pleased to help you.
				</p>
			</p>';
  		} else if ($res == 3) {
			echo '
			<p>
				<h3 class="h3-teasers">Registration Confirmation</h3>
				<p>
					<strong>Terima Kasih Bapak/Ibu</strong> <br>
					Data Bapak/Ibu sudah terdaftar sebelumnya. <br>
					Mohon hubungi kami via telpon atau email ke exhibitor@tradexpoindonesia.com. <br>
					Kami siap membantu.
				</p>
				<p>
					<strong>Thank you for registering</strong> <br>
					You have already registered.<br>
					Please contact us by phone or email at exhibitor@tradexpoindonesia.com.
					We are pleased to help you.
				</p>
			</p>';
   		}
    } else {
        ?>	
        <div class="box" style="font-size:14px; line-height:18px; ">
            <form name="form" id="form" class="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" onsubmit="return validate(this)" method="post">
                <p>
					<?php
                    $sql = "select * from form_label where labelType='$idEvent'";
                    //echo "<br> sql".$sql; 
                    if ($hasil = mysql_query($sql)) {		
                        while ($rec = mysql_fetch_array($hasil)) {
                            echo "<h2 class='h2-teasers'>".$rec["labelNameTitle"]."</h2>";
                            $sql2 = "select * from form_design, form_element where elementID = element AND labelParentID = ".$rec["labelID"]." order by designORDER asc";
                            // echo $sql2;
                            if ($hasil2 = mysql_query($sql2)) {
                                echo '<table width="100%" cellpadding="0" cellspacing="1" border="0" bgcolor="#999999" style="border:1px solid #999999">';
								echo '	<tr valign="top" bgcolor="#e4e4e4">';
								echo '		<td colspan="2" style="background-color:#e4e4e4; height:1px; padding:2px;" align="right"></td>';
                                echo '		</td>	
									 	</tr>
									 ';
								while ($rec2 = mysql_fetch_array($hasil2)) {
                                    // Link ke Element
                                    $sql4 = "select * from form_element, form_element_link, form_element_sub where elementID='".$rec2["element"]."' 
                                             and elementShow='1' and linkDesignID='".$rec2["designID"]."' and linkElementSubID=elementSubID";
                                    // echo $sql4;
                                    if($hasil4 = mysql_query($sql4)) {
                                        while ($rec4 = mysql_fetch_array($hasil4)) {
                                            $elementSubID = $rec4["elementSubID"];
                                            $elementSubName = $rec4["elementSubName"];
                                            $elementSubStat = $rec4["elementSubStat"];
                                            $elementName = $rec4["elementName"];
                                        }
                                    }
                                    // Link ke Element
                                    //echo $elementSubStat;
                                    if ($rec2["elementName"] != "hidden") {
                                        //echo "$designName : ".$$designName;
                                        echo '<tr valign="top" bgcolor="#e4e4e4">';
                                        echo '	<td style="background-color:#e4e4e4; padding-top:0; padding-bottom:0">
													<strong>
														'.$rec2["labelName"];
														if ($rec2["labelNameEng"]) {
															echo '
															(<i>'.$rec2["labelNameEng"].'</i>)';
														}
													echo '	
													</strong>													
												</td>';
										echo '</tr>';
                                        echo '<tr>';
										echo '	<td style="background-color:#e4e4e4; padding-top:0; padding-bottom:25px">';
                                                $inputName = $rec2["designName"];
                                                if ($elementName == "checkbox") $inputName .= "[]";
    
                                                if($rec2["elementShow"] == "1") {
                                                    if($elementSubStat == "single") {
                                                        if ($elementName == "select") {
                                                            $opsi = '';
                                                            $sql3="select * from form_element_value where elementSubParentID=".$elementSubID." order by valueID ";
                                                            // echo $sql3;
                                                            if($hasil3 = mysql_query($sql3)) {
                                                                while ($rec3 = mysql_fetch_array($hasil3)) {
                                                                    $elementSubParentID = $rec3["elementSubParentID"];
																	if ($opsi == '') {
                                                                        $opsi  = '<select style="height:33px;" name="'.$inputName.'" id="'.$inputName.'">';
                                                                        $opsi .= "	<option value = ''>- select (pilih) -</option>";
																		if ($elementSubParentID == '1') {
																			$opsi .= "	<option style='font-size:10px' value = '77'>Indonesia</option>";
																			$opsi .= "	<option style='font-size:10px' value = '' disabled></option>";
																		}
                                                                    }
                                                                    $opsi .= '<option style="font-size:10px" ';
                                                                    //echo "<br>".$$designName;
                                                                    if ($$rec2["designName"]==$rec3["valueID"]) $opsi .= ' selected ';
                                                                    $opsi .= 'value = "'.$rec3["valueID"].'">'.$rec3["valueName"].'</option>';
                                                                }
                                                                if ($opsi != '') {
                                                                    $opsi .= '</select>';
                                                                    echo $opsi;
																	if ($elementSubParentID == '4') {
																		echo '<p style="padding:0; margin:10px 0px 0px 0px"><strong>For other city, please specify (untuk kota lain, masukkan disini</strong>)</p>';
																		echo '<textarea style="width:100%; font-size:15px" name="kota_propinsi_lain" id="kota_propinsi_lain" cols="'.$rec2["cols"].'" rows="'.$rec2["row"].'">'.$kota_propinsi_lain.'</textarea>';
																	}
                                                                }
                                                            }
                                                        } else {
                                                            $opsi = '';
                                                            $sql3 = "select * from form_element_link, form_element_sub, form_element_value
																	 where linkDesignID = '".$rec2["designID"]."' and linkElementSubID = elementSubID and
																	 elementSubID = elementSubParentID order by valueID";															
															//where elementSubParentID=".$elementSubID." order by valueID ";
                                                            //	echo "<br> sql3: ".$sql3;
                                                            $ctr = 0;
															$SubParent = "";
															if($hasil3 = mysql_query($sql3)) {
                                                                while ($rec3 = mysql_fetch_array($hasil3)) {																	
																	if ($opsi == '' || $SubParent != $rec3["elementSubParentID"]) {
                                                                        
																		if ($opsi == '') {
																			$opsi = '
																			<table width="100%" celpadding="0" celspacing="0" border="0"> 
																				<tr>
																					<td colspan="2" style="height:2px; font-size:1px; padding:3px; background-color:#e4e4e4;"></td>
																				</tr>
																			';
																		} 
																		if ($rec3["elementSubParentID"] >= 6 && $rec3["elementSubParentID"] <= 12) {
																			if ($SubParent != '')
																			$opsi .= '
																				</tr>
																				<tr>
																					<td colspan="2" style="height:10px; font-size:1px; padding:3px; background-color:#e4e4e4;"></td>
																				</tr>
																			';
																			$opsi .= '																			
																			<tr>
																				<td colspan="2" style="height:2px; font-size:1px; padding:3px; background-color:#e4e4e4;">
																					<b>'.$rec3["elementSubDescription"].'</b>
																				</td>
																			</tr>
																			';
																		}
																		$SubParent = $rec3["elementSubParentID"];
																		$opsi .= '
																			<tr>
																		';
                                                                    } else if ($ctr%2 == 0) {
																		$opsi .= '
																			</tr>
																			<tr>
																		';
																	}
																	
																	
																	if ($rec3["valueName"] == "Others, please specify (Lainnya, masukkan disini)") {
																		$opsi .= '
																			</tr>
																			<tr>';
																		$opsi .= '	
																				<td colspan="4" style="background-color:#e4e4e4; padding-top:0; padding-bottom:10px">
																					'.$rec3["valueName"];
																					$opsi .= '
																					<textarea style="width:100%; font-size:15px" name="Others'.$rec3["elementSubParentID"].'" id="Others'.$rec3["elementSubParentID"].'" cols="'.$rec2["cols"].'" rows="'.$rec2["row"].'">'.${"Others".$rec3["elementSubParentID"]}.'</textarea>';
																				$opsi .= '	
																				</td>';
																			$opsi .='		
																			<tr>';	
																	} else {
																		$opsi .= '	
																				<td width="2%" style="background-color:#e4e4e4; padding-top:0; padding-bottom:10px">
																					<input ';
																					//$dsName = $rec2["designName"];
																					if ($elementName == "checkbox") {
																						if ($rec2["designName"]=="produk" || $rec2["designName"]=="know_about") {
																							//echo "<br>".$$rec2["designName"][0];
																							foreach ($$rec2["designName"] as &$value) {
																								$val = $value[1];
																								//echo "<br> val: ".$val."  valueID: ".$rec3["valueID"]; 
																								if ($val==$rec3["valueID"]) {
																									$opsi .= 'checked ';
																								}
																							}
																						}
																					} else {
																						if ($$rec2["designName"]==$rec3["valueID"]) {
																							$opsi .= 'checked ';
																						}
																					}

																					$opsi .= 'type="'.$elementName.'" id="'.$inputName.'" name="'.$inputName.'" ';
																					
																					if ($elementName == "checkbox") {
																						$val = $rec3["elementSubParentID"]."-".$rec3["valueID"];
																					} else {
																						$val = $rec3["valueID"];
																					}
																					$opsi .= 'value="'.$val.'">
																				</td>';
																		$opsi .= '	
																				<td'; if ($rec3["valueID"]=='590') $opsi .= ' colspan="3" '; else $opsi .= ' width="43%" '; $opsi .= ' style="background-color:#e4e4e4; padding-top:0; padding-bottom:10px">
																					'.$rec3["valueName"];
																					if ($rec3["valueID"]=='590') {
																						$sql7 = "select * from form_element_value where elementSubParentID = '15' order by valueID";
																						//echo "<br>sql7 : ".$sql7;
																						if ($hasil7 = mysql_query($sql7)) {
																							$num_rows = mysql_num_rows($hasil7);
																							//echo "<br> num_rows: ".$num_rows;
																							if ($num_rows > 0) {
																								$cekBox = "";
																								$opsi .= '
																								<select style="height:33px;" name="know_from_office_rep" id="know_from_office_rep" class="decodeIt">';
																									$opsi .= '
																									<option value="">- select (pilih) -</option>';
																									while ($data7 = mysql_fetch_array($hasil7)) {
																										$opsi .= '
																										<option ';																										
																										if (!$cekBox) {
																											//echo "Test : ".${"kdNegara".$rec2["designID"]};
																											if ($know_from_office_rep == $data7["valueID"]) {
																												$cekBox = 'selected="selected" ';
																												$opsi .= $cekBox;
																											}
																										}
																										$opsi .= 'style="font-size:10px" value="'.$data7["valueID"].'">';
																										$opsi .= 	$data7["valueName"];
																										$opsi .= '</option>';
																									}
																								$opsi .= '
																								</select>
																								';
																							}
																						}
																					}																		
																		$opsi .= '	
																				</td>
																		';
																	}
                                                                    $ctr++;    
                                                                }
                                                                if ($opsi != '') {
                                                                    $opsi .= '		
																			</tr>
																		</table>';
                                                                    echo $opsi;
                                                                }
                                                            }
                                                        }
                                                    } else if($elementSubStat == "multiple") {
                                                        //echo "Element Name : ".$elementName;
                                                        
                                                        if ($elementName == "select") {
                                                            //echo "test";
                                                        } else {
                                                            $sql3="select * from $elementSubName ";
                                                            //echo $sql3;
                                                            if ($hasil3 = mysql_query($sql3)) {
                                                                $tabelContent = '';
                                                                $rows_count = mysql_num_rows($hasil3);							
                                                                // echo '<br>Nomor : '.$rows_count;
                                                                for($i=0; $i<$rows_count; $i++) {
                                                                    $rec3 = mysql_fetch_row($hasil3);
                                                                    if ($i==0) {
                                                                        $tabelContent = '
                                                                        <table width="100%" cellpadding="6" cellspacing="1" bgcolor="#CCCCCC">
                                                                            <tr bgcolor="#FFFFCC">
                                                                                <td></td>
                                                                        ';
                                                                    } else {
                                                                        $inputType = '<input ';
                                                                        if ($$rec2["designName"]==$rec3[0]) $inputType .= ' checked ';
                                                                        $inputType .= ' type="'.$elementName.'" name="'.$inputName.'" value="'.$rec3[0].'">';
                                                                        
                                                                        $tabelContent .= '
                                                                            <tr bgcolor="#f8f3d3">
                                                                                <td align="center">'.$inputType.'</td>
                                                                        ';
                                                                    }
                                                                    for($r=0;$r<count($rec3)-1;$r++) {
                                                                        if ($r==0) {
                                                                            $tabelContent .= '
                                                                            <td	align="center">';
                                                                            if ($i==0) 
                                                                                $tabelContent .= '	
                                                                                    <strong>ID</strong></td>';
                                                                            else {
                                                                                $tabelContent .= '	
                                                                                    <strong>'.$i.'</strong></td>';
                                                                            }
                                                                        } else {
                                                                            //echo $rec3[$r];
                                                                            $tabelContent .= '
                                                                            <td>';
                                                                            if ($i==0) 
                                                                            $tabelContent .= '
                                                                                <strong>';
                                                                            $tabelContent .= 
                                                                                    $rec3[$r];
                                                                            if ($i==0) 
                                                                            $tabelContent .= '
                                                                                </strong>';
                                                                            $tabelContent .= '
                                                                            </td>';
                                                                        }
                                                                    }
                                                                    $tabelContent .= '</tr>';
                                                                }
                                                                if ($tabelContent != '') {
                                                                    $tabelContent .= '
                                                                        </table>';
                                                                    echo $tabelContent;
                                                                }	
                                                            }
                                                        }
                                                    }
                                                } else if($rec2["elementShow"] == "2") {
                                                    $sql5 = "select * from form_element where elementID='".$rec2["element"]."' 
                                                             and elementShow='2' ";
                                                    //echo $sql4;
                                                    if($hasil5 = mysql_query($sql5)) {
                                                        while ($rec5 = mysql_fetch_array($hasil5)) {
                                                            $elementName = $rec5["elementName"];
                                                        }
                                                    }	
    
                                                    //echo "<br> elementName : ".$elementName."<br>"; 
                                                    //echo "<br>designID : ". $rec2["designID"];
													if ($elementName == "textarea")	{
                                                  		echo '<textarea style="width:100%; font-size:15px" name="'.$rec2["designName"].'" id="'.$rec2["designName"].'">'.$$rec2["designName"].'</textarea>';
                                                    } else {
														if ($rec2["designID"] == '7' || $rec2["designID"] == '13') {
															
															echo '
															<div style="width:100%; display:block">
																<div style="width:38%; margin-right:2%; display:inline-block; float:left">
																';
																	$sql7 = "select * from form_element_value where elementSubParentID = '5' and valueID <> '375'";
																	//echo "<br>sql7 : ".$sql7;
																	if ($hasil7 = mysql_query($sql7)) {
																		$num_rows = mysql_num_rows($hasil7);
																		//echo "<br> num_rows: ".$num_rows;
																		if ($num_rows > 0) {
																			$cekBox = "";
																			if (${"kdNegara".$rec2["designID"]} == "Indonesia (62)")
																				$cekBox = 'selected="selected" ';
																			//echo "<br>cekBox: ".$cekBox;	
																			echo '
																			<select style="width:100%; height:33px;" name="kdNegara'.$rec2["designID"].'" id="kdNegara'.$rec2["designID"].'" class="decodeIt">';
																			echo '
																				<option value="">- select (pilih) -</option>
																				<option '.$cekBox.' style="font-size:10px" value = "Indonesia (62)">Indonesia (62)</option>
																				<option style="font-size:10px" value = "" disabled></option>
																			';
																			
																			while ($data7 = mysql_fetch_array($hasil7)) {
																				echo '
																				<option ';
																				
																				if (!$cekBox) {
																					//echo "Test : ".${"kdNegara".$rec2["designID"]};
																					if (${"kdNegara".$rec2["designID"]} == $data7["valueName"]) {
																						$cekBox = 'selected="selected" ';
																						echo $cekBox;
																					}
																				}
																				echo 'style="font-size:10px" value="'.$data7["valueName"].'">';
																				echo 	$data7["valueName"];
																				echo '</option>';
																			}
																			echo '
																			</select>
																			';
																		}
																	}
																echo '
																</div>
																<div style="width:60%; display:inline-block; float:left">
																	<input style="width:100%; height:33px;" class="decodeIt" type="'.$rec2["elementName"].'" name="'.$rec2["designName"].'" id="'.$rec2["designName"].'" max-size="'.$rec2["size"].'" value="'.$$rec2["designName"].'">
																</div>
															</div>
															';
														} else {
															echo '<input style="';
															echo '<input style="';
															if ($rec2["designID"] == '6')
																echo 'width:20%;';
															else 
																echo 'width:100%;';
															echo 'height:33px;" class="decodeIt" type="'.$rec2["elementName"].'" name="'.$rec2["designName"].'" id="'.$rec2["designName"].'" maxlength="'.$rec2["size"].'" size="'.$rec2["size"].'" value="'.$$rec2["designName"].'">';
														}
													}
                                                }
                                        echo '	</td>';
                                        echo '</tr>';
                                    }
                                }
                                echo '</table>';
                            }
                        }
                    }									
                    ?>
                    <table width="100%" cellpadding="15" cellspacing="1" border="0">
                        <tr>
                            <td align="center">
                                <input type="hidden" name="ktsandi" id="ktsandi" value="<?php echo $_SESSION['random_number']?>">
                                <input type="hidden" name="elementSubStat" id="elementSubStat" value="<?php echo $elementSubStat; ?>">
                                <input type="submit" name="action" id="action" class="button" value="Submit">								
                            </td>
                        </tr>
                    </table>
                </p>
            </form>
        </div>
        <?php
    }
    ?>
