<script Language="JavaScript1.1"  type="text/javascript">
  charset = '<?php echo CHARSET; ?>';
  tytul = '<?php echo str_replace('\'','',$products_name); ?>';
  logo =  '<?php echo DIR_WS_IMAGES . STORE_LOGO; ?>';

  szerokosci = new Array(10);
  wysokosci = new Array(10);
  opis = new Array(10);

  pictures = new Array(10);
  pictures_big = new Array(10);
  <?php
  if (tep_not_null($product_info['products_image'])) {
   $opis = '';
   $i = 0;
   $j = 0;
   $img_mid = tep_obrazek(DIR_WS_IMAGES . $product_info[products_image], DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_HEIGHT);

   echo "pictures[$j]=\"$img_mid\"\n";
   if (IMAGE_WATERMARK == 'true') {
     echo "pictures_big[$i]=\"image.php?main=$img_path$product_info[products_image]&watermark=watermark.png\"\n";
   } else {
     echo "pictures_big[$i]=\"$img_path$product_info[products_image]\"\n";
   }
   $image_size = getimagesize(DIR_WS_IMAGES . $product_info[products_image]);
   $width = $image_size[0];
   $height = $image_size[1];
   echo "szerokosci[$i] = '".$width."';\n";
   echo "wysokosci[$i] = '".$height."';\n";
   echo "opis[$i] = '".$products_name."';\n";

   $j++;
   $i++;
  }
  $images_product = tep_db_query("SELECT additional_images_id, products_id, images_description, medium_images, popup_images FROM " . TABLE_ADDITIONAL_IMAGES . " WHERE products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
  if (!tep_db_num_rows($images_product)) {
  } else {
    while ($new_products = tep_db_fetch_array($images_product)) {
      $img_mid = tep_obrazek(DIR_WS_IMAGES . $new_products[popup_images], DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_HEIGHT);
      echo "pictures[$j]=\"$img_mid\"\n";
      if (IMAGE_WATERMARK == 'true') {
        echo "pictures_big[$i]=\"image.php?main=$img_path$new_products[popup_images]&watermark=watermark.png\"\n";
      } else {
        echo "pictures_big[$i]=\"$img_path$new_products[popup_images]\"\n";
      }
      $image_size = getimagesize(DIR_WS_IMAGES . $new_products[popup_images]);
      $width = $image_size[0];
      $height = $image_size[1];
      echo "szerokosci[$i] = '".$width."';\n";
      echo "wysokosci[$i] = '".$height."';\n";
	  echo "opis[$i] = '".$new_products[images_description]."';\n";
      $j++;
      $i++;
    }
  }
  ?>

  var current_picture=0;

  function LoadMidPicture(picture_index) {     
   current_picture=picture_index;      
   document.big_photo.src = pictures[picture_index];
   return;
  }
  
  function ShowBigPicture(picture_index) {

	var imageObject = new Image();
	imageObject.src = pictures_big[picture_index];
	
	<?php 
	if (POPUP_IMAGE_WIDTH != '' && POPUP_IMAGE_WIDTH > 0) {
		if (POPUP_IMAGE_WIDTH > 800) {
			$pop_width = 800;
		   } else {
		    $pop_width = POPUP_IMAGE_WIDTH;
	  } } else {
		$pop_width = 800;
	}
	if (POPUP_IMAGE_HEIGHT != '' && POPUP_IMAGE_HEIGHT > 0) {
		if (POPUP_IMAGE_HEIGHT > 600) {
			$pop_height = 600;
		   } else {
		    $pop_height = POPUP_IMAGE_HEIGHT;
	  } } else {
		$pop_height = 600;
	}	
	if ($pop_width < 350) {
		$pop_width = 350;
	}
	if ($pop_height < 350) {
		$pop_height = 350;
	}
	$ye = '0';
	
	if (POPUP_IMAGE_WIDTH == '' && POPUP_IMAGE_HEIGHT == '') {
		$ye = '1';
	}
	?>
	
	<?php if ($ye == '0') { ?>
		szerokosci_admin = <?php echo $pop_width; ?>;
		wysokosci_admin = <?php echo $pop_height; ?>;
	<?php } else { ?>
		szerokosci_admin = szerokosci[picture_index];
		wysokosci_admin = wysokosci[picture_index];	
	<?php } ?>
	
	if ((parseFloat(szerokosci[picture_index])) < (szerokosci_admin-60) && (parseFloat(wysokosci[picture_index])) < (wysokosci_admin-60)) {

		szerok_box = parseFloat(szerokosci[picture_index])+60;
		wysok_box = parseFloat(wysokosci[picture_index])+60;
		szerok = szerokosci[picture_index];
		wysok = wysokosci[picture_index];
		
		} else {
		
		szeiz = szerokosci_admin / parseFloat(szerokosci[picture_index]);       //oblicza wspolczynnik szerokoscii okna do szerokoscii obrazka
		wysiz = wysokosci_admin / parseFloat(wysokosci[picture_index]);				
		if (szeiz <= wysiz) { 
			szerok_box = szerokosci_admin;
			wysok_box = wysokosci_admin;	
			szerok = (parseFloat(szerokosci[picture_index]) * szeiz)-60;		// szerokosci okna
			wysok = (parseFloat(wysokosci[picture_index]) * szeiz)-60;   // wysokosci okna
		   } else { 
			szerok_box = szerokosci_admin;
			wysok_box = wysokosci_admin;			   
			szerok = (parseFloat(szerokosci[picture_index]) * wysiz)-60;
			wysok = (parseFloat(wysokosci[picture_index]) * wysiz)-60;
		}				
	}
		
	win = new Window( { className: 'spread', destroyOnClose: true, recenterAuto:true, minimizable:false, maximizable:false } );
	win.setSize(szerok_box, wysok_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;'>"+tytul.substr(0,70)+"<<?php echo '%2F'; ?>td><<?php echo '%2F'; ?>tr>"+
								"<<?php echo '%2F'; ?>table><<?php echo '%2F'; ?>td><<?php echo '%2F'; ?>tr>"+
								"<tr><td height='100%' align='center' valign='middle' colspan='3' style='background:#ffffff; border:1px solid #c0c0c0;'><img src=\""+pictures_big[picture_index]+"\" width=\""+szerok+"px\" height=\""+wysok+"px\" border=\"0\"><<?php echo '%2F'; ?>td><<?php echo '%2F'; ?>tr><<?php echo '%2F'; ?>table><<?php echo '%2F'; ?>div>");
	win.showCenter();
  }    

</script>

