<script type="text/javascript">
$(document).ready(function(){
	var currcat = $('#hid-curr-catid').val();
	expand(currcat);
})
function expand(catId) {
	$('.collapse').hide();
	$('#' + catId).show();
}
</script>

<input type="hidden" id="hid-curr-catid" value="<?php echo $this->currCat; ?>">
<ul id="main_menu">
	<?php foreach ($this->sitePages as $sitePage): ?>
		<?php if($sitePage['h1'] == 'no category'): ?>
       
			<li>
				<ul class="nocategory">
					<?php foreach ($sitePage['pages'] as $subPage): ?>
						<li><a title="<?php echo $subPage['h1']; ?>" href="<?php echo ($subPage['url'] != 'index') ? $this->websiteUrl . $subPage['url'] . '.html' : $this->websiteUrl ; ?>" ><?php echo $subPage['navigationTitle']; ?></a></li>
					<?php endforeach; ?>
				</ul>
			</li>
       
		<?php else: ?>
			<?php $this->classCounter++; ?>
			<li class="cat-<?php echo $this->classCounter; ?>"><a onclick="expand('<?php echo $sitePage['url']; ?>')" title="<?php echo $sitePage['h1']; ?>" href="<?php echo $this->websiteUrl . $sitePage['url'] . '.html'; ?>" ><?php echo $sitePage['navigationTitle']; ?></a>
            
				<ul id="<?php echo $sitePage['url']; ?>" class="collapse" style="display: none;">
					<?php foreach ($sitePage['pages'] as $subPage): ?>
						<li><a onclick="expand('<?php echo $sitePage['url']; ?>')" title="<?php echo $subPage['h1']; ?>" href="<?php echo ($subPage['url'] != 'index') ? $this->websiteUrl . $subPage['url'] . '.html' : $this->websiteUrl ; ?>" ><?php echo $subPage['navigationTitle']; ?></a></li>
					<?php endforeach; ?>
				</ul>
            
			</li>
		<?php endif; ?>
	<?php endforeach; ?>
</ul>