<?

if ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) {
    define( 'ROOT', 'http://'.$_SERVER['HTTP_HOST'] );
    define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );
    session_start();
    header( 'Content-type: text/html; charset=windows-1251' );
    include_once ROOT_DIR . '/engine/config.php';
} else {
    if ( !defined( 'MISOFT' ) ) { exit(); }
}

if ( !isset( $_SESSION['iduser'] ) ) {
    $advButton = '<li><a href="/adddyn" ><span style="font-size: 13px;" class="glyphicon glyphicon-bullhorn"></span> Реклама</a></li>';
	$payButton = '<li><a href="/serfing" ><span style="font-size: 13px;" class="glyphicon glyphicon-usd"></span> Заработать</a></li>';
	$ratingButton = '';
	$topButton = '';
	
} else {
	$advButton = '';
	$payButton = '';
	$ratingButton = '<li><a href="/status" ><span style="font-size: 13px;" class="glyphicon glyphicon-star-empty"></span> Карьера</a></li>';
	$topButton = '<li><a href="/top=rating" ><span style="font-size: 13px;" class="glyphicon glyphicon-fire"></span> Топ</a></li>';
	$sql_basket = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM basket WHERE iduser = '" . $_SESSION['iduser'] . "'" ) );
	$sql_events = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM developments_user WHERE iduser = '" . $_SESSION['iduser'] . "' AND status = '1'" ) );
}
?>
<div ><img class="logotip_top" src="/theme/images/logotip.png"/><div class="topMenuLeftPix hidden-md-down"></div></div>
<nav class="topMenuRight hidden-md-down">
  <ul>
	<li><a href="/home" ><div style="font-size: 13px;" class="glyphicon glyphicon-home"></div> Главная</a></li>		
	<?=$advButton?>
	<?=$payButton?>
	<li><a href="/news" ><span style="font-size: 13px;" class="glyphicon glyphicon-globe"></span> Новости</a></li>
	<li><a href="/forum" ><span style="font-size: 13px;" class="glyphicon glyphicon-comment"></span> Форум</a></li>
	<?=$ratingButton?>
	<li><a href="/catalog" ><span style="font-size: 13px;" class="glyphicon glyphicon-list-alt"></span> Каталог</a></li>
	<?=$topButton?>
  </ul>
</nav>
<? if ( isset( $_SESSION['iduser'] ) ) { ?>
	<script type="text/javascript">
		function open_acn() {
			if ($('.open_acn').css('display') == 'none') {
				$('.open_acn').fadeIn(0);
				$('.imgoadd').fadeOut(0);
				$('.imgoend').fadeIn(0);
			} else {
				$('.open_acn').fadeOut(0);
				$('.imgoend').fadeOut(0);
				$('.imgoadd').fadeIn(0);
			}
		}
		
		function open_basket() {
			location.href = ('/basket');
		}
		
		function open_events() {
			location.href = ('/events');
		}
	</script>
	<div class="hidden-md-down block_top_accaunt">
	  <div class="fa fa-bell events_button" onclick="open_events();return false"><? if ( $sql_events['count'] > 0 ) { ?><div class="events_border"><?=$sql_events['count']?></div><? } ?></div>
	  <div onclick="open_basket();return false" class="fa fa-shopping-basket basket_button" style=""><? if ( $sql_basket['count'] > 0 ) { ?><div class="basket_border"><?=$sql_basket['count']?></div><? } ?></div>
	  <img class="avatar_acn" onclick="open_acn();return false" src="/temp/avatar/<?=$config_user['avatar']?>"/>
	</div>
	<div class="topMenuRightPix hidden-md-down"></div>
	<div class="accaunt_panel hidden-md-down">
	  <div class="open_acn_buton"  onclick="open_acn();return false">
		<img class="imgoadd" src="/theme/images/accaunt_open.png"/>
		<img class="imgoend" src="/theme/images/accaunt_openend.png"/>
	  </div>
	</div>	
<? } else { ?>
<nav class="topMenuRightAUTH hidden-md-down">
  <ul>
	<li><a href="/login" ><span style="font-size: 13px;" class="glyphicon glyphicon-user"></span> Вход</a></li>
    <li><a href="/registration" ><span style="font-size: 13px;" class="glyphicon glyphicon-plus"></span> Регистрация</a></li>
  </ul>
</nav>
<? } ?>