<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,gallery_id)
{
	document.searchfrm.act.value=document.location.href;
	document.getElementById("gallery_id").value=gallery_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="gallery_id" id="gallery_id" value="" />
<style>
.gal-box{
	width: 280px;
	height: 190px;
	/*border: 1px solid #CCC;*/
}
</style>
 <div style="padding-top:130px;">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" class="breadcrumb"><a href="index.php" class="bnav">Home</a> &raquo; Gallery</td>
                </tr>
              <tr>
                <td>&nbsp;</td>
                </tr>
              <tr>
                <td><h3>Gallery</h3></td>
                </tr>
              <tr>
                <td>&nbsp;</td>
                </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="8" cellpadding="5" class="table table-responsive">
				<?php 
				$i =0;
              						  $j = 0;
				foreach($gallerylist as $gallery){
                  if($j % 3 == 0 && $j !=0)
              					{
              						$i=0;
              						echo "</tr>";
              						
              						echo "<tr>";
              					}
              					if($j == 0)
              					{
              						echo "<tr>";
              					}
								?>
				<td align="left">
					<table >
						<tr>
							<td align="center">
							  <a href="#" onclick="gotolink('photos','<?php echo $gallery->id;?>')"><?php if($gallery->simage!='' and file_exists('./static/uploadfiles/galleries/'.$gallery->simage)){?>
						<img class="img-thumbnail" src="./utility/processImage.php?imageName=<?php echo urlencode($gallery->simage); ?>&w=250&h=150&mod=3&type=2&<?php echo date("HisdmY");?>" border="0" /></a>
					<?php }else{?>
						<a href="#" onclick="gotolink('photos','<?php echo $gallery->id;?>')"><img src="images/noimg.jpg" width="220" height="150" border="0" /></a>
					<?php }?></td>
						</tr>
					
                  		<tr>
                    		<td align="center" class="box-brd"><?php echo $gallery->gallerytitle?><br /><?php echo "Number of Photos (".$gallery->subsec_count.")";?>&nbsp;</td>
                   
                  		</tr>
					</table>
				</td>
						<?php
								if($j == ($nume_prd -1 )){
									if($i == 1){
										echo '<td width="20%">&nbsp;</td>';
										echo '<td width="20%">&nbsp;</td>';
										echo '<td width="20%">&nbsp;</td>';
									}
									elseif($i == 2){
										echo '<td width="20%">&nbsp;</td>';									
										echo '<td width="20%">&nbsp;</td>';
									}
									elseif($i == 3){
										echo '<td width="20%">&nbsp;</td>';																			
									}
								}
			                $j++;
			                $i++;
              				?>
                 <?php }?>
                </table></td>
                </tr>
              <tr>
                <td>&nbsp;</td>
                </tr>
              <tr><td colspan="5">
	  <table width="98%" align="center" cellspacing="1">
			 <tr>
			  		<td height="34" align="center" valign="middle" bgcolor="#f5f5f5" class="td2">
                    	<a class="onav" href="#" onclick="submitform('0','<?php echo $_REQUEST['limit']?>')" >First</a>
                    </td>
                    <td  align="center" valign="middle" bgcolor="#f5f5f5" class="td2">
						<?php //print_r($_POST);
                        if($_REQUEST["back"] >=0){
                        ?>
                        <a class="onav" href="#" onclick="submitform('<?php echo $_REQUEST["back"]?>','<?php echo $_REQUEST['limit'] ?>')">Prev</a>
                        <?php
                        }
                        ?>
                    </td>
                    <td align="center" valign="middle" bgcolor="#f5f5f5" class="td2"><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="middle" 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="middle" bgcolor="#f5f5f5" class="td2"><a class="onav" href="#" onclick="submitform('<?php echo $lastPageLink; ?>')">Last</a></td>
                </tr>
			 </table>
			 </td></tr>
              <tr>
                <td>&nbsp;</td>
                </tr>
              <tr>
                <td>&nbsp;</td>
                </tr>
              <tr>
                <td>&nbsp;</td>
                </tr>
              </table>
             </div>
</form>