<?
if (!defined('webid')) {
    exit();
}
?>
<h3 style="border-bottom: 1px dotted #cccccc; color: #1c62b9; text-shadow: 0 1px 0 #fafafa;">Стена пользователя</h3>
<script type="text/javascript">
$('#id').keyup(function(){
    $('#ss').attr('href', 'id'+$(this).val());
});
$('img#podarok').tipTip();
$('.onb').tipTip();
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="stena">
    <thead>
        <th style="background: #ebebeb; padding: 5px;" align="left">Поиск по ID пользователя:&nbsp;&nbsp;<input type="text" name="id" id="id" class="val" />&nbsp;<a href="id1" class="big_btn" id="ss">Поиск</a></th>
    </thead>
    <?
    $id = intval($_GET['id']);
    $_COOKIE['referer'] = $id;
    $infus = mysql_query("SELECT * FROM tb_users WHERE id = '$id'");
    if (mysql_num_rows($infus) < 1) {
        echo '<tr><td align="center" style="color: #800000; background: #fababa; padding:5px">Пользователь с ID: ' . $id . ' не найден!</td></tr>';
    } else {
        $row = mysql_fetch_array($infus);
        if ($row['finestatus'] != '0') {
            $reys = 'Штрафник';
            $usstatus = '';
            $reycolor = 'color: #FF0000; text-shadow: 0 0 0.2em #FF0000;';
        } else
        if ($row['pemail'] == '' AND $row['finestatus'] == '0') {
            $reys = 'Прохожий';
            $usstatus = '';
            $reycolor = 'color: #8D950B; text-shadow: 0 0 0.2em #8D950B;';
        } else
		if ($row['reyting'] >= 1 and $row['reyting'] < 10 and $row['pemail'] != '' AND $row['finestatus'] == '0') {
            $reys = 'Стажер';
            $usstatus = '';
            $reycolor = 'color: #8D950B; text-shadow: 0 0 0.2em #8D950B;';
        } else
        if ($row['reyting'] >= 10 and $row['reyting'] < 100 and $row['pemail'] != '' AND $row['finestatus'] == '0') {
            $reys = 'Рабочий';
            $usstatus = '';
            $reycolor = 'color: #8D950B; text-shadow: 0 0 0.2em #8D950B;';
        } else
        if ($row['reyting'] >= 100 and $row['reyting'] < 250 and $row['pemail'] != '' AND $row['finestatus'] == '0') {
            $reys = 'Бригадир';
            $usstatus = '';
            $reycolor = 'color: #8D950B; text-shadow: 0 0 0.2em #8D950B;';
        } else
        if ($row['reyting'] >= 250 and $row['reyting'] < 600 and $row['pemail'] != '' AND $row['finestatus'] == '0') {
            $reys = 'Мастер';
            $usstatus = '<img src="theme/img/status/master.png" width="26" height="40" class="usstatus2" />';
            $reycolor = 'color: #8D950B; text-shadow: 0 0 0.2em #8D950B;';
        } else
        if ($row['reyting'] >= 600 and $row['reyting'] < 1000 and $row['pemail'] != '' AND $row['finestatus'] == '0') {
            $reys = 'Бизнесмен';
            $usstatus = '<img src="theme/img/status/s_master.png" width="26" height="40" class="usstatus2" />';
            $reycolor = 'color: #800000; text-shadow: 0 0 0.2em #800000;';
        } else
        if ($row['reyting'] >= 1000 and $row['pemail'] != '' AND $row['finestatus'] == '0') {
            $reys = 'Олигарх';
            $usstatus = '<img src="theme/img/status/oligarh.png" width="26" height="40" class="usstatus2" />';
            $reycolor = 'color: #1c62b9; text-shadow: 0 0 0.2em #1c62b9;';
        } else {
            $reys = 'Никто';
            $usstatus = '';
            $reycolor = 'color: #8D950B';
        }

        if ($row['user_status'] == 'admin') {$reys = 'Админ';}
        if ($row['ban'] == 1 AND $row['finestatus'] == '0') {$reys = '<font color="#800000">Заблокирован</font>';}
        
        if ($row['taskreyt'] < 0) {
            $trc = 'color: #800000';
            $pl = '';
        }
        if ($row['taskreyt'] == 0) {
            $trc = 'color: #cccccc';
            $pl = '';
        } else
        if ($row['taskreyt'] > 0) {
            $trc = 'color: #8D950B';
            $pl = '+';
        }
        if ($row['family'] == 1) {
            $family = 'мужской';
        } else {
            $family = 'женский';
        }
        if ($row['lastlogdate'] == '') {
            $lastjoin = '-';
        } else {
            $lastjoin = date('d.m.Y H:i ', $row['lastlogdate']);
        }
        $ref1 = mysql_fetch_array(mysql_query("SELECT count(*)as count FROM tb_users WHERE referer = '" . $row['id'] . "'"));
		///Статус онлайн
		$us_online = mysql_query("SELECT id FROM online WHERE iduser = '$row[id]'");
        if (mysql_num_rows($us_online) > 0) {
            $img_online = '<font color="#84A91E">онлайн</font>';
            } else {
            $img_online = '<font color="#800000">оффлайн</font>';
        }
		///првоеряем активность конкурсов
		$active_ref_kon = mysql_fetch_array( mysql_query( "SELECT(SELECT count(*) FROM konkurs_ref WHERE referername = '".$row['id']."' AND status = '1')active_kon_ref"));
		if($active_ref_kon['active_kon_ref'] > 0) { 
			$active_status_ref = '<img style="margin-bottom: -2px;" src="/theme/images/ref_kon_on.png" />';
		} else { 
			$active_status_ref = '<img style="margin-bottom: -2px;" src="/theme/images/ref_kon_off.png" />';
		}
		?>
        <tr>
            <td class="lt" style="border-bottom: 0;">
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td rowspan="12" width="60" align="center" valign="top"><div style="position: relative;"><img src="avp/<?=$row['avatar']?>" width="60" height="60" class="avatar" /><?=$usstatus?></div>
						<div style="margin-top: -3px; margin-left: -5px;"><?=$img_online?></div>
						</td>
                        <td width="50%" class="lt">ID</td>
                        <td width="50%" class="rt"><?=$row['id']?>&nbsp;&nbsp;<a href="/mail/new<?=$row['id']?>"><img src="theme/img/mail/mail.png" width="16" height="12" border="0" style="position: relative; top: 1px;" /></a></td>
                    </tr>
                    <tr>
                        <td class="lt">Ник</td>
                        <td class="rt"><?=$row['username']?></td>
                    </tr>
                    <tr>
                        <td class="lt">Пол</td>
                        <td class="rt"><?=$family?></td>
                    </tr>
                    <tr>
                        <td class="lt">Статус</td>
                        <td class="rt"><span style="<?=$reycolor?>"><?=$reys?></span></td>
                    </tr>
					<tr>
                        <td class="lt">Рейтинг</td>
                        <td class="rt"><span style="color: #FF9966;"><?=number_format($row['reyting'], 0, '.', '')?> </span>Баллов</td>
                    </tr>
                    <tr>
                        <td class="lt">Репутация в заданиях</td>
                        <td class="rt"><span style="<?=$trc?>"><?=$pl . $row['taskreyt']?></span></td>
                    </tr>
                    <tr>
                        <td class="lt">Откуда</td>
                        <td class="rt"><?=$row['country']?></td>
                    </tr>
                    <tr>
                        <td class="lt">Регистрация</td>
                        <td class="rt"><?=date('d.m.Y H:i ', $row['joindate'])?></td>
                    </tr>
                    <tr>
                        <td class="lt">Последний визит</td>
                        <td class="rt"><?=$lastjoin?></td>
                    </tr>
                    <tr>
                        <td class="lt">Рефералов</td>
                        <td class="rt"><?=$ref1['count']?></td>
                    </tr>
					<tr>
                        <td class="lt">Конкурсы рефералам</td>
                        <td class="rt"><?=$active_status_ref?></td>
                    </tr>
					<tr>
                        <td class="lt" style="border-bottom: 0;">Авторефбек рефералам</td>
                        <td class="rt" style="border-bottom: 0;"><?=$row['autoback']?>%</td>
                    </tr>
				</table>
            </td>
        </tr>
        <?
        $pod = mysql_query("SELECT * FROM tb_gift WHERE tous = '$id'");
        if (mysql_num_rows($pod) > 0) {
            ?>
            <tr><td class="rt" style="border-bottom: 0;">
            <?
            while ($pd = mysql_fetch_array($pod)) {
                $pdus = mysql_fetch_array(mysql_query("SELECT username FROM tb_users WHERE id = '" . $pd['fromus'] . "'"));
                ?>
                <img src="theme/img/podarki/<?=$pd['gift']?>.png" width="48" height="48" title="<center><?=$pd['comms']?><br />Подарок от ID: <?=$pd['fromus']?> - <?=$pdus['username']?><br /><?=date('d.m.Y H:i', $pd['date'])?></center>" align="left" style="margin: 3px;" id="podarok" />
                <?
            }
            ?>
            </td></tr>
            <?
        }
        ?>
        <?if (isset($_SESSION["username"]) && isset($_SESSION["password"])){
        if ($byme['referer'] == 0 and $_SESSION['iduser'] != $id and $row['reyting'] >= 10) {
            $selfref = '<a href="#" class="big_btn" onclick="selfref(' . $id . ')">Стать рефералом</a>';
        } else {
            $selfref = '';
        }    
        ?>
        <script type="text/javascript">
        function showblock(bname) {
            if (document.getElementById(bname).style.display == 'none') {
                document.getElementById(bname).style.display = '';
            } else {
                document.getElementById(bname).style.display = 'none';
            }
            return false;
        }
        function sendwall(){
            $.post('ajax.php?func=addwall',{
                id: <?=$id?>,
                comms: $('.scomms').val()
            }, function(data) {
                if (data == 1) {
                    FLAX.Html.thread['flax'].repeat();
                } else {
                    $('#open').fadeIn(500);
                    $('#error').html(data);
                    setTimeout(function(){
                        $('#open').fadeOut(500);
                    }, 2000);
                }
            });
            return false;
        }
        function showgift(id) {
            $('#q_content').Qbox({
                'title': '',
                'width': 540,
                'height': 380,
                'fadespeed': 300,
                'url': 'gift.php',
                'param': 'id='+id
            });
            return false;
        }
        function selfref(tid) {
            $.post('ajax.php?func=addreferer',{
                id: tid
            }, function(data) {
                if (data == 1) {
                    FLAX.Html.thread['flax'].repeat();
                } else {
                    $('.opens').fadeIn(500);
                    $('#errors').html(data);
                    setTimeout(function(){
                        $('.opens').fadeOut(500);
                    }, 2000)
                }
            });
            return false;
        }
        </script>
		<tr class="opens" style="display: none;">
            <td colspan="2" style="background: #ebebeb;"><div id="errors"></div></td>
        </tr>
        <tr>
            <td style="background: #ebebeb; padding: 5px;" align="center"><a href="#" onclick="showblock('comms')" class="big_btn">Оставить комментарий</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="showgift(<?=$id?>)" class="big_btn">Сделать подарок</a>&nbsp;&nbsp;&nbsp;<?=$selfref?></td>
        </tr>
        <tr id="open" style="display: none;">
            <td id="error" style="border-bottom: 0;"></td>
        </tr>
        <tr id="comms" style="display: none;">
            <td style="background: #ebebeb; padding: 5px;" align="center"><textarea class="scomms"></textarea><br /><a href="#" onclick="sendwall()" class="big_btn">Отправить</a></td>
        </tr>
        <?
        } else {
            ?>
            <tr><td class="lt" style="background: #ebebeb;" align="center"><a href="/r=<?=$row['id']?>" class="big_btn" target="_blank">Регистрация</a></td></tr>
            <?
        }
    }
    ?>
</table>
<?
$wallcount = mysql_fetch_array(mysql_query("SELECT count(*) as count FROM tb_wall WHERE tous = '$id'"));
?>
<script type="text/javascript" src="theme/js/scrollpagination.js"></script>
<script type="text/javascript">
$(function(){
	$('#wallcont').scrollPagination({
		'contentPage': 'wallcomms.php?id=<?=$id?>',
		'contentData': {},
		'scrollTarget': $(window),
		'heightOffset': 1,
		'beforeLoad': function(){
			$('.loading').fadeIn();	
		},
		'afterLoad': function(elementsLoaded){
			 $('.loading').fadeOut();
			 var i = 0;
			 $(elementsLoaded).fadeInWithDelay();
			 if ($('#wallcont').children().size() > <?=$wallcount['count']?>){
			 	//$('#nomoreresults').fadeIn();
				$('#wallcont').stopScrollPagination();
			 }
		}
	});
	
	$.fn.fadeInWithDelay = function(){
		var delay = 0;
		return this.each(function(){
			$(this).delay(delay).animate({opacity:1}, 200);
			delay += 100;
		});
	};
		   
});
</script>
<div id="wallcont"></div>
<div align="center"><div class="loading"></div></div>