<?php include 'sets.php';?>
<html>
<head>
<title>Photo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body bgcolor="#<?php echo $color1 ?>" text="#000000" leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center" height="100%">
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="1" cellpadding="6" class="text" bgcolor="#<?php echo $color5 ?>" height="100%">
        <tr valign="top"> 
          <td bgcolor="#FFFFFF"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" class="text">
              <tr> 
                <td height="100"> 
                  <div align="center"><img src="images/logo2.gif"></div>
                </td>
              </tr>
              <tr> 
                <td height="1"> 
                  <?php 
			include 'connect.php';
			$sql1 = "SELECT * FROM photos WHERE room_id='$rid' ORDER BY priority desc";
			$result1 = mysql_query($sql1);
				$num_rows = mysql_num_rows($result1);
			 while ($myrow=mysql_fetch_array($result1)) {
			$pid=$myrow['id'];
?>
                  <?php 
			include 'connect.php';
			$sql2 = "SELECT * FROM photos WHERE id='$id'";
			$result2 = mysql_query($sql2);
	        while ($myrow=mysql_fetch_array($result2)) {
			$photoid=$myrow['id'];
			$photo=$myrow['name_en'];
			$description=$myrow['description_en'];
			$priority=$myrow['priority'];
?>
                  <?php 
			include 'connect.php';
			$sql3 = "SELECT * FROM photos WHERE room_id='$rid' AND priority>'$priority' ORDER BY priority LIMIT 0,1";
			$result3 = mysql_query($sql3);
	        while ($myrow=mysql_fetch_array($result3)) {
			$photoid2=$myrow['id'];
			$priority2=$myrow['priority'];
?>
                  <?php } ?>
                  <?php } ?>
                  <?php } ?>
                </td>
              </tr>
              <tr> 
                <td height="20"> 
                  <div align="center"><span class="titles"> 
                    <?php echo $photo ?>
                    </span></div>
                </td>
              </tr>
              <tr> 
                <td height="10"></td>
              </tr>
              <tr>
                <td height="20"> 
                  <div align="center"> 
                    <?php echo $description ?>
                  </div>
                </td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
              <tr> 
                <td height="20" bgcolor="#<?php echo $color1 ?>"> 
                  <?php if ($priority>=$priority2)    {?>
                  <table border="0" cellspacing="3" cellpadding="3" align="center" width="100%" height="40">
                    <tr> 
                      <td bgcolor="#<?php echo $color5 ?>" width="40"> 
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td> 
                              <div align="center"><a href="roomgalleryphoto.php?id=<?php echo $pid ?>&rid=<?php echo $rid ?>" class="links1"><img src="images/start.gif" border="0"> 
                                start</a></div>
                            </td>
                          </tr>
                        </table>
                      </td>
                      <td bgcolor="#<?php echo $color5 ?>"> 
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td> <div align="left"><?php if ( $start!=='1' )    {?><a href="javascript:history.go(-1);" class="links1"><img src="images/prev.gif" border="0"> 
                                previous</a><?php } ?></div></td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <?php }else{ ?>
                  <table border="0" cellspacing="3" cellpadding="3" align="center" width="100%" height="40">
                    <tr> 
                      <td bgcolor="#<?php echo $color5 ?>" width="40"> 
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td> 
                              <div align="center"><a href="roomgalleryphoto.php?id=<?php echo $pid ?>&rid=<?php echo $rid ?>" class="links1"><img src="images/start.gif" border="0"> 
                                start</a></div>
                            </td>
                          </tr>
                        </table>
                      </td>
                      <td bgcolor="#<?php echo $color5 ?>"> 
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td> 
                              <div align="left"> 
                                <?php if ( $start!=='1' )    {?><a href="javascript:history.go(-1);" class="links1"><img src="images/prev.gif" border="0"> 
                                previous</a><?php } ?></div>
                            </td>
                            <td> 
                              <div align="right"><a href="roomgalleryphoto.php?id=<?php echo $photoid2 ?>&rid=<?php echo $rid ?>" class="links1">next 
                                <img src="images/next.gif" border="0"></a></div>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <?php } ?>
                </td>
              </tr>
              <tr> 
                <td height="20"> 
                  <div align="center"><a href="javascript:window.close();" class="link">close</a></div>
                </td>
              </tr>
            </table>
          </td>
          <td bgcolor="#<?php echo $color3 ?>" width="500">
            <div align="center"><img src="photos2/<?php echo $photoid ?>.jpg"></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
