<?
function title()
{
	global $user;	
	
	if (isset($user))
	{
		global $set;		
		
		if ($set['web'] == false)
		{			
			?><table style="width:100%" cellspacing="0" cellpadding="0"><tr><?
		
			$k_new = mysql_result(mysql_query("SELECT COUNT(`mail`.`id`) FROM `mail`
			 LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]'
			 WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"),0);
			 
			$k_new_fav = mysql_result(mysql_query("SELECT COUNT(`mail`.`id`) FROM `mail`
			 LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]'
			 WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"),0); // Почта			
			 
			 $lenta = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `tape` WHERE `id_user` = '$user[id]' AND `read` = '0' "),0); // Лента			
			 
			 $discuss = mysql_result(mysql_query("SELECT COUNT(`count`) FROM `discussions` WHERE `id_user` = '$user[id]' AND `count` > '0' "),0); // Обсуждения			
			 
			 $k_frend = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$user[id]'"), 0); // Друзья			
			 
			 $k_notif = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `notification` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0); // Уведомления			 
			 
			 $comm_lenta = mysql_result(mysql_query("SELECT COUNT(`read`) FROM `comm_lenta` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0); // сообщества		 
			 
			 $new_g = mysql_result(mysql_query("SELECT COUNT(*) FROM `my_guests` WHERE `id_ank` = '$user[id]' AND `read`='1'"),0);
			 
			 
			 
			 	 
			/*
			=================================
			Страничка
			=================================
			*/			
if  ($user['pol']==1){
$aa = 'off_1.gif';
}else{
$aa = 'off_0.gif';
}
			?>
			<td class="auts">
			<a href="/info.php?id=<?=$user['id']?>"><center><img src="/style/user/<?=$aa?>" alt="Lafac.Ru" /></center></a>
			</td>
			<?
			
			/*
			=================================
			Почта
			=================================
			*/			
			
			?><td class="auts"><?
			if ($k_new != 0 && $k_new_fav == 0)
			{				
				?><a href="/new_mess.php"><center><img src="/style/icons/icon_pochta22.gif" alt="Lafac" /><span class='mess_count'><?=$k_new?></span></center></a><?
			}
			else
			{
				?><a href="/konts.php"><center><img src="/style/icons/nav_pochta.gif" alt="Lafac" /></center></a><?
			}
			?></td><?
			
			
			
			/*
			=================================
			Обсуждения
			=================================
			*/
			if ($discuss > 0)
			{
				$j3 = 'discussions';
			}
			elseif ($k_notif > 0)
			{
				$j3 = 'notification';
			}
			else
			{
				$j3 = 'discussions';
			}			
			
			?>		
			<td class="auts">
			<a href="/user/<?=$j3?>/">
			<center><img src="/style/icons/journal_i.gif" alt="*" />
			<?
			// Cкладываем сумму счетчиков
			$k_ll = $k_notif + $discuss;
			
			if($k_ll > 0)
			{
				?>
				<span class='mess_count'><?=$k_ll?></span>
				<?
			}
			?>			
			</center></a></td>
			<?
			
			/*
			=================================
			Лента
			=================================
			*/
			
			if ($lenta > 0)
			{
				$j2 = 'tape';
			}
			elseif ($comm_lenta > 0)
			{
				$j2 = 'tape/comm.php';
			}
			else
			{
				$j2 = 'tape';
			}
			
			?>
			<td class='auts'>
			<a href="/user/<?=$j2?>/"><center><img src="/style/icons/lenta_i.gif" alt="Lafac" />
			<?
			// Cкладываем сумму счетчиков
			$k_l = $lenta + $comm_lenta;
			
			if($k_l > 0)
			{
				?>
				<span class='mess_count'><?=$k_l?></span>
				<?
			}
			?>
			</center></a>
			</td>
			<?
			/*
			=================================
			Друзья
			=================================
			*/			 
			
			if ($k_frend > 0)
			{
				?>
				<td class='auts'>
				<a href="/user/frends/new.php"><center><img src="/style/icons/icon_druzya.gif" alt="Lafac" />  <span class='mess_count'><?=$k_frend?></span></center></a>
				</td>
				<?
			}			
			
			/*
			=================================
			Обновить
			=================================
			*/
			
			?>
			<td class='auts'>
			<a href='/user/myguest/'><center><img src='/style/icons/guests.gif' alt='Lafac' />  	
			<?
			if($new_g > 0)
			{
				?>
				<span class='mess_count'><?=$new_g?></span>
				<?
			}
			?>
			</center></a></td>		
			</tr></table>
			<?
		}
		
	




//Если эфир включен ))
if (isset($_GET['efon']))
{
mysql_query("UPDATE `user` SET `g_guest` = 0 WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['message'] = 'Эфир успешно включен';
header("Location:?");
exit;
}
// Если эфир отключен
if (isset($_GET['efoff']))
{
mysql_query("UPDATE `user` SET `g_guest` = 1 WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['message'] = 'Эфир успешно скрыт';
header("Location: ?");
exit;
}






 // Эфир из беседки
 if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `guest`"), 0) > 0 && $_SERVER['PHP_SELF'] != '/guest/index.php')
 {
 
 	if($user['g_guest'] != 1)
	{
 $s_post = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest` WHERE time ORDER by id DESC limit 1"));
 echo " <div class='main'>";
 echo "Прямой эфир из <a href='/guest/'>чата</a>";
 echo "<span style='float:right;'><a href='?efoff'> <img src='/style/icons/delete.gif' title='Отключить чат на время'/> Скрыть</span></a>";
 echo "</div>";

 echo "<table style='width:100%' cellspacing='0'><tr>";
 echo "<td class='icon14'><center>";
 echo avatar($s_post['id_user'], true, 50);
 echo "</center></td>";
 echo "<td class='main_menu'>";

 echo group($s_post['id_user']) . user::nick($s_post['id_user'],1,1,1);
 if (isset($user) && $user['id']!=$s_post['id_user'] && $s_post['id_user']!=6)
 echo '[<a href="/guest/?response=' . $s_post['id_user'] . '">ответ</a>] ';
 echo ' <font style="font-size:11px; color: red;">(' . vremja($s_post['time']) . ')</font><br/><span class="text">';
 echo output_text($s_post['msg']);
 echo "</span></td></tr></table>";
	} else {
 echo " <div class='main'>";
 echo "Эфир из <a href='/guest/'>Гостевой</a>";
 echo "<span style='float:right;'><a href='?efon'><img src='/style/icons/ok.gif' title='Включить эфир из чата'/> Вкл.</a></span>";
 echo "</div>";
	}
 



 }















	
		
		
		
		
		
		
		
	}
	
}
?>