	<?php
	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>";
	
	echo '
	<br>
	<div style="padding-bottom:7px">
		<strong>'.$button_label.'</strong>
	</div>
	<form name="formKelengkapanData" id="formKelengkapanData" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">';
        $sql = "select * from form_label where labelType='$idEvent'";
        //echo "<br> sql".$sql; 
        if ($hasil = mysql_query($sql)) {		
            while ($rec = mysql_fetch_array($hasil)) {
                $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="10" cellspacing="1" border="0" bgcolor="#999999">';
                    while ($rec2 = mysql_fetch_array($hasil2)) {
                        echo '
                        <tr valign="top" bgcolor="#e4e4e4">
                            <td width="28%" style="background-color:#e4e4e4;">
                                <strong>'
                                    .$rec2["labelName"].'<br>'
                                    .($rec2["labelNameEng"] ? '(<i>'.$rec2["labelNameEng"].'</i>)' : '').'	
                                </strong>
                            </td>';
                            echo '
                            <td style="background-color:#e4e4e4;">
                                '.$rec2["elementName"]($rec["labelID"], $rec2["designID"], 0, "form_design", "form_element", "elementID", "element", "labelParentID", "designID").'
                            	'.others($rec2["designID"]).'
							</td>
                        </tr>';
                    }
					if ($_SESSION['username'] == 'super' && $button_label == 'Add New Record') {
                        echo '
                        <tr valign="top" bgcolor="#e4e4e4">
                            <td width="28%" style="background-color:#e4e4e4;">
                                <strong>Remark</strong>
                            </td>';
                            echo '
                            <td style="background-color:#e4e4e4;">
								<input size="1" type="text" name="remark" id="remark" value="0" />
							</td>
                        </tr>';
					}
                    echo '
                        <tr valign="top" bgcolor="#e4e4e4">
                            <td align="center" colspan="2">
                                <div style="margin:20px 0px" align="center">
									<div id="cancelformKelengkapanData" class="hvr-sweep-to-right" style="padding:10px 30px; cursor:pointer;">
										<font style="color:#ffffff; text-align:center">
											<< Cancel
										</font>
									</div>
									<div id="submitformKelengkapanData" class="hvr-sweep-to-right" style="padding:10px 30px; cursor:pointer;">
										<font style="color:#ffffff; text-align:center">
											Save Data >>
										</font>
									</div>
									<input type="hidden" name="action" id="action" value="'.$button_label.'" />
									<input type="hidden" name="button_event" id="button_event" value="'.$button_event.'" />
                                	<input type="hidden" name="header_id" id="header_id" value="'.$header_id.'" />
								</div>
                            </td>
                        </tr>
                    </table>
                    <br>';
                }
            }
        }

	echo '
    </form>';										
	?>
