<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/vhosts/finica.com/subdomains/test/httpdocs/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records   
	list($brandsRecords, $brandsMetaData) = getRecords(array(     
		'tableName'   => 'brands',
		'where'       => whereRecordNumberInUrl(1),     
		'limit'       => '1',  
	));      

	$brandsRecord = @$brandsRecords[0]; // get first record
	
	// show error message if no matching record is found   
	if (!$brandsRecord) { dieWith404("Record not found!"); }         
	
	if (@$_REQUEST['featured'] == 1) {     
		list($productsRecords, $productsMetaData) = getRecords(array(
			'tableName'   => 'products',
			'where'       =>  "featured = '1'",
			'allowSearch' =>  false,     
		));   
	}
	else {
		list($productsRecords, $productsMetaData) = getRecords(array(
			'tableName'   => 'products',       
			'where'       => "brand = '".intval($brandsRecord['num'])."'",
			'allowSearch' => false,     
		));
	} 

?>

<?php function cutText($string, $setlength) {
	$length = $setlength;
	if($length<strlen($string)){
		while (($string{$length} != " ") AND ($length > 0)) {
			$length--;}
	if ($length == 0) return substr($string, 0, $setlength);
	else return substr($string, 0, $length);}
	else return $string; }
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
  <title><?php echo $brandsRecord['title'] ?></title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
    
    <!-- JQUERY UI ACCORDION  -->
    
	<link rel="stylesheet" href="css/main_style.css" type="text/css" />
    <link rel="stylesheet" href="css/menu.css" type="text/css" />
    <link rel="stylesheet" href="css/jquery.ui.all.css">
	<script src="js/jquery-1.7.1.js"></script>
	<script src="js/ui/jquery.ui.core.js"></script>
	<script src="js/ui/jquery.ui.widget.js"></script>
	<script src="js/ui/jquery.ui.accordion.js"></script>
	
	<script>
	$(function() {
		$( "#accordion" ).accordion({
			autoHeight: false,
			navigation: true
		});
	});
	</script>
   
 </head>
<body>

 <div class="container">
	
    <div class="header">
  	<table width="922" border="0" cellspacing="0" cellpadding="0">
    <tr>
    	<td width="166" align="right" valign="middle" bgcolor="#b6ab81" style="padding-right:10px"><span class="type4">artisan<br />cheeses<BR />&<BR />specialty<BR />foods</span>		
    	</td>
        <td width="5" align="left" valign="top"><img src="images/spacer.gif" width="5" /></td>
        <td width="288" align="left" valign="top"><img src="images/header_img2.jpg" width="288" height="120" /></td>
        <td width="5" align="left" valign="top"><img src="images/spacer.gif" width="5" /></td>
        <td align="left" valign="top"><a href="index.php"><img src="images/header_logo.gif" width="458" height="120" border="0"/></a></td>
     </tr>
     <tr height="22">
        <td width="922" colspan="5" valign="top" bgcolor="#8b4420"><img src="images/spacer.gif" width="922" height="22" /></td>
     </tr>
    </table>
    <!-- end .header --></div>
 
  <div class="sidebar1">
  
  <!--Code for menu starts here-->
      <div id="accordion" class="menu_list"> 
		<p class="menu_head"><a href="#section1">Our Company</a></p>
		<div class="menu_body">
		 <a href="about_usDetail.php#section1">About Us</a>
         <a href="newsList.php#section1">Press Room &amp; Awards</a>
         <a href="eventsList.php#section1">Events</a>	
         <a href="career_opportunitiesDetail.php#section1">Career Opportunities</a>
         <a href="contactDetail.php#section1">Contact</a>
		</div>
        <p class="menu_head"><a href="#section2">What's New</a></p>
        <div class="menu_body">
        	<a href="brandsDetail.php?What-s-New-39#section2">View New Products</a>
        </div>
		<p class="menu_head"><a href="#section3">Cheeses</a></p>
		<div class="menu_body">
         <a href="product_categoriesDetail.php?Cheeses-1#section3">View All Products</a>
         <a href="brandsDetail.php?Alimentias-41#section3">Alimentias</a>
         <a href="brandsDetail.php?Beemster-1#section3">Beemster</a>
         <a href="brandsDetail.php?BelGioioso-2#section3">BelGioioso</a>
         <a href="brandsDetail.php?Bothwell-7#section3">Bothwell</a>
         <a href="brandsDetail.php?Celebrity-8#section3">Celebrity</a>
		 <a href="brandsDetail.php?Celebrity-International-10#section3">Celebrity International</a>
		 <a href="brandsDetail.php?Chimay-37#section3">Chimay</a>
		 <a href="brandsDetail.php?Collier-s-43#section3">Collier's</a>
         <a href="brandsDetail.php?Cypress-Grove-38#section3">Cypress Grove</a>
         <a href="brandsDetail.php?Finlandia-11#section3">Finlandia</a>
		 <a href="brandsDetail.php?Sartori-14#section3">Sartori</a>
         <a href="brandsDetail.php?St.-John-s-40#section3">St. John's</a>
         <a href="brandsDetail.php?Zerto-13#section3">Zerto</a>
		 <a href="brandsDetail.php?Italian-Specialty-Cheeses-15#section3">Italian Specialty Cheeses</a>
		 <a href="brandsDetail.php?Other-Specialty-Cheeses-16#section3">Other Specialty Cheeses</a></span>	
		</div>
		<p class="menu_head"><a href="#section4">Specialty Grocery</a></p>
		<div class="menu_body">
        <a href="product_categoriesDetail.php?Specialty-Grocery-3#section4">View All Products</a>
        <a href="brandsDetail.php?34-Degrees-21#section4">34 Degrees</a>
        <a href="brandsDetail.php?Dalmatia-17#section4">Dalmatia</a>
        <a href="brandsDetail.php?Del-Destino-5#section4">Del Destino</a>
        <a href="brandsDetail.php?Frutto-D-Italia-19#section4">Frutto D'Italia</a>
        <a href="brandsDetail.php?Les-Trois-Petits-Cochons-35#section4">Le Trois Petits Cochons</a>
        <a href="brandsDetail.php?Menu-6#section4">MENU</a>
        <a href="brandsDetail.php?NY-Flatbreads-33#section4">NY Flatbreads</a>
        <a href="brandsDetail.php?Ortiz-42#section4">Ortiz</a>
		<a href="brandsDetail.php?Paiarrop-32#section4">Paiarrop</a>
        <a href="brandsDetail.php?Solo-Italia-34#section4">Solo Italia</a>
        <a href="brandsDetail.php?United-Olive-Oil-36#section4">United Olive Oil</a>
        <a href="brandsDetail.php?Villa-Manodori-24#section4">Villa Manodori</a>
        <a href="brandsDetail.php?Other-Specialties-22#section4">Other Specialties</a>
    </div>
        <p class="menu_head"><a href="#section5">Meats</a></p>
		<div class="menu_body">
        <a href="product_categoriesDetail.php?Meats-Fish-6#section5">View All Products</a>
        <a href="brandsDetail.php?Levoni-29#section5">Levoni</a>
        <a href="brandsDetail.php?Volpi-18#section5">Volpi</a>
        <a href="brandsDetail.php?Zerto-30#section5">Zerto</a>
        </div>
     </div>
     <p class="menu_head"><a href="recipes_main.php" style="text-decoration:none;">Recipes</a></p>
       		
 	 <!-- Code for Menu ends here -->
     
    <div class="searchbox">
    <span class="heading_search">search</span><BR />
   
    <form method="GET" action="search_results.php">
	<input type="text" name="q" value="<?php echo htmlspecialchars(@$FORM['q']); ?>" size="18"><BR />
    <img src="images/spacer.gif" height="10px" /><BR />
	<input type="submit" name="" value="SEARCH" class="button"></form><br/><br/><BR /><BR /><BR />
    <!-- end .searchbox --></div>
     
  	<!-- end .sidebar1 --></div>
 
  <div class="content">
  	<span class="heading"><?php echo $brandsRecord['title'] ?></span><BR />
  
 	<div class="brand_img2">
    <!-- BRAND IMAGE -->
		<?php foreach ($brandsRecord['image'] as $upload): ?>
          	<?php if ($upload['hasThumbnail']): ?>
            	<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
           <?php elseif ($upload['isImage']): ?>
            	<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
		   <?php else: ?>
           		<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
          <?php endif ?>
      <?php endforeach ?>
      <!-- end BRAND IMAGE -->
	<!-- end .brand_img2 --></div>

	<div class="brand_desc2">
		<!-- BRAND LOGO -->
		<?php foreach ($brandsRecord['logo'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
            <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

          <?php elseif ($upload['isImage']): ?>
            <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

          <?php else: ?>
            <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

          <?php endif ?>
        <?php endforeach ?></br>
        <!-- end BRAND LOGO -->
        
        <!-- BRAND DESCRIPTION -->
		<?php echo $brandsRecord['content'] ?>
        <?php if ($brandsRecord['manufacturer_website']): ?>
       		Website: <?php echo $brandsRecord['manufacturer_website'] ?>
        <?php else: ?>&nbsp;            
       	<?php endif ?> 
            <br/>
        <!-- end BRAND DESCRIPTION -->
	
    <!-- end .brand_desc2 --></div>

	<div class="product_links2">
            <br /><hr style color="#b6ab81"/>
			<span class="heading2">Products</span><BR /><BR />
			<table width="600" border="0" cellspacing="0" cellpadding="0">
              <?php foreach ($productsRecords as $record): ?>
              	
                <tr>
                <td width="100" style="padding-bottom:15px">
					<div class="border">
					<?php foreach ($record['thumbnail'] as $upload): ?>
                    <a href="<?php echo $record['_link'].$record['section_number'] ?>">
					  <?php if ($upload['hasThumbnail']): ?>
                        <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
            
                      <?php elseif ($upload['isImage']): ?>
                        <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
            
                      <?php else: ?>
                        <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
            
                      <?php endif ?>
                      </a>
                    <?php endforeach ?>
                    </div>
        
        		</td>
                <td align="left" style="padding-left:10px" valign="top"><span class="heading4"><a href="<?php echo $record['_link'].$record['section_number'] ?>"><?php echo $record['title'] ?></a></span><BR />
                <?php 
						$html = preg_replace("|</p>\s*$|i", "", $record['content'] ); 
						$html = cutText($html, 170); 
						$html = $html . "...</p>"; 
						echo $html; 
				?>
                </td>
              </tr>
			 <?php endforeach ?>
            </table>

     
            <hr style color="#b6ab81"/><BR />
			
            <a href="product_categoriesDetail.php?<?php echo join(', ', getListLabels('brands', 'product_category', $brandsRecord['product_category'])); ?>-<?php echo $brandsRecord['product_category'].$brandsRecord['section_number'] ?>">View all <?php echo join(', ', getListLabels('brands', 'product_category', $brandsRecord['product_category'])); ?></a>
            <BR /><BR /><BR />

     <!-- end .product_links2 --></div>

    <?php if (!$brandsRecord): ?>
      No record found!<br/><br/>
    <?php endif ?>
	
    <!-- end .content --></div>

 	<div class="footer"><center>
    <p>Copyright © 2012 Finica Food Specialties, Ltd.</p></center>
    <!-- end .footer --></div>
    
  <!-- end .container --></div>
</body>
</html>
