<?php
define('USERNAME_REQUIRED', TRUE);
define('ACCOUNT_REQUIRED', TRUE);
include('global.php');
define("THIS_SCRIPT", 'me');
$username = $core->EscapeString($_SESSION['username']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title><?php echo $sitename." - Me"; ?></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="Public/JS/jquery.history.js"></script>
	<script language="javascript"> 
	(function($){
		$(document).ready(function() {
			$('.Usersmotto').click(function()  {
				$('.Usersmotto').css("display", "none")
				$('.UserMotto').css("display", "block")
				$('.UserMotto').focus()
				return;
			});
	
			$('.UserMotto').blur(function()  {
				$('.UserMotto').css("display", "none")
				$.ajax({
					url: "functions/updatemotto.php?motto=" + $('.UserMotto').val(),
					async: false
				})
				$('.Usersmotto').html($('.UserMotto').val())
				$('.Usersmotto').css("display", "block")
				$('.Usersmotto').css("min-width", "200px")
				$('.Usersmotto').css("min-height", "30px")
				return;
			});
		});
	})(jQuery);
	</script>
<link type="text/css" rel="stylesheet" href="Public/Styles/<?php echo $currentstyle ?>/CSS/main.css" />
</head> 
 
<body> 
 
<div class="mainBox"> 
	<?php include("header.php"); ?>
	<?php include("system/homenav.php"); ?>

	<div class="mid" id="midcontent"> 

<div class="column" id="column1">

		<div class="myOverview">
			<div id="enter-hotel">
				<div class="open">
					<a href="client/?forwardid=2&roomid=1" target="ClientWndw" onclick="window.open('client/','ClientWndw','width=980,height=597');return false;"><?php echo $lang['enter_hotel']; ?><i></i></a><b></b>
				</div>
			</div>
			<div id="avatar-plate" onclick="location.href='characters.php'"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure=<?php echo $users->UserInfo($username, 'look'); ?>" alt="<?php echo $users->UserInfo($username, 'username'); ?>" style="margin:0 0 0 15px;" /></div>
		</div>
		<div class="avatarinfo">
			<div class="MottoContainer">
				<div class="Usersname"><?php echo $users->UserInfo($username, 'username'); ?>:</div>
				<div class="Usersmotto" style="min-width:200px; min-height:30px;"><?php echo $users->UserInfo($username, 'motto'); ?></div>
				<input class="UserMotto" type="text" value="<?php echo $users->UserInfo($username, 'motto'); ?>" style="display:none"/>
			</div>
			<div class="link-bar">
				<div class="credits"><?php echo $users->UserInfo($username, 'credits'); ?> <?php echo $lang['credits']; ?></div>
				<div class="activitypoints"><?php echo $users->UserInfo($username, 'activity_points'); ?> <?php echo $lang['pixels']; ?></div>
                <?php
				$query = mysql_query("SELECT * FROM user_subscriptions WHERE user_id = '".$users->UserInfo($username, 'id')."' LIMIT 1");
				$num = mysql_num_rows($query);
				$subscription = mysql_fetch_array($query);
				if($num > 0 && $subscription['timestamp_expire']>= time())
				{
					$expire = $subscription['timestamp_expire']-time();
					$expire = intval($expire/60/60/24);
					if($subscription['subscription_id'] == 'habbo_club')
					echo '<div class="club">'.$expire.' '.$lang['hc_left'].'</div>';
					elseif($subscription['subscription_id'] == 'habbo_vip')
					echo '<div class="club">'.$expire.' '.$lang['vip_left'].'</div>';
				}
				?>
			</div>
		</div>
	<div class="avatarextrainfo">
			<?php
            $query = mysql_query("SELECT * FROM messenger_friendships WHERE user_one_id ='".$users->UserInfo($username, 'id')."'");
			$i = 0;	
			while($friends = mysql_fetch_array($query))
			{
				$getfriend = mysql_query("SELECT * FROM users WHERE id ='".$friends['user_two_id']."' AND online = '1' LIMIT 1");
				if(mysql_num_rows($getfriend) > 0)
				{
					$i++;
					if($i == 1)
					{
						echo '<div class="content" id="feed-friends">'.$lang['friends_online'].': ';
					}
					$friend = mysql_fetch_array($getfriend);
					echo $friend['username'].', ';
				}
			}
			if($i > 0)
			echo '</div>';
			?>
		<div class="smallcontent" id="feed-lastlogin">
			<?php echo $lang['last_signed_in']; ?>: <?php echo @date("d-m-Y", $users->UserInfo($username, 'last_online')); ?>
		</div>
	</div>
    
    <div class="contentBox">
		<div class="boxHeader"><?php echo $lang['campaigns']; ?></div>
	<?php 
	$query = mysql_query("SELECT * FROM cms_news WHERE campaign ='1' ORDER BY published DESC");
	$num = mysql_num_rows($query);
	if($num > 0)
	{
		$color = 'odd';
		while($campaign = mysql_fetch_array($query))
		{
			echo' 
					<div class="campaigncontainer" id="'.$color.'">
						<div class="image" style="background: url('.$campaign['campaignimg'].') no-repeat;"></div>
						<div class="campaign">
							<div class="title"><a href="articles.php?story='.$campaign['id'].'">'.strip_tags($campaign['title']).'</a></div>
							<div class="story">'.strip_tags($campaign['shortstory'], '<br><br/><br />').'</div>
							<div class="published">'.$lang['posted_date'].': '.@date("d-m-Y", $campaign['published']).'</div>
							<div class="readmore"><a href="articles.php?story='.$campaign['id'].'">'.$lang['read_more'].'</a></div>
						</div>
					</div>';
			if($color == 'odd')
			$color='even';
			else
			$color='odd';
		}
	}			
	?>
	</div>
</div>

<div class="column" id="column2">
	<?php
	$query = mysql_query("SELECT * FROM cms_news ORDER BY published DESC LIMIT 1");
	$num = mysql_num_rows($query);
	if($num > 0)
	{
		$news = mysql_fetch_array($query);
		echo'<div class="newsHeader">
				<div class="HeadlineStory" id="'.$news["id"].'" style="background: url('.$news["image"].') no-repeat; display:block;">
					<p class="Mainheadline"><a href="articles.php?story='.$news["id"].'">'.stripslashes($news["title"]).'</a></p>
					<p class="Mainstory">'.strip_tags($news["shortstory"], '<br><br/><br />').'</p>
				</div>
		</div>';
		$color = 'odd';
		$query = mysql_query("SELECT * FROM cms_news ORDER BY published DESC LIMIT 3");
		while($news = mysql_fetch_array($query))
		{
			echo'<div class="storybox" id="'.$color.'" ref="'.$news["id"].'">
				<p class="headline"><a href="articles.php?story='.$news["id"].'">'.$news["title"].'</a></p>
				<p class="date">'.@date("d-m-Y", $news['published']).'</p>
			</div>';
			if($color == 'odd')
			$color='even';
			else
			$color='odd';
		}
	}
	?>
		<div class="storyboxEnd">
			<div class="readmore"><a href="articles.php"><?php echo $lang['read_more']; ?></a></div>
		</div>
<?php
if($twitter != '')
{
	?>
        <center>
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 4,
  interval: 6000,
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#CCC',
      color: '#000'
    },
    tweets: {
      background: '#BBB',
      color: '#000',
      links: '#000'
    }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    hashtags: true,
    timestamp: true,
    avatars: false,
    behavior: 'all'
  }
}).render().setUser('<?php echo $twitter ?>').start();
</script>
</center>
<?php
}
?>
</div>

<?php include("system/sideads.php"); ?>

	</div> 

	<?php include("system/footer.php"); ?>
</div> 

</body> 
</html>