<?
function title($title=NULL)
{
global $set;
global $user;
if ($set['web']==false)
{
if ($title==NULL)$title=$set['title'];

$title=$set['title'];



echo "<div class='foot'>\n";
echo "<center>$title</center></div>";
/*
echo "<div class='rekl'>\n";
rekl(1);
echo "</div>\n";*/
}
#################
function aut(){}
#################

echo "<style type='text/css'>
.up_panel {
color: #9999ff;
padding: 2px;
margin: 0px;
line-height: 17px;
}
.up_panel a {
color: #fff;
}
.event {
color: yellow;
}
.date {
text-align: right;
color: black;
margin: 1px;
padding: 1px;
background: #efebef;
border: 1px solid #636563;
}
</style>";


if ($set['web']==false)
{

global $user;
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);

$jn=mysql_result(mysql_query("SELECT COUNT(*) FROM `jurnal` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);

$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);

$zoz = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE `to` = '$user[id]'"), 0);



if ($user['up_panel'] == 0)
{

echo "<table style='width:100%' cellspacing='0' cellpadding='0'><tbody><tr>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
echo "<div class='aut_n'><a href='/umenu.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/mobdrug.png'></a>";
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($user['pol'] == 1) {
echo "<div class='aut_n'><a href='/info.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/man.png' alt='Я' /></a>";
} else {
echo "<div class='aut_n'><a href='/info.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/woman.png' alt='Я' /></a>";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($k_new!=0 && $k_new_fav==0) {
echo "<div class='aut_n'><a href='/new_mess.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/mess.png'> <span class='event'>$k_new</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/konts.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/mess.png'></a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($jn>0) {
echo "<div class='aut_n'><a href='/jurnal.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/journal.png'> <span class='event'>$jn</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/jurnal.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/journal.png'></a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($lenta>0) {
echo "<div class='aut_n'><a href='/lenta.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/lenta.png'> <span class='event'>$lenta</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/lenta.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='/images/lenta.png'></a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE `to` = '$user[id]' LIMIT 1"), 0) > 0)
{
echo "<div class='aut_n'><a href='/frend_new.php' style='text-align:center;display:block;padding:1px;font-size:small;'><img src='style/images/friendship.gif'> <span class='event'>$zoz</span></a>\n";
}
echo "</td>";

echo "</tr></tbody></table>";

}
elseif ($user['up_panel'] == 1)
{
echo "<table style='width:100%' cellspacing='0' cellpadding='0'><tbody><tr>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
echo "<div class='aut_n'><a href='/umenu.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Старт</a>";
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
echo "<div class='aut_n'><a href='/info.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Я</a>";
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($k_new!=0 && $k_new_fav==0) {
echo "<div class='aut_n'><a href='/new_mess.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Почта <span class='event'>$k_new</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/konts.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Почта</a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($jn>0) {
echo "<div class='aut_n'><a href='/jurnal.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Журнал <span class='event'>$jn</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/jurnal.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Журнал</a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;white-space:nowrap;'>";
if ($lenta>0) {
echo "<div class='aut_n'><a href='/lenta.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Лента <span class='event'>$lenta</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/lenta.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Лента</a>\n";
}
echo "</td>";

echo "</tr></tbody></table>";

}
else
{

echo "<table style='width:100%' cellspacing='0' cellpadding='0'><tbody><tr>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
echo "<div class='aut_n'><a href='/umenu.php' style='text-align:center;display:block;padding:1px;font-size:small;'>С</a>";
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
echo "<div class='aut_n'><a href='/info.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Я</a>";
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($k_new!=0 && $k_new_fav==0) {
echo "<div class='aut_n'><a href='/new_mess.php' style='text-align:center;display:block;padding:1px;font-size:small;'>П <span class='event'>$k_new</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/konts.php' style='text-align:center;display:block;padding:1px;font-size:small;'>П</a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;border-right: 1px solid #9c9aff;white-space:nowrap;'>";
if ($jn>0) {
echo "<div class='aut_n'><a href='/jurnal.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Ж <span class='event'>$jn</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/jurnal.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Ж</a>\n";
}
echo "</td>";

echo "<td style='vertical-align:top;width:20%;white-space:nowrap;'>";
if ($lenta>0) {
echo "<div class='aut_n'><a href='/lenta.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Л <span class='event'>$lenta</span></a>\n";
} else {
echo "<div class='aut_n'><a href='/lenta.php' style='text-align:center;display:block;padding:1px;font-size:small;'>Л</a>\n";
}
echo "</td>";

echo "</tr></tbody></table>";

}




echo "</div>";

if ($k_new_fav!=0)
echo "<b><a href='/new_mess.php'><img src='/style/icons/mess_fav.png' alt='$k_new_fav' /> Сообщени".($k_new_fav==1?'е':'я')."</a></b><br />\n";

$admin_settings=mysql_fetch_array(mysql_query("SELECT * FROM `admin_settings`"));
if ($admin_settings["udacha"]==1){
$money=mysql_result(mysql_query("SELECT COUNT(*) FROM `udacha_yes` WHERE `user`='$user[id]'"),0);
if($money>0){echo '<img src="/style/icons/1016.gif" alt="" class="icon"/> <a href="/object/udacha.php">Вам улыбнулась удача!</a><br />';
}
}

$knj=mysql_result(mysql_query("SELECT COUNT(*) FROM `present_jurnal` WHERE `id_user` = '$user[id]' AND `read` = '0'"), 0);
if ($knj>0)
echo "<a href='/present/jurnal.php' title='Вам подарков'>$knj <img src='/style/images/present--plus.png'></a>\n";

$k_n_s_zak=mysql_result(mysql_query("SELECT COUNT(`forum_zakl`.`id_them`) FROM `forum_zakl` LEFT JOIN `forum_p` ON `forum_zakl`.`id_them` = `forum_p`.`id_them` AND `forum_p`.`time` > `forum_zakl`.`time` WHERE `forum_zakl`.`id_user` = '$user[id]' AND `forum_p`.`id` IS NOT NULL"),0);
if ($k_n_s_zak>0)
echo "<a href='/zakl.php' title='Новые сообщения в закладках'>Сообщения в закладках ($k_n_s_zak)</a><br />\n";

echo "</div>";

if ($user['time']==1)echo '<div class="date">';
if ($user['time']==1)echo date("H:i");
if ($user['time']==1)echo '</div>';


//echo "<div class='up_panel'>";

} else {
//echo "<marquee>Для того, чтобы пользоваться всеми возможностями Xhata.Su необходимо пройти . Если Вы еще не зарегистрированы, то Вам необходимо пройти процесс  Регистрации</a>.</marquee>\n";
echo "</div>\n";
echo "<div class='foot'> <img src='/xhata/glav/glav.png' alt=''/> <a href='/aut.php'><font color='black'>Вход</font></a> | <img src='/xhata/glav/familiya.png' alt='' /> <a href='/reg.php'><font color='red'>Регистрация</font></a></div>\n";

}
echo "</div>\n";
}
}