  <?php 
$table_cells="";
$rows="";
$base_dir = "/var/www/html/www.hobiecat.com/htdocs";

$model = $_GET["model"];


$category = "sailing";

$link_back = "/".$category."/models_".$model.".html";
$current_dir = "/".$category."/images/".$model."/";
$header_source=$current_dir."modelname.gif";


$browse_dir = $base_dir.$current_dir;
$dir = opendir($browse_dir);

$links = "";
$i = 0;

while ($file = readdir($dir))
{
  if ((strstr($file, "gallery")) and (strlen($file) < 18)){
  $image_array[$i] = $file; 
  $i = $i + 1;
  }


}

closedir($dir);
sort($image_array);
$i=0;
while ($i<(count($image_array))){ 

  $num_list = (substr($image_array[$i], 8, 2));
  $img_type = (substr($image_array[$i], 11, 2));

if ($img_type == "tn"){
$image_matrix[(integer)$num_list][0] = $image_array[$i];
}
elseif ($img_type == "lr"){
$image_matrix[(integer)$num_list][1] = "<a href=\"gallery.php?model=".$model."&img_num=".$num_list."&res=lr\"><font size=\"1\">Small</font></a>";
}
elseif ($img_type == "hr"){
$image_matrix[(integer)$num_list][2] = "<a href=\"gallery.php?model=".$model."&img_num=".$num_list."&res=hr\"><font size=\"1\">Large</font></a>";
}

$i++;
 }

$row = 0;
$count = 0;
while ($row < ((count($image_matrix))+1))
{
if ($row < 10){
$num = "0".$row;
}
else {
$num = $row;
}
if (isset($image_matrix[$row][0]) and (isset($image_matrix[$row][1]) or isset($image_matrix[$row][2]))){
if (($count <> 0) and ($count % 5 == 0)){
$table_cells = $table_cells."</tr><tr>";
$rows = $rows + 1;}
if (!isset($image_matrix[$row][2])){
$seperator = " - ".$image_matrix[$row][1]." - ";
$image_link = "<a href=\"gallery.php?model=".$model."&img_num=".$num."&res=lr\"><img border=\"0\" src=\"".$current_dir.$image_matrix[$row][0]."\"></a>";
}
elseif (!isset($image_matrix[$row][1])){
$seperator = " - ".$image_matrix[$row][2]." - ";
$image_link = "<a href=\"gallery.php?model=".$model."&img_num=".$num."&res=hr\"><img border=\"0\" src=\"".$current_dir.$image_matrix[$row][0]."\"></a>";
}
else{
$seperator = $image_matrix[$row][1]." - ".$image_matrix[$row][2];
$image_link = "<a href=\"gallery.php?model=".$model."&img_num=".$num."&res=lr\"><img border=\"0\" src=\"".$current_dir.$image_matrix[$row][0]."\"></a>";
}
$table_cells = $table_cells."<td valign=\"top\" align=\"center\">".$image_link."<br>".$seperator."</td>";
$count = $count + 1;
}
$row++;
}

$width_image = 519;
$height_image = (($rows + 1) * 65) + 215;
?>
<html>
<head>
  <meta name="GENERATOR" content="Adobe PageMill 3.0 Win">
  <title>Sailing Image Gallery</title>
  <link rel="stylesheet" type="text/css" href="/media/site_styles.css">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <script language="JavaScript1.2" src="/scripts/javascript/menu_data.js"></script>      
  <script language="JavaScript1.2" src="/scripts/javascript/dqm_script.js"></script>
</head>


<body bgcolor="#ffffff"
 leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" align="left" cellpadding="0" cellspacing="0"> 
<!--Begin Header --><tr>
      

<td background="/media/images/header-footer/header_sail_07.gif"> 
    <table width="660" border="0" cellspacing="0" cellpadding="0" height="73">
        <tr> 
          <td width="29" height="73" valign="top"> <img src="/media/images/header-footer/header_sail_01.gif" width="29" height="75"naturalsizeflag="0" align="BOTTOM">		  </td>
		  
          <td width="135" height="73" valign="top"> <a href="/index.html" target="_top"><img src="/media/images/header-footer/header_sail_02.gif" width="135" height="75" border="0" naturalsizeflag="0" align="BOTTOM" alt="Hobie Cat - Home"></a>		  </td>

          <td width="247" height="73" valign="top"> <img src="/media/images/header-footer/header_sail_03.gif" width="247" height="75" naturalsizeflag="0" align="BOTTOM">		  </td>
		  
          <td width="74" height="73" valign="top"> <a href="/sailing/index.html" target="_top"><img src="/media/images/header-footer/header_sail_04.gif" border="0" width="74" height="75" naturalsizeflag="0" align="BOTTOM" name="menu0" id="menu0" onMouseOver="showMenu(event)" onMouseOut="hideMenu(event)"></a>		  </td>
        
		  <td width="62" height="73" valign="top"> <a href="/support/index.html" target="_top"><img src="/media/images/header-footer/header_sail_05.gif" border="0" width="67" height="75" naturalsizeflag="0" align="BOTTOM" name="menu1" id="menu1" onMouseOver="showMenu(event)" onMouseOut="hideMenu(event)"></a>		  </td>
		  
          <td height="73" valign="top"> <a href="/company/contact.html" target="_top"><img src="/media/images/header-footer/header_sail_06.gif"  border="0" width="108"height="75" naturalsizeflag="0" align="BOTTOM" name="menu2" id="menu2" onMouseOver="showMenu(event)" onMouseOut="hideMenu(event)"></a></td>
      </tr>
   </table>
</td>
</tr><!--End Header --> <tr> <td valign="top"> <table width="661" height="100%" border="0" cellspacing="0" cellpadding="0"> 
<tr> <td width="122"><img src="images/in_top_left.gif" width="106" height="14"></td><td width="30"><img src="images/in_top_middle.gif" width="30" height="14"></td><td width="562"><img src="images/in_top_right.gif" width="508" height="14"></td></tr> 
<tr> <td rowspan="8" valign="top" width="106"> <table border=0 cellpadding=0 cellspacing=0> 
<tr> <td> <a href="models_bravo.html"><img src="images/sailboat_nav_01.gif" width=106 height=39 border="0"></a></td></tr> 
<tr> <td> <a href="models_wave.html"><img src="images/sailboat_nav_02.gif" width=106 height=25 border="0"></a></td></tr> 
<tr> <td> <a href="models_getaway.html"><img src="images/sailboat_nav_03.gif" width=106 height=27 border="0"></a></td></tr> 
<tr> <td> <a href="models_hobie16.html"><img src="images/sailboat_nav_04_noline.gif" width=106 height=51 border="0"></a></td></tr> 
<tr> <td> <a href="models_fxone.html"><img src="images/sailboat_nav_11.gif" width=106 height=24 border="0"></a></td></tr> 
<tr> <td> <a href="models_tiger.html"><img src="images/sailboat_nav_08.gif" width=106 height=23 border="0"></a></td></tr>
<tr>
  <td><a href="models_wildcat.html"><img src="images/sailboat_nav_016.gif" alt="Wild Cat" width=106 height=25 border="0"></a></td>
</tr> 
</table></td><td width="30" height="33" valign="top"><img src="images/in_row4_middle.gif" width="30" height="35"></td><td width="508"><img src="images/<?php echo $model; ?>/modelname.gif" width="308" height="33" border="0"></td></tr> 
<tr> <td width="30" height="<?php echo $height_image;?>"><img src="images/in_row5_middle.gif" width="30" height="<?php echo $height_image;?>"></td><td width="503"><table valign="top" cellpadding="7"><tr><?php echo $table_cells; ?></tr></table></td></tr> 
<tr> <td width="30"><img src="images/in_row6_middle.gif" width="30" height="19"></td><td width="562"><img src="images/in_row6_right.gif" width="<?php echo $width_image;?>" height="19"></td></tr> 
<tr> <td width="30" height="45"><img src="images/in_row7_middle.gif" width="30" height="45"></td><td width="562"><font face="Verdana, Arial, Helvetica, sans-serif" color="#6666cc" size="2">&nbsp; 
</font> <a href="<?php echo $link_back; ?>"><font size="2">Back to the model page</font></a></td></tr> 
<tr> <td width="30"><img src="images/in_row8_middle.gif" width="30" height="14"></td><td width="562"><img src="images/in_row8_right.gif" width="<?php echo $width_image;?>" height="14"></td></tr> 
<tr> <td width="30" background="images/in_bkgdline.gif">&nbsp;</td><td width="562"> 
<table width="547" border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> 
<td colspan="2"><img src="images/trans_5x5.gif" width="391" height="5"></td></tr> 
<tr valign="top"> <td width="4"> <p><img src="images/trans_5x5.gif" width="4" height="5"></p></td><td width="423"> 
</td></tr> <tr valign="top"> <td width="4">&nbsp;</td><td width="391">&nbsp;</td><td>&nbsp;</td></tr> 
</table><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p></td></tr> </table>  <tr>
    <td align="left" valign="top" background="/media/images/header-footer/footer_sail_07.gif"> 
      <table width="636" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          
        <td width="139" valign="top"> <a href="/sailing/index.html" target="_top"><img src="/media/images/header-footer/footer_sail_01.gif" width="139" height="36" alt="Sailing" border="0" naturalsizeflag="0" align="BOTTOM"></a>		</td>
		
        <td width="101" valign="top"> <a href="/kayaking/index.html" target="_top"><img src="/media/images/header-footer/footer_sail_02.gif" width="101" height="36" alt="Kayaking" border="0" naturalsizeflag="0" align="BOTTOM"></a>		</td>
		
	    <td width="91" valign="top"> <a href="/fishing/index.html" target="_top"><img src="/media/images/header-footer/footer_sail_03.gif" width="91" height="36" alt="Fishing" border="0" naturalsizeflag="0" align="BOTTOM"></a>        </td>
	
	    <td width="93" valign="top"> <a href="/company/contact.html" target="_top"><img src="/media/images/header-footer/footer_sail_04.gif" width="93" height="36" alt="Contact" border="0" naturalsizeflag="0"align="BOTTOM"></a>		</td>

        <td width="131" valign="top"> <a href="/company/dealer.html" target="_top"><img src="/media/images/header-footer/footer_sail_05.gif" width="128" height="36" alt="Dealers" border="0" naturalsizeflag="0" align="BOTTOM"></a>        </td>
		
        <td valign="top"> <a href="/index.html" target="_top"><img src="/media/images/header-footer/footer_sail_06.gif" width="98" height="36" border="0" naturalsizeflag="0" align="BOTTOM" alt="Hobie Cat - Home"></a></td>
		
      </tr>
      </table>
   </td>
</tr> </table></td></tr> </table><br> 
</body>
</html>
