<?php
if(!defined('IN_DEMOSOSO')) {
	exit('this is wrong page,please back to homepage');
}
?>

		<?php
		$resmenu = getarr_dmmenu($pidmenu);
		 // pre($resmenu);
if($resmenu['datares']=='no') echo $resmenu['data'];
else{

$menufirstv = ' first';
$menulastv = ' last';

?>
 <ul class="m">
<?php
 
		foreach ($resmenu['data'] as $k=>$v) {

			$k++;
           $menufirst = $k==1?$menufirstv:'';
		   $menucount = count($resmenu['data']);

		   $menulast = $k==$menucount?$menulastv:'';

		   //-----------------

			$name = $v['name'];
			$pidname = $v['pidname'];
			$menutid = 'menu'.$v['id'].' ';
			$linkurl = $v['linkurl'];
			$menu_xiala = $v['menu_xiala'];

			$typepidname=$v['type'];
			 $type = substr($typepidname,0,4);

 			if($type=='cate'){
				if($typepidname==$mainpidname) $activemenu = ' active';
			    else $activemenu = '';
 			}
			else{
				 if($pidname==$main_menuid) $activemenu = ' active';
				 else $activemenu = '';
			}
 

			?>
			<li   class="m <?php echo $menutid.$menufirst.$menulast?>"><a class="m <?php echo $activemenu?>" href="<?php echo $linkurl?>" <?php linktarget($linkurl)?>><?php echo $name?></a>

			<?php 
			      if($type=='page' || $type=='cusm'){
				      	if($menu_xiala<>'') echo $menu_xiala;
				      	else {
				      			if(isset($v['son'])){
							      		echo '<ul class="sub">';
							      		foreach ($v['son'] as $ksub => $vsub) {
							      			echo '<li><a href="'.$vsub['linkurl'].'" '.linktarget($vsub['linkurl']).'>'.$vsub['name'].'</a></li>';
							      			 
							      		}
							      		echo '</ul>';
							      	}
				      	}

			      }
			      else{ //cate...
			      	 if(isset($v['son'])){
			      	 		 if($v['son']['datares']=='yes'){
			      	 		 	echo '<ul class="sub">';
								foreach ($v['son']['data'] as $ksub => $vsub) {
									?>

									 <li><a href="<?php echo $vsub['link']?>"><?php echo $vsub['name']?></a>
									 <?php
									 	 if(isset($vsub['son'])){
									 	 	echo '<ul class="sub">';
									 	 	foreach ($vsub['son']  as $ksub2 => $vsub2) {
											    ?>
											    <li><a href="<?php echo $vsub2['link']?>"><?php echo $vsub2['name']?></a>
												 <?php
												}
											echo '</ul>'; 
									 	 }
									 ?>

									 </li>
			      			 	
									<?php
									}	//end foreach		
									echo '</ul>';      	 			

			      			 }
			      	 }

			      	//----------
			      }

				?>

			</li>
			<?php
		}
		?>
	</ul>
<?php
}
?>	
  