<!-- start page -->
<div id="page">

	<!-- start content -->
	<div id="content">
		<div class="post">
			<div class="title">
				<h2><a href="#"></a><a href="#">Invite Friends</a></h2>
				<script>
					function vform()
						{
							var inv=0;
							for(i=1;i<=10;i++)
								{
									if(document.getElementById('fname'+i).value!='' || document.getElementById('fnumber'+i).value!='')	
										{
											inv++;
											if(document.getElementById('fnumber'+i).value.length!=10 || document.getElementById('fnumber'+i).value=='')
												{
													if(document.getElementById('fname'+i).value=='')
														alert("Please enter friend name "+i);
													else
														alert("Please enter friends phone number "+i);
																										
													if(document.getElementById('fnumber'+i).value.length!=10)	
														alert("Invalid phone number");
													return false;
												}
										}								
								}
								
							if(inv>0)	
								return true;
							else
								{
									alert("Please invite atlist one friend.");
									return false;
								}
						}

					  function isNumberKey(evt)
					  {
						 var charCode = (evt.which) ? evt.which : event.keyCode
						 if (charCode > 31 && (charCode < 48 || charCode > 57))
							return false;
				
						 return true;
					  }
				</script>
				
				<p>Fill up the form below and any phone number included will be automatically signed up. A text message will be sent to your friend/colleague, he/she will automatically start receiving texts from the group. <br /> <?=$msg?> </p>
				<form action="" method="post" onsubmit="return vform();">
				<table align="center" width="90%" style="color:#000000; text-decoration:none; font-weight:100;">
				<? 
				$xp = NULL;
				$id = $this->session->userdata('id');
				//echo "select * from groups where owner_uid = '$id' ";
				$sql = mysql_query("select * from groups where owner_uid = '$id' ") or die(mysql_error());
				while($row = mysql_fetch_array($sql))
					{
						$id = $row['id'];
						$type = $row['type'];
						$name = $row['name'];
						if($type)
							$gt = "Private";
						else
							$gt = "Public";
						
						$xp[$id] = "$name ($gt)";
					}
					?>
				<? if(!count($xp)) { ?>
				<tr>
						<td colspan="4" align="left"><font color="#FF0000" size="+1"> <strong>To invite friends you must be the owner of a group click <a href="<?=base_url()?>welcome/create_group/">HERE</a> to create your own group ></strong> </font> </td>
				</tr>
				
				<? }?>
				
				<?
				if(count($xp)){
				for($i=1;$i<=10;$i++) {?>
					<tr>
						<td>Enter Friend Name <?=$i?> <input value="" type="text" name="fname<?=$i?>" id="fname<?=$i?>"  /> </td>
						<td>Enter Friend Number <?=$i?> <input value="" type="text" name="fnumber<?=$i?>" id="fnumber<?=$i?>" onkeypress="return isNumberKey(event);"   /> </td>
						<td>Select group to join <?=$i?> 
							<select name="gid<?=$i?>" style="font-size:12px;" id="gid<?=$i?>">
								<? foreach($xp as $key=>$value) {?>
									<option value="<?=$key?>"><?=$value?></option>
								<? }?>
							</select>
						 </td>
					</tr>
				<? }
				}
				?>
				<tr><td colspan="3" align="left">
				<? if(count($xp)) { ?>
				<input type="submit" name="abc" value="Invite Friends" />
				<? }
				 ?>
				</td></tr>
				
				</table>
				</form>
		  </div>


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