<script>

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

    $('#shoutbox').load('<?=base_url();?><?=index_page();?>/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();?><?=index_page();?>/welcome/group_update/<?=$group_id;?>",
			data: dataString,
			dataType: 'html',
			beforeSend: function() {
				$('#result').html('<img src="http://127.0.0.1/locomo/cdn/images/ajax-loader.gif"/>loading...');
				if(!update[0]) {
					$('#result').html('You did not write anything !');   	
					return false;
				} 	
			},
			success: function(response) {
				$('#result').html(response);
				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', 140, 'updatelimitinfo');
 	})
});
 
</script> 





<!-- start page -->
<div id="page">
	<!-- start sidebar -->
	<div id="sidebar">
      <ul>
        <li id="search"><strong><font size="+2"><?=$group_name;?></font></strong><br />
	
        </li>
        <li id="categories">
          <h2>&nbsp;</h2>
          <ul>
		  <?php if($this->Group->IsOwner($group_id,$this->session->userdata('id'))== TRUE)
		  {
		  
		  ?>
		   <form action="<?=base_url();?><?=index_page();?>/welcome/group_delete/" method="post" id="form" >
		    <input name="delete" type="submit" class="button_side_base"  value="Delete Group" align="right" />
		   </form>
		   <?php
		   }
		   else
		   {
		   ?>
		     <form action="<?=base_url();?><?=index_page();?>/welcome/group_leave/" method="post" id="form" >
		    <input name="leave" type="submit" class="button_side_base"  value="Leave Group" align="right" />
		   </form>
		   <?php
		   }
		   ?>
     
          </ul>
        </li>
      </ul>
  </div>
	<!-- end sidebar -->
	<!-- start content -->
	<div id="content">
		<div class="post">
		  <div class="title">
				<h2><a href="#">Write your message! </a></h2>
				<p>&nbsp;</p>
				<p>
				   <textarea name="update" cols="100" 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 -->