<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Welcome to Sounit. free group texting.</title>
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
    <link rel="stylesheet" type="text/css" href="<?=base_url()?>css/style.css">
</head>
<body>
<script>


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

    $('#shoutbox').load('<?=base_url();?>welcome/group_get_updates/<?=$group_id?>').fadeIn(1000);

}

setTimeout ("updateShouts()",1000);

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

<script language="javascript"> 
$(document).ready(function(){
	$('#updateBtn').click(function() { 
		var update = $('#update').val();
		var group_id = $('#group_id').val();
        var dataString = 'update='+ update + '&group_id=' + group_id;
		
		$.ajax({
			type: 'POST',
			url: "<?=base_url()?>welcome/group_update/<?=$group_id;?>",
			data: dataString,
			dataType: 'html',
			beforeSend: function() {
				$('#result').html('<img src="<?=base_url()?>cdn/images/ajax-loader.gif"/>Loading...');
				if(!update[0]) {
					$('#result').html('You did not write anything !');   	
					return false;
				} 	
			},
			success: function(response) {
				$('#result').html(response);
				document.getElementById('update').value = '';
				$('#updatelimitinfo').html(''); 
				
				updateShouts();			
			}
 
		});
	});
});
</script> 
<script language="javascript"> 
function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
		return true;
	}
}
 
$(function(){
 	$('#update').keyup(function(){
 		limitChars('update', 120, 'updatelimitinfo');
 	})
});
 
</script> 





<!-- start page -->
<div id="page">
	<!-- start sidebar -->
	<div id="sidebar">
		<?
			$sql = mysql_query("select * from groups as G, users as U where U.id = G.owner_uid and G.id = '$id'") or die(mysql_error());
			$row = mysql_fetch_array($sql);
			$by = $row['username'];
			$date_time = $row['date_time'];
			$type = $row['type'];
			
			$userID = $this->session->userdata('id');
			$s = mysql_query("select * from members as m,users as u where m.member_uid!='$userID' AND m.member_uid = u.id and m.group_id = '$group_id' and m.pending1 = '0' group by u.id") or die(mysql_error());
            $iWillUseMessages=mysql_num_rows($s);       
		?>
	<div style="border:1px solid gray;border-radius:10px;padding: 5px;background-color: #E2E2E2;" >	
	   <div style="padding: 5px 45px;">
	        <strong><font size="+2">	<?=$group_name;?></font></strong> 
    		<table align="center" width="100%">
    		<tr><td align="left" style="padding-left:23px;">
        	<em><? if($type == 0) { ?> <font color="#006600">This is a public group</font> <? } else { ?> <font color="#FF0000"> This is a private group</font> <? }?></em>
        	</td></tr>
        	</table>
               
            <p align="center"><img src="<?=base_url().$row['logo']?>"></p>
            <p align="left">Group Id : <strong style="color:#0066FF">GL<?=$id?></strong></p>
            		
            <p  align="left">Created By : <strong><?=$by?></strong></p>
            <p  align="left">Time : <strong><?=$date_time?></strong></p>
        </div>
      </div>             
       <br/>
      <div style="border:1px solid gray;border-radius:10px;padding: 5px;background-color: #E2E2E2;" >	
         <div style="padding: 5px 45px;">
          <h2>Action</h2>
          <?php if($this->Group->IsOwner($group_id,$this->session->userdata('id'))== TRUE)
		  {
		  ?>
		   <form action="<?=base_url();?>welcome/group_delete/" method="post" id="form" >
		    <input name="delete" type="submit" class="button_side_base"  value="Delete Group" align="right" /><br />
            <br />

		    <input name="delete" type="submit" class="button_side_base"  value="&nbsp;&nbsp;Edit Group&nbsp;&nbsp;" align="right" />
		   </form>
		   <?php
		   }
		   else
		   {
		   ?>
		     <form action="<?=base_url();?>welcome/group_leave/" method="post" id="form" >
		    <input name="leave" type="submit" class="button_side_base"  value="Leave Group" align="right" />
		   </form>
		   <?php
		   }
		   ?>
     
        </div>
     </div>
	  <br/>
	 <div style="border:1px solid gray;border-radius:10px;padding: 5px;background-color: #E2E2E2;" >
	  <div style="padding: 5px 30px;">	
        <h2>Group Members</h2>
		  <ul>
    	  <? 
			$s = mysql_query("select * from members as m,users as u where m.member_uid = u.id and m.group_id = '$group_id' and m.pending1 = '0' group by u.id") or die(mysql_error());
			while($r = mysql_fetch_array($s))
			{
		?>
		<li><?=$r['username']?> </li>
		<? } //while end ?>
		</ul>
	  <br />
	 	  <?php if($this->Group->IsOwner($group_id,$this->session->userdata('id'))== TRUE)
		  {
		  ?> 
	
	  <h2>Pending Members</h2>
	  <style>
	  
a.info{
    position:relative; /*this is the key*/
    z-index:24; 
    color:#000;
    text-decoration:none}

a.info:hover{z-index:25; background-color:#ff0}

a.info span{display: none}

a.info:hover span{ /*the span will display just on :hover state*/
    display:block;
    position:absolute;
    top:2em; left:2em; width:15em;
    border:1px solid #CCCCCC;
    background-color:#EEEEEE; color:#333333;
    text-align: center}
	
	  </style>
	   <ul  id="foottip">
		<? 
			$cnt = mysql_num_rows($s);
			
			while($r = mysql_fetch_array($s))
			{
			$id = $r['member_uid'];
		?>
			<li>	<?=$r['username']?> &nbsp;&nbsp;&nbsp;
				<a href="<?=base_url()?>welcome/approve_member/<?=$group_id?>/<?=$r['member_uid']?>/" style="color:#006600;"  class="info"><strong>Approve</strong><span><?=$r['about']?></span></a>&nbsp;/&nbsp;<a href="<?=base_url()?>welcome/declined_member/<?=$group_id?>/<?=$r['member_uid']?>" class="info">Deny<span><?=$r['about']?></span></a></li>
		<? } //while end ?>
		
	  </ul>
	
	 <? }?>
    	</div>	 
	</div>	 
	
	
  </div>
	<!-- end sidebar -->
	<!-- start content -->
	<div id="content">
		<div class="post" style="border: 1px solid gray;">
		  <div class="title">
		  <h3>If you send to all your group you will use  <?=$iWillUseMessages?> text's </h3>
				<h2><a href="#">Write your message! </a></h2>
				<p>&nbsp;</p>
				<p>
				   <textarea name="update" cols="60" rows="5" id="update"  ></textarea>
				</p>
		
		     <input type="hidden" name="group_id" value="<?=$group_id?>"  id="group_id" />
			<p><font size="+2" style="font-weight:bold;" color="#FF0000"><span id="updatelimitinfo"></span></font></p>
			<p>&nbsp;</p>
			
			 <p><font size="+2" style="font-weight:bold;" color="#000000"><span id="result"></span></font></p>
		   <p>&nbsp;</p>
                <p>
                <input type="submit" name="updateBtn" id="updateBtn" class="button_base" value="Post It !" align="right" />
                </p>
	   
	      </div>
	
		  
		  
		      <div id="shoutbox"></div>
		  
		  
		  
		  
		  
			<p class="links">&nbsp;</p>
	  </div>
  </div>
	<!-- end content -->
	<br style="clear: both;" />
</div>
<!-- end page -->