<?php
function getMainNav1Type1($topNavCurrId)
{
  global $dbInstance, $configTableHead, $kuWebsiteCurrLanguage, $kuHttpPath, $arrAllModule;
  $kuStrMainNav1 = "";
  $strSql = "select * from {$configTableHead}menu where (navshow=2 or navshow=4) and lang='{$kuWebsiteCurrLanguage}' order by sortnum asc;";
  $arrTopNav = $dbInstance->getList($strSql);
  foreach($arrTopNav as $topInfo)
  {
    $strMainNav2 = "";
    $topId = $topInfo['id'];
    $menuType = $topInfo['menutype'];
    $menuModule = $topInfo['menumodule'];
    $menuTitle = $topInfo['menutitle'];
    $strBlank = ($topInfo['blankwindow'] == 1 ? " target='_blank' " : "");
    
    if(2 == $menuType)$urlNav1 = $topInfo['otherurl'];//如果是外部链接
    else if(1 == $menuModule)$urlNav1 = $kuHttpPath.$arrAllModule[$menuModule]."/index.php?lang={$kuWebsiteCurrLanguage}&menuid={$topId}";
    else $urlNav1 = $kuHttpPath.$arrAllModule[$menuModule]."/index.php?lang={$kuWebsiteCurrLanguage}&menuid={$topId}&page=1";
    if($topId == $topNavCurrId)$kuStrMainNav1 .= "<li class='mainMenu current nav{$topId}'>\n<a href=\"{$urlNav1}\" $strBlank><span>{$menuTitle}</span></a>\n</li>\n";
    else $kuStrMainNav1 .= "<li class='mainMenu nav{$topId}'>\n<a href=\"{$urlNav1}\" $strBlank><span>{$menuTitle}</span></a>\n</li>\n";
  }
  return $kuStrMainNav1;
}

function getMainNav2Type1($topNavCurrId)
{
  global $dbInstance, $configTableHead, $kuWebsiteCurrLanguage, $kuHttpPath, $arrAllModule;
  $kuStrMainNav2 = '';
  $strSql = "select * from {$configTableHead}menu where (navshow=2 or navshow=4) and lang='{$kuWebsiteCurrLanguage}' order by sortnum asc;";
  $arrTopNav = $dbInstance->getList($strSql);
  foreach($arrTopNav as $topInfo)
  {
    $strMainNav2 = "";
    $topId = $topInfo['id'];
    $menuType = $topInfo['menutype'];
    $menuModule = $topInfo['menumodule'];
    $menuTitle = $topInfo['menutitle'];
    $strBlank = ($topInfo['blankwindow'] == 1 ? " target='_blank' " : "");
    
    if(2 == $menuType)$urlNav1 = $topInfo['otherurl'];//如果是外部链接
    else if(1 == $menuModule)$urlNav1 = $kuHttpPath.$arrAllModule[$menuModule]."/index.php?lang={$kuWebsiteCurrLanguage}&menuid={$topId}";
    else $urlNav1 = $kuHttpPath.$arrAllModule[$menuModule]."/index.php?lang={$kuWebsiteCurrLanguage}&menuid={$topId}&page=1";
    if($topId == $topNavCurrId)$strMainNav2 = "<li class='mainMenu current nav{$topId}'>\n<a href=\"{$urlNav1}\" $strBlank><span>{$menuTitle}</span></a>\n";
    else $strMainNav2 = "<li class='mainMenu nav{$topId}'>\n<a href=\"{$urlNav1}\" $strBlank><span>{$menuTitle}</span></a>\n";

    $strSql2 = "select * from {$configTableHead}menu where fatherid={$topId} and lang='{$kuWebsiteCurrLanguage}' order by sortnum asc;";
    //echo $strSql2;
    $arrSecondNav = $dbInstance->getList($strSql2);
    if(0 < count($arrSecondNav))//二级
    {
        $strMainNav2 .= "<ul id='subOne{$topId}'>\n";
        foreach($arrSecondNav as $secondInfo)
        {
            $secondId = $secondInfo['id'];
            $menuType2 = $secondInfo['menutype'];
            $menuModule2 = $secondInfo['menumodule'];
            $menuTitle2 = $secondInfo['menutitle'];
            $strBlank = ($secondInfo['blankwindow'] == 1 ? " target='_blank' " : "");
            
            if(2 == $menuType)$urlNav2 = $topInfo['otherurl'];//如果是外部链接
            else if(1 == $menuModule)$urlNav2 = $kuHttpPath.$arrAllModule[$menuModule]."/index.php?lang={$kuWebsiteCurrLanguage}&menuid={$secondId}";
            else $urlNav2 = $kuHttpPath.$arrAllModule[$menuModule]."/index.php?lang={$kuWebsiteCurrLanguage}&menuid={$secondId}&page=1";
            $strMainNav2 .= "<li class='subMenu nav{$topId}'><a href=\"{$urlNav2}\" $strBlank><span>{$menuTitle2}</span></a></li>\n";
        }
        $strMainNav2 .= "\n</ul>\n";
    }
    $strMainNav2 .= "\n</li>\n";
    $kuStrMainNav2 .= $strMainNav2;
  }
  return $kuStrMainNav2;
}
?>