<?php 
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
require("includes/http.js");
$action_value=(isset($HTTP_GET_VARS['action_value'])?tep_db_prepare_input($HTTP_GET_VARS['action_value']):'');
$serverDate = date('Y-m-d H:i:s',getServerDate(false));
if($action_value=='remind') {
	$email_address=(isset($HTTP_POST_VARS['txt_email'])?tep_db_prepare_input($HTTP_POST_VARS['txt_email']):'');
	$sql_array=array('products_id'=>tep_db_prepare_input($HTTP_GET_VARS['products_id']),
					'date_added'=>$serverDate,
					'attributes_id'=>tep_get_sorted_attribute_ids($HTTP_POST_VARS['attribute_value']),
					'email_address'=>$email_address);
	tep_db_perform(TABLE_PRODUCTS_REMINDERS,$sql_array);
	$action_value="";
}
echo tep_draw_form('prd_cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'),'post','onSubmit="javascript:return validateForm();"'); 
?>
<table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB;?>">
<?php 
  if ($product_check['total'] < 1) {
?>
      <tr>
        <td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></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">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_template_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
<?php
  } else {
  	
	
    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.author_name,p.products_model, p.products_quantity, p.products_image_1,p.products_image_2,p.products_image_3,p.products_image_4,p.products_image_5,
							p.products_title_1,p.products_title_2,p.products_title_3,p.products_title_4,p.products_title_5,pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.products_quantity,p.manufacturers_id,p.is_attributes from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
	$product_info = tep_db_fetch_array($product_info_query);
    tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

    if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
      $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']),'1',true) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
    } else {
      $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']),'1',true);
    }

    if (tep_not_null($product_info['products_model'])) {
      $products_name = $product_info['products_name'] . '<span class="smallText" align="right">[' . $product_info['products_model'] . ']</span>';
    } else {
      $products_name = $product_info['products_name'];
    }
	if($product_info['is_attributes']=='Y')
	{
		$att_query=tep_db_query("select * from " . TABLE_PRODUCTS_STOCK . " where products_id='" . (int)$HTTP_GET_VARS['products_id'] . "'");
		$att_array=array();
		$a_cnt=0;
		while($att=tep_db_fetch_array($att_query))
		{
			$att_array[$a_cnt]=array("attributes"=>$att["attributes_id"],
									  "stock"=>$att["products_quantity"],
									  "status"=>$att['attribute_status']);
			$a_cnt++;
		}
	}	
	
require(DIR_WS_JAVASCRIPT . "product_info.js.php");
// BOF: WebMakers.com Added: Show Featured Products
if (SHOW_HEADING_TITLE_ORIGINAL=='yes') {
$header_text = '&nbsp;';
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
            <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
}else{
$header_text=$products_name . "\tleft\t" . $products_price . "\tright";
}
?>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_top(false, false, $header_text);
}
// EOF: Lango Added for template MOD

// prepare the images to show
$images=array();
$img_string="";
$title_string="";
for ($icnt=1;$icnt<=5;$icnt++){
	if ($product_info['products_image_' . $icnt]!=""){
		$images[]=array("image"=>$product_info["products_image_" .$icnt],'title'=>$product_info["products_title_" . $icnt]);
		if (file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . "big/" .$product_info['products_image_' . $icnt])){
			$img_string.="'" . DIR_WS_IMAGES . "big/" . $product_info["products_image_" . $icnt] . "',";
		} else {
			$img_string.="'" . DIR_WS_IMAGES . $product_info["products_image_" . $icnt] . "',";
		}
		$title_string.="'" . addslashes($product_info["products_title_" . $icnt]) . "',";
	}
}
$img_string=substr($img_string,0,-1);
$title_string=substr($title_string,0,-1);
if ($img_string!=""){
	echo '<script language="javascript">load_images(' . $img_string  .');</script>';
}
if ($title_string!=""){
	echo '<script language="javascript">load_titles(' . $title_string  .');</script>';
}
?>
<tr><td valign="top">
	<table cellpadding="2" cellspacing="0" width="100%" border="0">
      <tr>
	  	<td valign="top" align="left" nowrap="nowrap"  rowspan="3" width="50%">
			<table cellpadding="2" cellspacing="0" width="100%" border="0">
				<tr><?php if($product_info['author_name']!='') $author='<b>by '. stripslashes($product_info['author_name']).'</b>';
							else $author='';
				?>
					<td valign="top" class="main"><?php echo $author.'<br>'.stripslashes($product_info['products_description']); ?></td>
				</tr>
			</table>
		</td>
        <td class="main" valign="top" width="50%">
          <table border="0" cellspacing="0" cellpadding="2" width="100%">
            <tr>
				
				<?php if (count($images)>0) { ?>
					<td valign="top" width="50%">
					<table border="0" width="0" cellpadding="2" cellspacing="0" align="center">
						<tr>
							<td valign="top" align="center" class="main" height="300">
							<?php 
									if (file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . "big/" .$images[0]["image"])){
										echo '<image src="' . DIR_WS_IMAGES . "big/" . $images[0]["image"] . '" id="imgContainer">';
									} else {
										echo '<image src="' . DIR_WS_IMAGES . $images[0]["image"] . '" id="imgContainer">';
									}	
							?><br /><br /><b><span id="titleContainer"><?php echo stripslashes(tep_output_string($product_info['products_title_1']));?></span></b>

							</td>
						</tr>
						<tr>
							<td valign="top" align="center" class="main">
							</td>
						</tr>
						<?php  if (count($images)>1) { ?>
						<tr>
							<td valign="top" width="50%">
							<table border="0" width="0" cellpadding="0" cellspacing="2"  bgcolor="#FFFFFF">
									<tr>
								<?php for ($icnt=0;$icnt<count($images);$icnt++) {$image_width +=SMALL_IMAGE_WIDTH;  if($image_width>300){echo '</tr><tr>';$image_width=0;}?>
									<td class="smallText" align="center" valign="bottom" style="border:1px solid #E5E4E4">
										<table border="0" width="0" cellpadding="0" cellspacing="2">
											<tr height="100">
												<td valign="middle" align="center">
												<?php echo tep_product_small_image($images[$icnt]["image"],$images[$icnt]["title"],'onClick="javascript:set_image(' . $icnt .');" style="cursor:pointer;cursor:hand;"');?>
												</td>
											</tr>
											<tr>
												<td class="smallText" align="center">
												<?php echo stripslashes(tep_output_string($images[$icnt]["title"]));?>
												</td>
											</tr>
										</table>
									</td>
								<?php } ?>
									</tr>
							</table>
							</td>
						</tr>
						<?php } // images>1?>
					</table>
					</td>
				<?php
					}
				?>
				</tr>
          
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
	
	<tr id="add_cart" style="display:''">
			<td><table border="0" width="100%" align="center" cellspacing="1" cellpadding="2" class="infoBox">
			  <tr class="infoBoxContents">
				<td>
				
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
				  <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_REVIEWS, tep_get_all_get_params()) . '">' . tep_template_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
					<td class="main" align="left"><?php echo  tep_template_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
									  
				   <!-- Begin Wishlist Code -->
					<td align="right" class="main"><?php //if (tep_session_is_registered('customer_id')) echo '<a href="' . tep_href_link(FILENAME_WISHLIST, tep_get_all_get_params(array('action')) . 'action=add_wishlist') . '">' . tep_image_button('button_add_wishlist.gif', IMAGE_BUTTON_ADD_WISHLIST) . '</a>'; ?></td>
				   <!-- End Wishlist Code -->
					
					
					<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				  </tr>
				</table>
				
				</td>
			  </tr>
			</table></td>
			</tr>
	<tr>
		<td valign="top" id="prd_attribs">		  
<?php   
       $initial =0;
				  $iname = 0;
				$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
				   $products_attributes = tep_db_fetch_array($products_attributes_query);
			///////////////////////////////////////////////////////////////////////////
			// BOF: attribute options
			if($product_info['is_attributes']=='Y'){
				if ($products_attributes['total'] > 0) {
				  $products_options_name = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'" . " order by popt.products_options_sort_order");
				  echo '<table width="100%" border="0" cellpading="0" cellspacing"0">';
				  echo '<tr height="25"><td class="availability" colspan="2" width="50%"><b>&nbsp;' . TEXT_PRODUCT_OPTIONS . '</b></td></tr><tr height="10"><td colspan="2"></td></tr>';
				  while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {
					$selected = 0;
					$initial++;
					$products_options_array = array();
					$products_options_array[] = array('id'=>0,'text'=>TEXT_SELECT_ATTRIBUTE);
					$attributes_array[]=array("id"=>$products_options_name_values['products_options_id']);
					echo '<tr height="25"><td class="main">' . $products_options_name_values['products_options_name'] . '</td><td>' . "\n";
			// BOF: WebMakers.com Added: Attributes Copy and Sort
					  if (PRODUCTS_OPTIONS_SORT_BY_PRICE !='1' ) {
							$products_options = tep_db_query("select  pa.products_options_sort_order, pa.options_id, pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'" . " order by pa.products_options_sort_order, pov.products_options_values_name");
					  } else {
							$products_options = tep_db_query("select pa.products_options_sort_order, pa.options_id, pa.options_values_id, pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'" . " order by pa.products_options_sort_order, pa.options_values_price");
					  }
			// EOF: WebMakers.com Added: Attributes Copy and Sort
					  while ($products_options_values = tep_db_fetch_array($products_options)) {
						 if($initial == 1){ 
						   //echo "select attributes_id from ". TABLE_PRODUCTS_STOCK . " where attribute_status='1' and products_id=$HTTP_GET_VARS['products_id']";
						   $stock_check_query = tep_db_query("select  attributes_id from ". TABLE_PRODUCTS_STOCK . " where attribute_status='1' and products_id = '".  $HTTP_GET_VARS['products_id'] ."'");
						  
						   if(tep_db_num_rows($stock_check_query) > 0){
						   while($stock_check = tep_db_fetch_array($stock_check_query)) {
						   		$temp = split('-', $stock_check['attributes_id']);
								$n = count($temp);
								$allow=0;
						  		for($icnt=0; $icnt<$n ; $icnt++){
						  	  		$split = split('{',$temp[$icnt]);
						      		if($split[0] == $products_options_name_values['products_options_id']){
							     		$id_pos = strpos($split[1],'}');
								 		$opt_val_id = substr($split[1],0,$id_pos);
											 if($opt_val_id == $products_options_values['products_options_values_id'] ){
											 	for($icn=0;$icn<count($products_options_values);$icn++){
												   if($products_options_array[$icn]['id'] == $products_options_values['products_options_values_id']) 
											  	   $allow = 1;	}
												   if($allow == 0){
												      $products_options_array[] = array('id' => $products_options_values['products_options_values_id'], 'text' => $products_options_values['products_options_values_name']);
											           if ($products_options_values['options_values_price'] != '0') {
													       $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options_values['price_prefix'] . $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info_values['products_tax_class_id']),'1',true) .') ';
						 							       }
												       }
											       }
											  }  
						         		 }   
						       		 }
						    	}
						 } 
					  }
					 
					echo tep_draw_pull_down_menu('sel_combo['.$products_options_name_values['products_options_id'].']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name_values['products_options_id']],' id="sel_combo['. $products_options_name_values['products_options_id'] .']" style="width:150px" onchange="javascript:load_stock(this,\'' . $HTTP_GET_VARS['products_id'] . '\','.$iname.');"');
					$iname++;
					echo '</td></tr>';		
				  }//while
			}
			}
		  echo '<table width="100%" align="left" border="0" cellpadding="0" cellspacing="0">';
		  echo '<tr height="30"><td colspan="2" valign="top"></td></tr>';
		  $selected_products_name = tep_db_query("select pd.products_id,pd.products_name,p.products_price from " . TABLE_PRODUCTS . " p," . TABLE_PRODUCTS_DESCRIPTION . " pd," . TABLE_PRODUCTS_TO_CATEGORIES . " pc where pc.categories_id=" . $current_category_id . " and pc.products_id=p.products_id and pd.products_id=p.products_id and pd.language_id=" . $languages_id . " order by rand() limit 0,3");
		  $check_selected_products_name = $selected_products_name;
		  $check_count = tep_db_num_rows($check_selected_products_name);
		  if($check_count>1){
			  echo '<tr height="25"><td class="availability" colspan="2"><b>&nbsp;' . TEXT_BUY . '</b></td></tr><tr height="10"><td colspan="2"></td></tr>';
			  $count=0;
			  while($fetch_row = tep_db_fetch_array($selected_products_name)){	  		
					if(($fetch_row['products_id']!=(int)$HTTP_GET_VARS['products_id']) && ($count < 2)){
						echo '<tr height="30" valign="middle"><td class="main"><a class="brown" href="' . tep_href_link(FILENAME_PRODUCT_INFO,'cPath='.$cPath.'&products_id='.$fetch_row['products_id']) . '">' . $fetch_row['products_name'] . '</a></td><td class="main" width="30%" align="right">' . $currencies->format($fetch_row['products_price']) . '</td></tr>';
						$count++;
					} 
			  }
		  }
		  echo '</table>'; 
// EOF: attribute options
///////////////////////////////////////////////////////////////////////////
?>

        </td>
		</tr>
		<tr>
				<td id="out_of_stock" style="display:none">
					<table cellpadding="5" cellspacing="0" width="100%" border="0" bgcolor="c7daef">
						<tr>
							<td><table cellpadding="2" cellspacing="0" width="100%">
								<tr>
									<td bgcolor="6a96db" width="150" class="infoboxheading"><?php echo TEXT_AVAILABILITY; ?></td>
								</tr>
								<tr>
									<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '3'); ?></td>
								</tr>
								<tr>
									<td>
										<table cellpadding="2" cellspacing="0" border="0" width="100%" bgcolor="ffffff">
											<tr>
												<td class="infoBoxContents"><?php echo "<b>" . TEXT_OUT_STOCK . "</b>";?></td>
											</tr>
											<tr>
												<Td class="infoBoxContents"><?php echo TEXT_OUT_STOCK_DETAILS;?></Td>
											</tr>
										</table>
									</td>
								</tr>
								<tr>
									<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '3'); ?></td>
								</tr>
								<tr>
									<td class="smallText" align="right"><?php echo TEXT_EMAIL .'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . tep_draw_input_field('txt_email','','size="20"') ; ?></td>
								</tr>
								<tr>
									<td align="right" >
									<?php  echo tep_template_image_submit('button_remind_me.gif', IMAGE_BUTTON_REMINDME,'onclick=javascript:remindme(); style="cursor:pointer"') ;
											?></td>
								</tr>
							</table></td>
						</tr>
					</table>
				</td>
				
      </tr>
	  </table>
	  </td>
	  </tr>
	 </table>
	</td></tr>  
	
      <tr>
      	<td colspan="2">
	<?php include(DIR_WS_MODULES . FILENAME_DYNAMIC_MOPICS);  ?>
	</td>
      </tr>
      <tr>
        <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      
	  </tr>	
	<?php $admin_review_query = tep_db_query("select reviews_text from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.reviews_id=rd.reviews_id and r.admin_review=\"Y\" and r.products_id = '" . (int)$products_id . "'");
		 
		  $admin_review_array = tep_db_fetch_array($admin_review_query);
	 ?>
	 <?php if(tep_db_num_rows($admin_review_query)>0){ ?>
	<tr>
		<td class="main"><b><?php echo TEXT_ADMIN_REVIEW; ?></b> </td>
	</tr>
	<tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td> </tr>
	<tr>
		<td class="main"><?php echo $admin_review_array["reviews_text"]; ?> </td>
	</tr>
	<?php } ?>   
<?php
    $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
    $reviews = tep_db_fetch_array($reviews_query);
    if ($reviews['count'] > 0) {
?>
     <!-- <tr>
        <td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td>
      </tr> !-->
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php    }
    if (tep_not_null($product_info['products_url'])) {
?>
      <tr>
        <td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
    }

    if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
      <tr><?php //print_r($product_info); //echo  $product_info['products_date_available'];?>
        <td  colspan="2" align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
      </tr>
<?php
    } else {
?>
      <tr>
        <td  colspan="2" align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
      </tr>
<?php
    }
?>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_bottom();
}
// EOF: Lango Added for template MOD
?>
<input type="hidden" name="product_stock" value="<?php echo $any_out_of_stock; ?>" />
<input type="hidden" name="attribute_stock" value="<?php echo $attribute_out_of_stock; ?>" />

      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
	  <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td>
<?php
//Added for x sell
 /*  if ( (USE_CACHE == 'true') && !SID) { 
    echo tep_cache_also_purchased(3600); 
     include(DIR_WS_MODULES . FILENAME_XSELL_PRODUCTS); 	 
   } else {  */
      include(DIR_WS_MODULES . FILENAME_XSELL_PRODUCTS_BUYNOW);
	  echo tep_draw_separator('pixel_trans.gif', '100%', '10');
      include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
	  
   // }
   }
 //  }
 echo tep_draw_hidden('attribute_value');
?>

<script type="text/javascript">
<?php 
	
	for($i=0;$i<sizeof($attributes_array);$i++){ ?>
	attrib[<?php echo $i;?>]="<?php echo $attributes_array[$i]['id'];?>";
<?php 	} ?>
<?php if($product_info['is_attributes']=='Y'){?>
		  <?php for($li=0,$max=sizeof($att_array);$li<$max;$li++){
		  		$row=$att_array[$li];
				echo "prd_att[" . $li . "] = new Array(5);" ;
				echo "prd_att[" . $li . "][0] = " . $row['stock'] .";";
				echo "prd_att[" . $li . "][1] = '" . $row['attributes'] ."';";
				echo "prd_att_status[" . $li . "] = '" . $row['status'] ."';";
				echo "prd_attributes[" . $li . "] = '" . $row['attributes'] ."';";
		   }
		   for($li=0,$max=sizeof($attributes_array);$li<$max;$li++)
				echo "option_array[" . $li . "] = " . $attributes_array[$li]['id'] . ";" ;
			echo "option_array=option_array.sort();";
		} ?>	


	if(product_stock<=0) {
		document.getElementById("out_of_stock").style.display="";
		document.getElementById("add_cart").style.display="none";
	}	
	else {
			for(j=0;j<prd_att_status.length;j++){
			  
			   if(prd_att_status[j] == 0)
			    is_status = parseInt(is_status) + 1; 
			}	
      if(is_attribute=='Y' &&  is_status == prd_att_status.length){
	   	document.getElementById("out_of_stock").style.display="";
	   	document.getElementById("add_cart").style.display="none";
	   	document.getElementById("prd_attribs").style.display="none";
	   } 
	}

	</script>
	 </td> </tr>  </table>
	<?php 
	echo tep_draw_hidden_field('products_id', $product_info['products_id']) ;
	?>
	</form>
