<!DOCTYPE html>
<html lang="<?= $system['language']?>">
<head>
<meta charset="utf-8">

<span id="realtitle"><title><?= $system['title']?></title></span>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<? /*
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-6277418502067253",
    enable_page_level_ads: true
  });
</script>
*/
?>
<meta name="yandex-verification" content="9ae47a967cc99b19" />
<meta name="application-name" content=""/>
<meta name="msapplication-tooltip" content=""/>
<meta name="msapplication-starturl" content="http://<?= urlencode($_SERVER['SERVER_NAME'])?>/index.php"/>
<meta name="keywords" content="<?= $system['meta_keyword']?>">
<meta name="description" content="<?= $system['meta_description']?>" />

<link href="<?= CSS?>bootstrap.css?t=<?=time()?>" rel="stylesheet">
<link href="<?= CSS?>main.css?t=<?=time()?>" rel="stylesheet">
<link href="<?= CSS?>ic.css?t=<?=time()?>" rel="stylesheet">
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="<?= JSC?>bootstrap.min.js" type="text/javascript"></script> 

<link rel="shortcut icon" href="<?= ICONS?>favicon.ico">
<? 
$sban = $sql -> fetch("SELECT * FROM `ban` WHERE `id_ban` = '".$user['id']."' AND `time` > '$time' ORDER BY `time` DESC LIMIT 1");

if ($user['id'] != $sban['id_ban']) {
if ($level > 0 && $func != 'user.reg') { ?>
        <script>  
        function titleshow()  
        {  
            $.ajax(
            {  
                url: "/AjaxSend.php",  
                cache: false,  
                success: function(html)
                {
                        if (html != 'NO')
                        {
                           $('#realtitle>title').replaceWith(html);  
                        }

                }  
            });  
        }  
        $(document).ready(function(){  
            titleshow();  
            setInterval('titleshow()',10000);  
        });  
        </script>

<script>
function getCounterUpdate() {
    $.ajax({
        url: '/api.php',
        dataType: 'json',
        success: function(data) {
            $.each(data, function(key, val) {
                if (val == 0) {
                    document.getElementById(key).style.display = 'none';
                } else {
                    document.getElementById(key).style.display = '';
                    $('#' + key).html('<span class="counter">' + val + '</span>');
                }
            });
        }
    });    
}

setInterval(function() { getCounterUpdate() }, 10000);
</script>

<?}

}
?>

</head>
<body>
    <!-- Navigation -->
<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner not-radius">
            <ul class="nav navbar-text pull-right nav-panel">
              <li class="divider-vertical"></li>
              <? if ($level > 0) { ?>
                <li<?= (preg_match('/main/i', $func) ? ' class="active"' : '')?>><a href="/?func=user.main"><i class="icon-user icon-white"></i> <?= 'Кабинет'?></a></li>
              <li class="divider-vertical"></li>
                <li<?= (preg_match('/contacts|mail/i', $func) ? ' class="active"' : '')?>><a href="/?func=user.contacts"><i class="icon-envelope icon-white"></i> <?= 'Почта'?><span id="counterMail"><?= ($counter['mail'] > 0 ? '<span class="counter">'.$counter['mail'] . '</span>' : '')?></span></a></li>
              <li class="divider-vertical"></li>
                <li<?= (preg_match('/journal/i', $func) ? ' class="active"' : '')?>><a href="/?func=user.journal"><i class="icon-bell icon-white"></i> <?= 'Журнал'?><span id="counterJurnal"><?= ($counter['journal'] > 0 ? '<span class="counter">'.$counter['journal'] . '</span>' : '')?></span></a></li>
              <li class="divider-vertical"></li>
                <? if ($level > 1) { ?>
                <li<?= (preg_match('/admin/i', $func) ? ' class="active"' : '')?>><a href="/?func=admin"><i class="icon-th-large icon-white"></i> <?= 'Админка'?><span id="counterAdmin"><?= ($counter['admin'] > 0 ? '<span class="counter">'.$counter['admin'] . '</span>' : '')?></span></a></li>
                <? } ?>
              <? } else { ?>
               <li<?= (preg_match('/auth/i', $func) ? ' class="active"' : '')?>><a href="/?func=user.auth"><i class="icon-lock icon-white"></i> <?= 'Вход'?></a></li>
             <li class="divider-vertical"></li>
               <li<?= (preg_match('/reg/i', $func) ? ' class="active"' : '')?>><a href="/?func=user.reg"><i class="icon-leaf icon-white"></i> <?= 'Регистрация'?></a></li>
              <? } ?>
             <li class="divider-vertical"></li>
            </ul>

            <ul class="nav">
              <li class="divider-vertical"></li>
              <li<?= ($func == 'home' ? ' class="active"' : '')?>>
                <a href="/"><?= 'Главная'?></a>
              </li>
              <li class="divider-vertical"></li>
              <li<?= ($func == 'votes' ? ' class="active"' : '')?>>
                <a href="/?func=votes">Отзывы</a>
              </li>
              <li class="divider-vertical"></li>
              <li<?= ($func == 'shop.statistics' ? ' class="active"' : '')?>>
                <a href="/?func=shop.statistics">Статистика</a>
              </li>
              <li class="divider-vertical"></li>
            </ul>

  </div>
</div>


<div class="container-fluid">
  <div class="row-fluid">
      <div class="well">
      

<?
if (isset($err)) {
    if (is_array($err)) {
        foreach ($err AS $_err) {
?>
            <div class="alert alert-error" style="margin: 2px;">
             <button type="button" class="close" data-dismiss="alert">&times;</button>
             <?= $_err?> 
            </div>
<?
        }
    } else {
?>
        <div class="alert alert-error" style="margin: 2px;">
         <button type="button" class="close" data-dismiss="alert">&times;</button>
         <?= $err?>
        </div>
<?
    }
}

if (isset($_SESSION['message']) && $_SESSION['message']) {
  $messages = $_SESSION['message'];
  $_SESSION['message'] = null;
}

if (isset($messages)) {
    if (is_array($messages)) {
        foreach ($messages AS $_messages) {
?>
            <div class="alert alert-success" style="margin: 2px;">
             <button type="button" class="close" data-dismiss="alert">&times;</button>
             <?= $_messages?> 
            </div>
<?
        }
    } else {
?>
  <div class="alert alert-success" style="margin: 2px;">
   <button type="button" class="close" data-dismiss="alert">&times;</button>
   <?= $messages?>
  </div>
<?
    }
}
?>
      
        <div class="navbar-center">
          <div class="navbar-header">
            <div class="logotype">
            </div>


            
            <div class="navbar-inline">
              <div class="navbar">
                <div class="navbar-inner">
                  <ul class="nav">


                      <li class="divider-vertical"></li>
                      <li<?= (preg_match('/shop|goods/i', $func) ? ' class="active"' : '')?>>
                      <a href="/shop/"><i class="icon-shopping-cart"></i> <?= 'Магазин'?></a>
                        </li>




                    <li class="divider-vertical"></li>
                    <li<?= ($func == 'news' ? ' class="active"' : '')?>>
                      <a href="/news.html"><i class="icon-globe"></i> <?= 'Новости'?></a>
                    </li>
                    <li class="divider-vertical"></li>
                    <li<?= ($func == 'chat' ? ' class="active"' : '')?>>
                      <a href="/?func=chat"><i class="icon-pencil"></i> <?= 'Гостевая'?></a>
                    </li>
                    <li class="divider-vertical"></li>
                    <li<?= ($func == 'contacts' ? ' class="active"' : '')?>>
                      <a href="/?func=contacts"><i class="icon-bookmark"></i> <?= 'Контакты'?></a>
                    </li>
                    <li class="divider-vertical"></li>
                    <li<?= ($func == 'faq' ? ' class="active"' : '')?>>
                      <a href="/?func=faq"><i class="icon-tags"></i> <?= 'FAQ'?></a>
                    </li>
                    <li class="divider-vertical"></li>
                  </ul>
                </div>
              </div>
            </div>
               <!--  
            <div class="navbar-text pull-right">
              <div class="navbar-text2">
			  
			  
                E-mail: <?= $system['email']?><br />
                WMID: <a target="_blank" href="https://passport.webmoney.ru/asp/CertView.asp?wmid=<?= $system['wmid']?>"><?= $system['wmid']?></a><br />
                ICQ: <?= $system['icq']?>
				
              </div>
            </div>-->
          </div>
        </div>

<?
if ($func == 'home2') {
  $ads_rekl = $sql -> select("SELECT * FROM `ads` WHERE `pays` = '1' AND `time_last` > '" . time() . "' AND `type` = 'goods' ORDER BY `time_pays` DESC LIMIT 5");
  
  if (is_array($ads_rekl)) {
    
    ?>
    <div class="main_razd">
    Рекомендуем
    </div>
    
    <div class="nav1">
    <?
      foreach($ads_rekl AS $rekl) {
        $goods = $sql -> fetch("SELECT * FROM `shop_goods` WHERE `id` = '$rekl[id_goods]'");
        echo '<a href="/goods/' . $rekl['id_goods'] . '" style="' . ($rekl['color'] ? 'color: ' . $rekl['color'] . '; ' : '') . 
        ($rekl['fonts'] == 1 ? 'font-weight: bold;' : '') . '"><i class="icon-thumbs-up"></i> ' . text($rekl['name']) . '</a> <span class="on">' . $goods['wmr'] . ' wmr</span><br />';
      }  
    ?></div><?  
  }
}

if ($system['title'] != null AND isset($user))
{
	$url_title = esc($system['title']);
	$url = esc($_SERVER['REQUEST_URI']);
	
	if ($user['url_set'] == 0)
	{
		$url_title = 'Неизвестно';
		$url = '/';
	}
	$sql -> update("UPDATE `users` SET `url_title` = '{$url_title}' , `url_city` = '{$url}' WHERE `id` = '{$user['id']}' LIMIT 1");
}
?>