<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tbody>

 <!-- Naglowek BOF -->
 <tr>
  <td>
   <?php
   $info_box_contents = array();
   $info_box_contents[] = array('text' => sprintf(HEADING_PRODUCT_REVIEWS));
   new contentBoxHeading($info_box_contents);
   ?>
  </td>
 </tr>
 <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
 </tr>
 <!-- Naglowek EOF -->

 <tr>
  <td>
   <table width="100%" cellspacing="1" cellpadding="2" class="infoBox">
    <tr class="infoBoxContents">
     <td>
      <table width="100%" cellspacing="0" cellpadding="0">
       <tr>
         <td>
          <table width="100%" border="0" cellspacing="0" cellpadding="2">

           <tr>
            <td align="left" valign="top">
			  <table width="100%" border="0" cellspacing="0" cellpadding="5">
				<tr>
				  <td align="left" valign="middle" class="ProductInfoTile" nowrap>
					<?php echo $products_name; ?>
				  </td>
				</tr>
			    <tr>
                 <td><span class="smallText" nowrap><?php echo (($product_info['products_price'] > 0) ? ITEM_PRICE :'');  ?></span>&nbsp;<span class="PriceRetailProduct"><B><?php echo (($product_info['products_price'] > 0) ? $products_price : ''); ?></B></span></td>
                </tr>
                <tr>
                 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
                </tr>
			  </table>
            </td>

            <td align="right" valign="middle">
             <!-- zdjecie -->
             <table border="0" cellspacing="0" cellpadding="2" width="<?php echo $szerokosc; ?>">
              <tr>
               <td align="center" class="smallText">
                <?php
                if (tep_not_null($product_info['products_image'])) {

					$szerokosc = DISPLAY_IMAGE_WIDTH + 10;
					$wysokosc = DISPLAY_IMAGE_HEIGHT + 10;
					
					if (FOTO_OPCJE == 'true') {
						?>
						<table border="0" cellpadding="0" cellspacing="0"><tr><td align="center">
                            <?php
                            if ($product_info['products_image'] != '') {
                            echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_HEIGHT,'','','','',DIR_WS_IMAGES . $product_info['products_image'],true,' rel="lytebox" title="'.$product_info['products_name'].'"');
                            }
                            ?>                        
						</table>
						<?php
						} else {
						?>
						<table border="0" cellpadding="0" cellspacing="0"><tr><td align="center">
                                <?php
                                if (FOTO_OPCJE != 'true') {
                                ?>
                                    <script type="text/javascript" src="includes/javascript/prototype/prototype.js"></script>
                                    <script type="text/javascript" src="includes/javascript/prototype/effects.js"></script>
                                    <script type="text/javascript" src="includes/javascript/prototype/window.js"></script>
                                    <script type="text/javascript" src="includes/javascript/prototype/window_effects.js"></script>

                                    <link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheet','themes/default.css')); // BTSv1.5 ?>">
                                    <link rel="stylesheet" type="text/css" href="<?php echo (bts_select('stylesheet','themes/spread.css')); // BTSv1.5 ?>">
                                <?php
                                }
                                ?>							
                                
                                <?php
                                $obraz_name = DIR_WS_IMAGES . $product_info['products_image'];
                                $obrazz = getimagesize($obraz_name);      //tworzy tablice z rozmiarami obrazka

                                if ($obrazz[0] < 550 && $obrazz[1] < 450) {
                                    if ($obrazz[0] < 340 && $obrazz[1] < 340) {
                                        $szerok_box = 400;
                                        $wysok_box = 400;
                                        $szerok = $obrazz[0];
                                        $wysok = $obrazz[1];			
                                      } else {
                                        $szerok_box = $obrazz[0]+60;
                                        $wysok_box = $obrazz[1]+60;		  
                                        $szerok = $obrazz[0];
                                        $wysok = $obrazz[1];
                                    }
                                  } else {
                                    $szeiz = 500 / $obrazz[0];       //oblicza wspolczynnik szerokosci okna do szerokosci obrazka
                                    $wysiz = 400 / $obrazz[1];				
                                    if ($szeiz <= $wysiz) {
                                        $szerok_box = (($obrazz[0] * $szeiz)-2)+60;
                                        $wysok_box = (($obrazz[1] * $szeiz)-2)+60;	
                                        $szerok = ($obrazz[0] * $szeiz)-2;		// szerokosc okna
                                        $wysok = ($obrazz[1] * $szeiz)-2;		// wysokosc okna
                                       } else {
                                        $szerok_box = (($obrazz[0] * $wysiz)-2)+60;
                                        $wysok_box = (($obrazz[1] * $wysiz)-2)+60;			   
                                        $szerok = ($obrazz[0] * $wysiz)-2;
                                        $wysok = ($obrazz[1] * $wysiz)-2;				   
                                    }
                                }								
                                ?>									
                                <script Language="JavaScript1.1"  type="text/javascript">							
                                function ShowPictureReview(pictures_name,name,szerokosc,wysokosc,sz_box,wy_box) {
                                    var imageObject = new Image();
                                    imageObject.src = pictures_name;										
                                    win = new Window( { className: 'spread', destroyOnClose: true, recenterAuto:true, minimizable:false, maximizable:false } );
                                    win.setSize(sz_box, wy_box);
                                                                
                                    win.getContent().innerHTML= unescape("<table cellpadding='0' cellspacing='6' border='0' align='center' width='100%' height='100%'><tr><td width='100%'>"+
                                                                "<table cellpadding='0' cellspacing='0' border='0' align='center' width='100%'>"+
                                                                "<tr><td height='30px' style='font-family:Tahoma,Arial;color:#000;font-size:15px;font-weight:bold;padding-left:5px;'>"+name.substr(0,70)+"<%2Ftd><%2Ftr>"+
                                                                "<%2Ftable><%2Ftd><%2Ftr>"+
                                                                "<tr><td height='100%' align='center' valign='middle' colspan='3' style='background:#ffffff; border:1px solid #c0c0c0;'><img src=\""+pictures_name+"\" width=\""+szerokosc+"\" height=\""+wysokosc+"\" border=\"0\"><%2Ftd><%2Ftr><%2Ftable><%2Fdiv>");																	
                                    win.showCenter();                                    
                                  }  
                                </script>
                                <?php
                                if ($product_info['products_image'] != '') {
                                echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_HEIGHT,'','','','',"javascript:ShowPictureReview('".DIR_WS_IMAGES . $product_info['products_image']."','".addslashes($product_info['products_name'])."','".$szerok."','".$wysok."','".$szerok_box."','".$wysok_box."')",true);
                                }
                                ?>                                
							</td></tr>
						</table>
					<?php
					}
		 	    }
                ?>
               </td>
              </tr>
             </table>
              <!-- koniec zdjecia -->
            </td>

		   </tr>

           <tr>
            <!-- opis start -->
            <td align="left" valign="top" colspan="4">
             <table border="0" cellspacing="0" cellpadding="2" align="left" width="100%">
			<!-- // Points/Rewards Module V2.1rc2a bof //-->
			<?php
			   if ((USE_POINTS_SYSTEM == 'true') && (tep_not_null(USE_POINTS_FOR_REVIEWS))) {
			?>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
			  </tr>
			  <tr>
				  <td>
				   <table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>	  
					<td align="center" class="smallText" style="font-weight:bold"><?php echo sprintf(REVIEW_HELP_LINK, $currencies->format(tep_calc_shopping_pvalue(USE_POINTS_FOR_REVIEWS)), '<a class="boxLink" style="font-weight:bold" href="' . tep_href_link(FILENAME_MY_POINTS_HELP,'faq_item=13', 'NONSSL') . '" title="' . BOX_INFORMATION_MY_POINTS_HELP . '">' . BOX_INFORMATION_MY_POINTS_HELP . '</a>'); ?></td>
					</tr>
				   </table>
				  </td>
			  </tr>
			  <tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
			  </tr>			  
			<?php
			  }
			?>
			<!-- // Points/Rewards Module V2.1rc2a eof //-->			  
              <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
              </tr>
              <tr>
               <td class="main"><?php echo stripslashes($product_info['products_description']); ?></td>
              </tr>
             </table>
            </td>
            <!-- koniec opisu -->
           </tr>

          </table>
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
   </td>
  </tr>

  <tr>
   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
  </tr>

  <tr>
   <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
      <td class="main" style="padding:5px"><b><?php echo HEADING_PRODUCT_REVIEWS; ?></b></td>
     </tr>
    </table>
   </td>
  </tr>
  
  <tr>
   <td>
    <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
     <tr class="infoBoxContents">
      <td>
       <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tr>
         <td valign="top">

		  <!-- opinie -->
          <table border="0" width="100%" cellspacing="0" cellpadding="2">
           <tbody>
            <?php
            $reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.approved = '1' and r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' order by r.reviews_id desc";
            $reviews_split = new splitPageResults($reviews_query_raw, MAX_DISPLAY_NEW_REVIEWS);

            if ($reviews_split->number_of_rows > 0) {
             if ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) {
             ?>
              <tr>
               <td>
                <table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tbody>
                  <tr>
                   <td class="smallText"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></td>
                   <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info'))); ?></td>
                  </tr>
                 </tbody>
                </table>
               </td>
              </tr>
              <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
              </tr>
              <?php
             }
             $reviews_query = tep_db_query($reviews_split->sql_query);
             while ($reviews = tep_db_fetch_array($reviews_query)) {
              ?>
              <tr>
               <td>
                <table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tbody>
                  <tr>
                   <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $product_info['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><u><b>' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($reviews['customers_name'])) . '</b></u></a>'; ?></td>
                   <td class="smallText" align="right"><?php echo sprintf(TEXT_REVIEW_DATE_ADDED, tep_date_long($reviews['date_added'])); ?></td>
                  </tr>
                 </tbody>
                </table>
               </td>
              </tr>
              <tr>
               <td>
                <table border="0" width="100%" cellspacing="1" cellpadding="2">
                 <tbody>
                  <tr class="infoBoxContents">
                   <td>
                    <table border="0" width="100%" cellspacing="0" cellpadding="2">
                     <tbody>
                      <tr>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                       <td valign="top" class="main"><?php echo tep_break_string(tep_output_string_protected($reviews['reviews_text']), 60, '-<br>') . ((strlen($reviews['reviews_text']) >= 100) ? '..' : '') . '<br><br><i>' . sprintf(TEXT_REVIEW_RATING, tep_image(DIR_WS_TEMPLATES . 'images/misc/stars_' . $reviews['reviews_rating'] . '.gif', sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])), sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])) . '</i>'; ?></td>
                       <td width="10" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                      </tr>
                     </tbody>
                    </table>
                   </td>
                  </tr>
                 </tbody>
                </table>
               </td>
              </tr>
              <tr>
               <td class="tableBottomBorder"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
              </tr>
              <?php
             }
            } else {
             ?>
             <tr>
              <td><?php new infoBox(array(array('text' => TEXT_NO_REVIEWS))); ?></td>
             </tr>
             <tr>
              <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
             </tr>
             <?php
            }

            if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
             ?>
             <tr>
              <td>
               <table border="0" width="100%" cellspacing="0" cellpadding="2">
                <tbody>
                 <tr>
                  <td class="smallText"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></td>
                  <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info'))); ?></td>
                 </tr>
                </tbody>
               </table>
              </td>
             </tr>
             <?php
            }
            ?>
            </tbody>
           </table>
          </td>
         </tr>
        </tbody>
       </table>
      </td>
     </tr>
    </table>
   </td>
  </tr>

 <!-- Przyciski BOF -->
  <tr>
   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
  </tr>
  <tr>
   <td>
    <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
     <tr class="infoBoxContents">
      <td>
       <table border="0" width="100%" cellspacing="0" cellpadding="2">
        <tbody>
         <tr>
          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params()) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
          <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()) . '">' . tep_image_button('button_write_review.gif', IMAGE_BUTTON_WRITE_REVIEW) . '</a>'; ?></td>
          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
         </tr>
        </tbody>
       </table>
      </td>
     </tr>
    </table>
   </td>
  </tr>
 <!-- Przyciski EOF -->
  <tr><td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td></tr>

 </tbody>
</table>
