<?php

#-------------------------------------------------------------------------
# Project [iPad 3D]
# Version: [activeproject_activever]  Alan Ryan www.codecrunchers.ie
# 2:17:50 AM -  Nov 4, 2010
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

//Bug Fix, Top Level Nodes can  Link 15/02/11 AR
function link_to_prefix($dest){
	if(is_numeric($dest))
		return "<a href=\"javascript:goTo($dest)\">";
	else
		return "<a href=\"$dest\">";

}
?>
<div id="tocnav">
<div style="float:right;margin:4px;">(Use two fingers to scrolll)</div>
<div id="tocScroll">
	<?php
	echo "<ul>"; 
	for($i=0;$i<count($pubMenu);$i++){
			$hasChildren = count($pubMenu[$i]['children']);
			
			//Bug Fix, Top Level Nodes can  Link 15/02/11 AR
			if($pubMenu[$i]['dest']!=""){
				echo "<li>";				
				echo link_to_prefix($pubMenu[$i]['dest']);
				echo $pubMenu[$i]['title'];
				echo "</a>";
			}
			else{		
				echo "<li>" . $pubMenu[$i]['title'];
			}
			 
						
			if($hasChildren){			
				echo "<ul>";
				for($c=0;$c<count($pubMenu[$i]['children']);$c++){
					$_hasChildren = isset($pubMenu[$i]['children'][$c]['children']);					
					echo "<li>";
					if($pubMenu[$i]['children'][$c]['dest']!="")  {
						$_dest_l1 = $pubMenu[$i]['children'][$c]['dest'];
						echo link_to_prefix($_dest_l1);
						echo $pubMenu[$i]['children'][$c]['title'];
						echo "</a>";
					}else{
						echo $pubMenu[$i]['children'][$c]['title'];	
					}
					//echo $pubMenu[$i]['children'][$c]['title'];
					if($_hasChildren){
						echo "<ul>";
						for($ic=0;$ic<count($pubMenu[$i]['children'][$c]['children']);$ic++){
							$_dest_l2 = $pubMenu[$i]['children'][$c]['children'][$ic]['dest'];
							echo "<li>";
							echo link_to_prefix($_dest_l2);								
							echo $pubMenu[$i]['children'][$c]['children'][$ic]['title'];
							echo "</a></li>";
		 				}
						echo "</ul>";
					}
					echo "</li>";
				}		
				echo "</ul>";
			}else{
				echo "</li>";
			}
	}
	echo "</ul>";	
	?>
	</div>		
</div>