<script>

function updateAllShouts(){
    // Assuming we have #shoutbox

    $('#shoutAllbox').load('<?=base_url();?>welcome/get_all_msgs/').fadeIn(1000);

}

setTimeout ("updateAllShouts()",1000);

setInterval ("updateAllShouts()",60000);
</script>

<script type="text/javascript">
$(function()
{
$('.more').live("click",function()
{
var ID = $(".bubble:last").attr("id");
if(ID)
{
$("#more"+ID).html('<img src="<?=base_url()?>cdn/images/bigLoader.gif" />');

$.ajax({
type: "POST",
url: "<?=base_url();?><?=index_page();?>/welcome/get_all_more_msgs/",
data: "lastmsg="+ ID,
cache: false,
success: function(html){
$("ol#updates").append(html);
$("#more"+ID).remove(); // removing old more button
}
});
}
else
{
$(".morebox").html('The End');// no results
}

return false;
});
});
</script>


<!-- start page -->
<div id="page">
	<!-- start sidebar -->
  
   <div id="leftside" style="float: left;margin-right: 15px;text-align: center;">
   <?php
     $userID = $this->session->userdata('id');
     $sqlConf = mysql_query("SELECT * FROM usertype_config WHERE id IN (SELECT membertype FROM users WHERE id='$userID')") or die(mysql_error());
	 $aConf=mysql_fetch_array($sqlConf,MYSQL_ASSOC);
	 
	 $sqlConf = mysql_query("SELECT count(*) as cnt FROM users WHERE membertype=1 AND aff_by='$userID'") or die(mysql_error());
	 $aFreeCount=mysql_fetch_array($sqlConf,MYSQL_ASSOC);
    
	 $sqlConf = mysql_query("SELECT count(*) as cnt FROM users WHERE membertype!=1 AND aff_by='$userID'") or die(mysql_error());
	 $aPaidCount=mysql_fetch_array($sqlConf,MYSQL_ASSOC);

	 $d=01;
     $mnth = date('m');
     $yr = date('Y');
     $dt = strtotime($d.'-'.$mnth.'-'.$yr);
     //die("SELECT count(*) as cnt FROM messages WHERE time_stamp>$dt AND member_uid='$userID'");
     $sqlConf = mysql_query("SELECT count(*) as cnt FROM messages WHERE time_stamp>$dt AND member_uid='$userID'") or die(mysql_error());
	 $aSMSCount=mysql_fetch_array($sqlConf,MYSQL_ASSOC);

	 ?>
   
  
       <div style="border:1px solid gray;border-radius:10px;padding: 5px; text-align: center;background-color: #E2E2E2;" >
        <h2>Today's Stat</h2>
            <div style="float:left;border-bottom:1px solid gray;border-right:1px solid gray;padding: 5px;width: 75px;">
                <h3>
                    Text's sent this month
                    <br/>
                    <?= $aSMSCount['cnt']?>/<font color="Blue"><?= $aConf['sms_limits'] ?></font>
                </h3>
            </div>
            <div style="float:left;border-bottom:1px solid gray;padding: 5px;width: 75px;">
                <h3>
                    <font color="Green">Paid</font>/<font color="Red">Free</font> Referrals
                    <br>
                    <font color="Green"><?= $aPaidCount['cnt']?></font>/<font color="Red"><?= $aFreeCount['cnt']?></font>
                </h3>
            </div>
            <div style="clear:both;"></div>
            <div style="float:left;border-right:1px solid gray;padding: 5px;width: 75px;">
                <h3>
                    Earnings this month
                    <br>
                    <font color="Green">$50</font>
                </h3>
            </div>
            <div style="float:left;padding:5px;width: 75px;">
                <h3>
                    Referral ID <a onclick='showHelp("This is then ID that you want share with people to use during then sign up. This ID will allow the system to keep track who are you reffering.");'>?</a>
                    <br>
                    <b><?= $userID ?></b>
                 </h3>
            </div>
            <div style="clear:both;"></div>
       </div>
       <br/>
       <h2>Referall URL <a onclick='showHelp("Copy the bellow URL and paste it wherever you want to share it. Share by email, on your blog, or other social networks. If a user signs up  under this link  will become a referall.");'>?</a></h2> <br/>
       <input type="text" value="<?=base_url();?>/welcome/newuser/<?= $userID ?>" size="26">
       <br/>
       <br/>
       <h2>Share On</h2> <br/>
       <a onclick="window.open('http://www.facebook.com/sharer.php?u=<?=base_url();?>/welcome/newuser/<?= $userID ?>','mywindow','width=750,height=650');" href="javascript:void(0);">
            <img width="60" height="60"  src="<?=base_url();?>images/fbicon.png">
       </a>
       <a href="http://twitter.com?status=<?=base_url();?>/welcome/newuser/<?= $userID ?>" target="_blank">
            <img width="60" height="60"  src="<?=base_url();?>images/twicon.png">
       </a>
       <br/>
       When people sign up under<br/>
       you share link you get a <br/>
       finders fee for the life<br/>
       of the account
       
    </div> 
    
    <div id="sidebar">
        <div style="border:1px solid gray;border-radius:10px;padding: 5px;background-color: #E2E2E2;" >
            <ul>
                <li id="search"><strong><font size="+2">Joined Groups</font></strong></li>
                <li id="categories">
                    <ul>
                        <? foreach($html as $value) { echo $value;} ?>
                    </ul>
                </li>
            </ul>
          <a href="<?=base_url();?><?=index_page();?>/welcome/create_group">
              <div style="width:160px; height:22px; font-weight:bold;" class="button_base">
                 <center>Create New Group</center>
              </div>
         </a>
        </div>
    </div>

	<!-- end sidebar -->
	<!-- start content -->
	<div id="content" style="float:left;margin:0px;border: 1px solid gray;width: 600px;">
		<div class="post">
			<div class="title">
				<h2><a href="#">Keep up with your group</a></h2>
			  <p>Micro-updates     to collaborate with your group and teams privately or publicly.</p>
			
				<p>&nbsp;</p>
			</div>
		
			<!-- start entry -->
		
        <div id='container'>
        <div class="entry">
        		   <div id="shoutAllbox"></div>
        </div>
        </div>
			<!-- end entry-->
			<p class="links">&nbsp;</p>
	  </div>
  </div>

  
	<!-- end content -->
	<br style="clear: both;" />
</div>
<!-- end page -->