<?

function title($title=NULL)
{
global $set;
global $user;

if ($title==NULL)$title=$set['title'];
echo "<div class='rekltitle'>";
rekl(2);
echo "</div>\n";
echo "<div class='title'>\n";

echo "$title\n";

echo "</div>\n";
echo "<div class='pochta'>\n";
if (isset($user))
{
$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);


if ($k_new!=0 && $k_new_fav==0)
echo "<img src='/style/icons/mess0.png' alt='$k_new' /> <a href='/new_mess.php'><u>+ $k_new</u></a> \n";


if ($k_new_fav!=0)
echo "<a href='/new_mess.php'><img src='/style/icons/mail.gif' alt='$k_new_fav' /></a> \n";

$knj=mysql_result(mysql_query("SELECT COUNT(*) FROM `present_jurnal` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0);
if ($knj>0)
echo "<img src='/style/icons/pod16.gif' alt='' class='icon'/> <a href=\"/present/jurnal.php\" title=\"Gifts\"><u>+ $knj</u></a> \n";


$nj=mysql_result(mysql_query("SELECT COUNT(*) FROM `jurnal` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($nj>0)echo "<img src='/style/icons/uv.png' alt='' /> <a href=\"/jurnal.php\" title=\"Jurnal\"><u>+ $nj</u></a> \n";

$nj=mysql_result(mysql_query("SELECT COUNT(*) FROM `deist` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($nj>0)echo "<img src='/dei/ruka.gif' alt='' /> <a href=\"/deist.php\" title=\"Jurnal\"><u>+ $nj</u></a> \n";

$nj=mysql_result(mysql_query("SELECT COUNT(*) FROM `ocenka` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);
if ($nj>0)echo "<img src='/style/icons/5.png' alt='' /> <a href=\"/ocenka.php\" title=\"Jurnal\"><u>+ $nj</u></a> \n";

$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);
if($lenta>0) echo "<img src='/style/icons/lenta.gif' alt='' class='icon'/> <a href='/lenta.php'><u>+ $lenta</u></a> ";

$obsuzh = mysql_result(mysql_query("SELECT COUNT(*) FROM `obsuzh` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);
if($obsuzh>0) echo "<img src='/style/icons/irc14.png' alt='' class='icon'/> <a href='/obsuzh.php'><u>+ $obsuzh</u></a> ";

$new_g=mysql_result(mysql_query("SELECT COUNT(*) FROM `myguests` WHERE `id_ank` = '$user[id]' AND `read`='1'"),0);
if($new_g!=0)echo "<img src='/style/icons/eye.png' alt='' /> <a href='/myguests.php'><u>+ $new_g</u></a> \n";

$zoz = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE `to` = '$user[id]'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0) > 0)
{
echo "<img src='/style/icons/user_add.png' alt='' /> <a href='/frend_new.php'><u>+ $zoz</u></a> ";
}

$zoz = mysql_result(mysql_query("SELECT COUNT(*) FROM `fanat_obm` WHERE `to` = '$user[id]'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `fanat_obm` WHERE `to` = '$user[id]' LIMIT 1"), 0) > 0)
{
echo "<img src='/style/icons/readers.gif' alt='' /> <a href='/fanat_obm.php'><u>+ $zoz</u></a> ";
}

$k_n_s_zak=0;
$q23=mysql_query("SELECT `id_them`, `time` FROM `forum_zakl` WHERE `id_user` = '$user[id]'");
while ($zakl = mysql_fetch_array($q23))
{
$k_n_s_zak+=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$zakl[id_them]' AND `time` > '$zakl[time]'"),0);
}
if ($k_n_s_zak>0)echo "<img src='/forum/forum.gif' alt='' /> <a href=\"/zakl.php\" title=\"New Forum\"> <u>+ $k_n_s_zak</u></a><br/>\n";
}
echo "</div>\n";
if ($user['vkl_title']==1)
{
if(isset($user)){
echo "<div class='mytitle'>\n";
if ($user['show_title']==0)
{
echo " <a href='/statusx.php'>\n";
echo "".online($user['id'])." </a>\n";
echo " <a href='/info.php'><span style=\"color:$user[ncolor]\">$user[nick]</span></a> \n";
if($user['rating']>=0 && $user['rating']<=5)echo "<a href='/info/help.php'> (Help)</a>";
}
if ($user['show_title']==1)
{
echo " <a href='/statusx.php'>\n";
echo "".online($user['id'])." </a>\n";
echo " <a href='/umenu.php'><span style=\"color:$user[ncolor]\">$user[nick]</span> [K]</a> \n";
if($user['rating']>=0 && $user['rating']<=5)echo "<a href='/info/help.php'> (Help)</a>";
}
echo "</div>\n";

echo '</div>';
if ($user['ank_o_sebe']!=NULL)echo "\n";
else
echo "<div class='menu_razd'><img src='/style/serv.png' alt='' /> <a href='/anketa.php?id=$user[id]'><font color='red'>Внимание! Заполните данные в анкете!</font></a></div>\n";

}
}
}
?>