<?php if($ctrlAction=='pastevents'){$lbl='Past'; }else{$lbl='JPC'; }?>
<script>
function submitform(start,limit)
{
	document.searchfrm.act.value=document.location.href;
	document.getElementById("start").value=start;
	document.getElementById("limit").value=limit;
		
	//document.searchfrm.action = u;
	
	document.searchfrm.submit();
}
function gotolink(u,event_id)
{
	document.searchfrm.act.value=document.location.href;
	document.getElementById("event_id").value=event_id;
	document.searchfrm.action = u;
	
	document.searchfrm.submit();
}
</script>
<form name="searchfrm" id="searchfrm" action="<?php echo $page_name?>" method="post" target="_parent">
<input type="hidden" name="start" id="start" value="<?=$_REQUEST["start"]?>" />
<input type="hidden" name="limit" id="limit" value="<?=$_REQUEST["limit"]?>" />
<input type="hidden" name="act" id="act" value="" />
<input type="hidden" name="event_id" id="event_id" value="" />
 <div style="padding-top:100px;">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="breadcrumb"><a href="index.php">Home</a> &raquo; <?php echo $lbl;?> Events</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="76%"><h3><?php echo $lbl;?> Events</h3></td>
    <td width="24%" align="right"><table width="100%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="45%" align="center">&nbsp;</td>
        <td width="55%" align="center">
			<?php if($ctrlAction=='pastevents'){?><a href="eventlist" class="btn btn-primary">JPC Events</a><?php }else{?><a href="pastevents" class="btn btn-primary">Past Events</a><?php }?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
   <tr>
                <td colspan="2">Total Records: <?php echo $_REQUEST["nume"];?></td>
                </tr>
  <tr>
    <td colspan="2">
	<span style="float:right">Sort by: 
					<select name="sortby" id="sortby" class="txt-box" onchange="document.searchfrm.submit()">
						<option value="startdate" <?php if($_REQUEST["sortby"]=='startdate'){echo "selected";}?>>Date</option>
						<option value="title" <?php if($_REQUEST["sortby"]=='title'){echo "selected";}?>>Title</option>
					</select>
				</span>
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="table table-bordered table-striped">
      <tr>
        <td width="8%" height="28" align="center"><strong>Sr. No.</strong></td>
        <td width="13%"><strong>Start Date</strong></td>
        <td width="67%"><strong>Event Title</strong></td>
        <td width="12%" align="center"><strong>Photo</strong></td>
      </tr>
	  <?php
	  $i=1;
	 foreach($eventlist as $eventdata){
	 ?>
      <tr>
        <td align="center" valign="top"><?php echo $i+$_REQUEST["start"];?>.</td>
        <td valign="top"><?php echo date('d.m.Y',strtotime($eventdata->startdate))?></td>
        <td valign="top"><a href="#" onclick="gotolink('eventdetails','<?php echo $eventdata->id;?>')" class="bnav"><?php echo $eventdata->title?>. </a>
        </td>
        <td align="center" valign="middle">
		<?php if($eventdata->photo!='' and file_exists('./static/uploadfiles/members/'.$eventdata->photo)){?>
						<img src="./utility/processImage.php?imageName=<?php echo urlencode($eventdata->photo); ?>&w=80&h=80&mod=4&type=2&<?php echo date("HisdmY");?>" />
					<?php }else{?>
						<img src="images/noimg.jpg" width="80px" height="80px" /></td>
					<?php }?>
		</td>
      </tr>
     <?php
	 $i++;
	  }
	  ?>
     
	  <tr><td colspan="5">
	  <table width="100%">
			 <tr>
			  		<td align="center" valign="top">
                    	<a href="#" onclick="submitform('0','<?php echo $_REQUEST['limit']?>')" >First</a>
                    </td>
                    <td  align="center" valign="top">
						<?php //print_r($_POST);
                        if($_REQUEST["back"] >=0){
                        ?>
                        <a href="#" onclick="submitform('<?php echo $_REQUEST["back"]?>','<?php echo $_REQUEST['limit'] ?>')">Prev</a>
                        <?php
                        }
                        ?>
                    </td>
                    <td align="center" valign="top"><strong>Pages </strong>
                    <?php								  
						$l=1;
						$lastPage = ceil($_REQUEST["nume"]/($_REQUEST["limit"]));
						for($i=0;$i < $_REQUEST["nume"];$i=$i+$_REQUEST["limit"]){
						if($i <> $_REQUEST["eu"]){
							if($l == $lastPage){
								$lastPageLink = "'".$i."','".$_REQUEST['limit']."'";
							}
						?>
						<a class="onav" href="#" onclick="submitform('<?php echo $i?>','<?php echo $_REQUEST['limit']?>')"><?php echo $l; ?></a>
					<?php
						}
						else { 
								if($l == $lastPage){
									$lastPageLink = "#";
								}
						?>
							<span class="paging_pages_cur"><a href="#" class="selected" alt="<?php echo SEO_ENCHOR_ALT; ?>" title="<?php echo SEO_ENCHOR_TITLE; ?>"><?php echo $l; ?></a></span>
							<?php
								}       
							$l=$l+1;
							} 
					  ?>                  </td>
                    <td align="center" valign="top" bgcolor="#F5F5F5" class="td2">
						<?php  
						if($_REQUEST["th"] < $_REQUEST["nume"]) { 	
                        ?>
                      		<a class="onav" href="#" onclick="submitform('<?php echo $_REQUEST["next"]?>','<?php echo $_REQUEST['limit']?>')">Next</a>
                        <?php
						}
						?>
                    </td>
                    <td align="center" valign="top"><a class="onav" href="#" onclick="submitform('<?php echo $lastPageLink; ?>')">Last</a></td>
                </tr>
			 </table>
			 </td></tr>
    </table></td>
  </tr>
</table>
</form>