<?
echo "<div class='event'><h1>".($ank['id']==$ku['id']?"Общение":"<a href='?user=$ank[id]'>$anku[nick]</a> / Общение")."</h1></div>";
echo "<div class='content'><div class='block'><ul>";
if(isset($_GET['friend']))
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)==0)
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)!=0)mysql_query("DELETE FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
mysql_query("INSERT INTO `kolhoz_friends` SET `id_user` = '$ku[id]', `id_ank` = '$ank[id]'");
//echo "INSERT INTO `kolhoz_friends` SET `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'";
}
else mysql_query("DELETE FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
echo mysql_error();
}
elseif(isset($_GET['blacklist']))
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)==0)
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'"),0)!=0)mysql_query("DELETE FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
mysql_query("INSERT INTO `kolhoz_blacklist` SET `id_user` = '$ku[id]', `id_ank` = '$ank[id]'");
}
else mysql_query("DELETE FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]'");
echo mysql_error();
}


if(isset($_GET['makeanoffer']))
{
$cena=100;
if($ku['rubies']>=$cena)
{
if(isset($_GET['ok']))
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$cena)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_zags` SET `he` = '$ku[nick]', `she` = '$ank[nick]', `collective` = '$mc[id]', `time` = '$time'");
echo '<div class="feedback"><ul class="feedbackPanel"><li class="feedbackPanelINFO"><span class="feedbackPanelINFO">Вы сделали предложение девушке '.($anku[nick]).'. В случае отказа, вы сможете вернуть 80 рубинов, забрав заявление из ЗАГСа.</span></li></ul></div>';

}
else
{
echo "<li>
<span>Вы оплачиваете подачу заявления в ЗАГС</span>  <span></span><br>
<span>Стоимость</span>: <span><span class='nobr'><img width='16' height='16' src='/images/icons/ruby.png' alt='o'> <span class='title'>100</span></span></span>
</li>
<li class='pt'><img alt='' width='16' height='16' src='/images/icons/tick.png'> <a href='?communication=$ank[id]&makeanoffer&ok'><span>Да, подтверждаю</span></a></li>
<li><img alt='' width='16' height='16' src='/images/icons/cross.png'> <a href='?communication=$ank[id]&makeanoffer'><span>Нет, отказываюсь</span></a></li>";
echo "</ul></div>";
include_once 'inc/foot.php';
}
}
else no_rubies($cena-$ku['rubies']);
}



if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/pencil.png'> <a href='?mail&new_msg=$ank[id]'>Написать</a></li>";
echo "<li><img alt='' width='16' height='16' src='images/icons/mail_filter_all.png'> <a href='?mail".($ank['id']!=$ku['id']?"&history=$ank[id]":null)."'>Переписка</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/money.png'> ".($ku['rating']>=$ank['rating']?"<a href='?perevod=$ank[id]'>":null)."Переслать монеты".($ku['rating']>=$ank['rating']?"</a>":null)."</li>";
if($ank['id']!=$ku['id'] && $ku['status']==3)echo "<li><img alt='' width='16' height='16' src='images/icons/ruby.png'> <a href='?perevod2=$ank[id]'>Переслать рубины</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/gift_plus.png'> <a href='?presents=$ank[id]&do'>Подарить</a></li>";
echo "<li><img alt='' width='16' height='16' src='images/icons/gift.png'> <a href='?presents=$ank[id]'>Подарки</a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/favorite.png'> <a href='?communication=$ank[id]&friend'><span>".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_friends` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]' LIMIT 1"),0)==0?"В друзья":"Из друзей")."</span></a></li>";
if($ank['id']!=$ku['id'])echo "<li><img alt='' width='16' height='16' src='images/icons/ignore.png'> <a href='?communication=$ank[id]&blacklist'><span>".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_blacklist` WHERE `id_user` = '$ku[id]' AND `id_ank` = '$ank[id]' LIMIT 1"),0)==0?"В игнор":"Отменить игнор")."</span></a></li>";
if($ank['id']!=$ku['id'] && $ank['brak']=='' && $ku['brak']==''&& $mc['zags']==1 && $ank['pol']==0)echo "<li><img alt='' width='16' height='16' src='images/icons/bank.png'> <a href='?communication=$ank[id]&makeanoffer'>Сделать предложение<span></span></a></li>";
echo "</ul></div>";
include_once 'inc/foot.php';
?>