<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<span id="realtitle"><title><?= $system['title']?></title></span>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name='yandex-verification' content='49648f7b8180b68e' />
<meta name="application-name" content=""/>
<meta name="msapplication-tooltip" content=""/>
<meta name="msapplication-starturl" content="//<?= 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" rel="stylesheet">
<link href="<?= CSS?>bootstrap-responsive.css" rel="stylesheet">
<link href="<?= CSS?>ic.css" rel="stylesheet">
<link href="<?= CSS?>main.css" rel="stylesheet">
<link rel="yandex-tableau-widget" href="test.json" />

<!--[if lt IE 9]>
      <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script src="<?= JSC?>bootstrap.min.js" type="text/javascript"></script>
<link rel="shortcut icon" href="<?= ICONS?>favicon.png">
<?if ($level > 0) { ?>
        <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>
<?}?>
</head>
<body>
<div class="body">

<div class="logotype">
  <div class="brands"><a href="http://4i4i.ru/?"><i class="ic-cart ic-logo"></i> Магазин</a></div>
</div>

<span id="jq">
  
        <div id="mailer"></div> 

        <script>  
        function show()  
        {  
            $.ajax({  
                url: "/AjaxCount.php",  
                cache: false,  
                success: function(html){  
                    $("#mailer").html(html);  
                }  
            });  
        }  
        $(document).ready(function(){  
            show();  
            setInterval('show()',10000);  
        });  
        </script>
		
    </span>

<span id="noscript">
<div class="nav-panel">
  <ul>
<?
    //<span class="hidden-phone">
    if ($level > 0) { ?>
        <li><a href="/?func=user.main"><i class="ic-user"></i><span class="hidden-phone">Кабинет </span></a></li>

        <li><a href="/?func=user.contacts"><i class="ic-mail-4"></i><span class="hidden-phone">Почта </span><?= ($counter['mail'] > 0 ? '<span class="counter">'.$counter['mail'] . '</span>' : '')?></a></li>
        <li><a href="/?func=user.journal"><i class="ic-bell-alt"></i><span class="hidden-phone">Журнал </span> <?= ($counter['journal'] > 0 ? '<span class="counter">'.$counter['journal'] . '</span>' : '')?></a></li>
        
<? if ($level > 1) { ?>
        <li><a href="/?func=admin"><i class="ic-th-large"></i><span class="hidden-phone">Админка </span><?= ($counter['admin'] > 0 ? '<span class="counter">'.$counter['admin'] . '</span>' : '')?></a></li>
        <? } ?>
		
    <? } else { ?>
       <li><a href="/?func=user.auth"><i class="ic-lock-open-filled"></i>Вход</a></li>
       <li><a href="/?func=user.reg"><i class="ic-pencil"></i>Регистрация</a></li>
    <? } ?>
  </ul>
</div>
</span>
    <script>
      $('#noscript').hide();
      $('#jq').show();
    </script>
	
<div class="header-title">
  <div class="title-text"><?= $system['title']?></div>
</div>

<?
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>
<?
    }
}
?>

<?
if ($func == 'home') {
  $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">
    <b>Рекомендуем</b>
    </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");
}
?>