<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */

// load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/hsphere/local/cracker15/artculturegroup.com/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

/// load records
  list($navigation_menu_entriesRecords, $navigation_menu_entriesMetaData) = getRecords(array(
    'tableName'   => 'navigation_menu_entries',
  ));

?>
    <?php $output = ''; ?>
	<?php foreach ($navigation_menu_entriesRecords as $record): ?>
<?php if($record['use_submenu'] == '1'):?> <?php $divclass = "anylinkmenu" ?><?php else:?><?php $divclass = "" ?><?php endif?>

<?php $entry = strtolower($record['entry']) ?>

<?php $sub1 = "" ?>
<?php $sub2 = "" ?>
<?php $sub3 = "" ?>
<?php $sub4 = "" ?>
<?php $sub5 = "" ?>
<?php $sub6 = "" ?>


<?php if($record['submenu_link_1_url']):?>
<?php $sub1 = "[" . "\"" . $record['submenu_link_1_text']. "\"" ."," . "\"" . $record['submenu_link_1_url'] ."\"" ." ]"  . ",";?>
<?php endif?>

<?php if($record['submenu_link_2_url']):?>
<?php $sub2 = "[" . "\"" . $record['submenu_link_2_text']. "\"" ."," . "\"" . $record['submenu_link_2_url'] ."\"" ." ]"  . ",";?>
<?php endif?>

<?php if($record['submenu_link_3_url']):?>
<?php $sub1 = "" ?><?php $sub3 = "[" . "\"" . $record['submenu_link_3_text']. "\"" ."," . "\"" . $record['submenu_link_3_url'] ."\"" ." ]"  . ",";?>
<?php endif?>

<?php if($record['submenu_link_4_url']):?>
<?php $sub4 = "[" . "\"" . $record['submenu_link_4_text']. "\"" ."," . "\"" . $record['submenu_link_4_url'] ."\"" ." ]"  . ",";?>
<?php endif?>

<?php if($record['submenu_link_5_url']):?>
<?php $sub5 = "[" . "\"" . $record['submenu_link_5_text']. "\"" ."," . "\"" . $record['submenu_link_5_url'] ."\"" ." ]"  . ",";?>
<?php endif?>

<?php if($record['submenu_link_6_url']):?>
<?php $sub6 = "[" . "\"" . $record['submenu_link_6_text']. "\"" ."," . "\"" . $record['submenu_link_6_url'] ."\"" ." ]"  . ",";?>
<?php endif?>

 <?php if($record['submenu_link_1_url']):?>
 
 <?php $output  .= "$sub1" . "$sub2" . "$sub3" . "$sub4" . "$sub5" . "$sub6" ; 

    $output= rtrim($output,","); // remove trailing comma 

?>
<?php endif?> 

var <?= $entry ?>={divclass:'<?= $divclass ?>', inlinestyle:'width:150px; background:#DAD2D0', linktarget:''} 
<?= $entry ?>.items=[
	<?= $output?>

]
<?php endforeach ?>




