	<?php
	$legendName;
	
	if ($ctr_level >= 1)
	$sql = "select * from menus_level_0 as a, menus_level_1 as b ";
	
	if ($ctr_level >= '3')
	$sql .= ", menus_level_2 as c ";
	
	$sql .= ", content as d WHERE ";
		
	if ($ctr_level >= 1)
	$sql .= "level_0 = a.id AND a.id = b.menus_lv_0 AND b.id_level_1 = level_1 ";
	if ($ctr_level == 1)
	$sql .= "AND menuLINK = '".$curPage1."' ";

	if ($ctr_level == 2)		 
	$sql .= "AND link_lv_1 = '".$curPage1."' ";
	
	if ($ctr_level >= 3)
	$sql .= "AND b.id_level_1 = c.menus_lv_1 and level_2 = c.id_level_2 ";
	if ($ctr_level == 3)
	$sql .= "AND link_lv_2 = '".$curPage1."' ";

	if ($ctr_level > 3)
		$sql .= "AND targetPage = '".$curPage1."'";

	//echo "<br> Sql : ".$sql;
	$preText = '';
	if ($hasil = mysql_query($sql)) {
        while ($data = mysql_fetch_array($hasil)) {
			echo "<br>test";
			if ($preText == '') {
				$preText = 'start';
				$imageContentDownload = '#';
				if ($data["imageMenu"]) {
					$imageContent = $thisPage.$data["menuLINK"].$data["imageMenu"];
					$bigImage = '
					<figure data-open="'.$imageContent.'" class="show-expander">
						<img src="'.$thisPage.'images/spacer.png" data-srcset="'.$imageContent.' 720w, '.$imageContent.' 1000w, '.$imageContent.'" alt="" title="" />';
					$bigImage .= '	
					</figure>';
					echo '
					<section class="layout-centered" class="M081">
						<div style="" class="row">
							<div style="" class="rowInner">
								<div align="center" style="margin-top:0;" class="col l-col12 m-col12 s-col12 modul-container">
									'.$bigImage.'
								</div>
							</div>
						</div>
					</section>';
				}
				echo $txt_legend;
			} 
			echo '
			<section class="layout-centered" class="M081">
				<div class="row spacerRow">
					<div class="rowInner">
						<div class="col l-col12 m-col12 s-col12">
							<img class="spacerRowImage" src="'.$thisPage.'images/spacer-bg.png" alt="" title="" />
						</div>
					</div>
				</div>
				<div class="row">
					<div class="rowInner">
						<div class="col l-col12 m-col12 s-col12 modul-container">';
							$contentText = '
							<div style="margin-top:15px"></div>
							<h1 style="text-align:center">'.$data["title"].'</h1>';
							$bigImage = array();
							$imagePosition = array();
							$sql5 = "select * from content_images where to_content_id = '".$data["idContent"]."' ";
							//echo "<br> sql5 : ".$sql5;
							$counter=0;
							if ($hasil5 = mysql_query($sql5)) {
								while ($data5 = mysql_fetch_array($hasil5)) {
									$imagePosition[$counter] = $data5["imagePosition"];
									$imageContent = $thisPage.$data["link_lv_1"]."images/".$data5["imageContent"]; 
									//echo "<br> Gambar : ".$imageContent;
									if($data5["imageContentDownload"])
										$imageContentDownload = $thisPage.$targetPage."images/".$data5["imageContentDownload"]; 
									else 
										$imageContentDownload = "#"; 
									// echo "<br>".$sql5;
									$bigImage[$counter] = '
									<figure data-open="'.$imageContentDownload.'" class="show-expander">
										<img src="'.$thisPage.'images/spacer.png" data-srcset="'.$imageContent.' 720w, '.$imageContent.' 1000w, '.$imageContent.'" alt="'.$data5["imageContentTitle"].'" title="'.$data5["imageContentTitle"].'" />';
										if ($data5["imageContentTitle"])
										$bigImage[$counter] .= '
										<p>'.$data5["imageContentTitle"].'</p>';
									$bigImage[$counter] .= '	
									</figure>';
									//echo "<br> counter : ".$counter;
									$counter++;
								}
							}

							$contentText .= '
							<p style="clear:both;" class="clearfix">
								<div style="text-align:left;">'.$data["long_description"].'</div>
							</p>';

							// echo "<br> tabbPosition : ".$data5["tabbPosition"];
							if ($imagePosition[0]==1) {
								echo $contentText;
								if ($bigImage[0]) echo $bigImage[0];
							} else if ($imagePosition[0]==2) {
								if ($bigImage[0]) echo $bigImage[0];
								echo $contentText;
							} else {
								echo $contentText;
							}

							if ($bigImage[1]) echo $bigImage[1]."<p>&nbsp;</p>";
							
							$tabb_text = '';
							$ctr = 0;
							$sql5 = "select * from content_tabb where tabbContentID='".$data["idContent"]."' order by tabbORDER ";
							if ($hasil5 = mysql_query($sql5)) {
								while ($data5 = mysql_fetch_array($hasil5)) {
									if ($ctr%4 == 0) {
										if ($ctr>0) {
											$tabb_text .= '		
															</div>
														</div>	
													</div>
												</div>
											</div>
										</section>
                                        ';
										}
										$tabb_text .= '
										<section class="M00601 M0060101 teaserModule layout-centered" data-modul="M00601">';
										if ($ctr==0) {
											$tabb_text .= '
											<div class="row spacerRow">
												<div class="rowInner">
													<div class="col l-col12 m-col12 s-col12">
														<img class="spacerRowImage" src="images/spacer-bg.png" alt="" title="" />
													</div>
												</div>
											</div>'; }
											$tabb_text .= '
											<div class="row">
												<div class="rowInner">
													<div class="col s-col12 m-col12 l-col12">';
														$tabb_text .= '
														<div class="s-nested12 m-nested12 l-nested12">
															<div class="teasers">';		
									}							
									$tabb_text .= '				<div class="col l-col3 m-col6 s-col12">
																	<article class="teaser-item">
																		<a data-teaserId="M00601">
																			<div class="teaserImageBlock">
																				<img class="teaserImage" src="'.$thisPage.$data["link_lv_1"].'images/'.$data5["tabbImage"].'" alt="" title="" />
																			</div>
																			<div class="teaserTextBlock">
																				<h3>'.$data5["tabbTITLE"].'</h3>   
																				<p>
																					'.$data5["tabbMessage"].'
																				</p>
																			</div>
																		</a>
																	</article>
																</div>'; $ctr++;
								} 
								if ($tabb_text != '') {
									$tabb_text .= '			</div>
														</div>	
													</div>
												</div>
											</div>
										</section>
									';
								}
							}
							echo $tabb_text;
						echo'
						</div>
					</div>
				</div>
			</section>';
        }
    }
    ?>
