<?php //echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO),'post','onSubmit="javascript:return validateForm();"'); 

$action_value=(isset($HTTP_POST_VARS['action_value'])?$HTTP_POST_VARS['action_value']:'');
$serverDate = date('Y-m-d H:i:s',getServerDate(false));
if($action_value=='remind') {
//echo $action_value;
//echo $HTTP_POST_VARS['attribute_value'];
	$attribute_ids=$HTTP_POST_VARS['attribute_value'];
	if($attribute_ids!="") $attribute_ids=tep_get_sorted_attribute_ids($attribute_ids);
	
	$email_address=(isset($HTTP_POST_VARS['txt_email'])?$HTTP_POST_VARS['txt_email']:'');
	$sql_array=array('products_id'=>$HTTP_GET_VARS['products_id'],
					'date_added'=>$serverDate,
					'attributes_id'=>$attribute_ids,
					'email_address'=>$email_address);
	
	tep_db_perform(TABLE_PRODUCTS_REMINDERS,$sql_array);
	$action_value="";
}
?>

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) .'action=add_product'),'post','onSubmit="javascript:return validateForm();"'); ?>
<input type="hidden" name="action_value" id="action_value">
<table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB;?>">
<script type="text/javascript">
	function validateForm(){
		for(i=0;i<document.cart_quantity.length;i++){
			if(document.cart_quantity.elements[i].type=="select-one")
			if(document.cart_quantity.elements[i].value==0){
				alert("Attribute value should not be empty");
				return false;
			}
		}
		var error="";
		/*if (document.cart_quantity.xsell_forced_item){
			if (!document.cart_quantity.xsell_forced_item.checked) error="<?php echo addslashes(ERROR_XSELL_FORCED);?>";
		}*/
		if(document.getElementById("out_of_stock").style.display=="")
		{
		//if(document.forms["cart_quantity"].elements["txt_email"]) {
			if(document.cart_quantity.txt_email.value=="")
				error+="<?php echo TEXT_ERR_EMAIL_ADDRESS; ?>";
		//}
		}		
		if (error!=""){
			alert(error);
			return false;
		}
		return true;
	}

	function load_images() { //v3.0
	  var d=document; 
  	  var a=load_images.arguments;
	  d.url_list=new Array();
		for(i=0; i<a.length; i++){ 
			d.url_list[i]=a[i];
		}
	}
	function load_titles() { //v3.0
	  var d=document; 
  	  var a=load_titles.arguments;
	  d.title_list=new Array();
		for(i=0; i<a.length; i++){ 
			d.title_list[i]=a[i];
		}
	}
	function set_image(index){
		var d=document; 
		var dest=d.getElementById("imgContainer");
		if (d.url_list[index] && dest){
			dest.src=d.url_list[index];
		}
		if (d.title_list[index]){
			d.getElementById("titleContainer").innerHTML=d.title_list[index];
		} else {
			d.getElementById("titleContainer").innerHTML="";
		}
	}
</script>
<?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 {
  	//$configuration_info_query = tep_db_query("select configuration_value from configuration where configuration_id=2125");
	//$configuration_info = tep_db_fetch_array($configuration_info_query);
    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, 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++;
		}
	}	
?>
<?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 = '<table width=100% border=0 cellpadding=4 cellspacing="0" valign="middle"><tr><td valign="top" class="infoBoxHeadingPage">' . $products_name . '</td><td align="right" width="200" valign="top" class="infoBoxHeadingPage">' . $products_price .'</td></tr></table>';
$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" width="100%">
	<table cellpadding="2" cellspacing="0" width="100%" border="0">
      <tr>
        <td class="main" valign="top" colspan="2" width="100%">
        <table border="0" cellspacing="0" cellpadding="2">
            <tr>
			<?php if (count($images)>0) { ?>
				<td valign="top" width="50%" align="center">
				<table border="0" width="0" cellpadding="2" cellspacing="0" align="center">					
					<tr>
						<td valign="top" align="center" class="main">
							<?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">';
									}	
							?>
						</td>
					</tr>
					<tr>
						<td valign="top" align="center" class="main">
							<b><span id="titleContainer"><?php echo stripslashes(tep_output_string($product_info['products_title_1']));?></span></b>
						</td>
					</tr>
					<tr><td></td></tr>
					
					<tr>
					<?php  if (count($images)>1) { ?>
						<td valign="top" width="50%" align="right">
						<table align="center" border="0" width="0" cellpadding="2" 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 align="center" border="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>
						<?php } // images>1?>						
					</tr>
				</table>
				</td>
				<?php
					}
				?>							
			</tr>
		</table>
	    </td>
	  </tr>
<!-- Entering Description and Available option view -->	
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '3'); ?></td>
	</tr>
	  <tr>	
	  	<td valign="top" align="left" width="100%">
			<table cellpadding="2" cellspacing="0" border="0">
				<tr>
					<td valign="top" colspan="0" width="100%"><?php echo stripslashes($product_info['products_description']); ?></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '3'); ?></td>
	</tr>
	<tr>
		<td valign="top" width="50%">
<?php
    $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="50%" align="left" border="0" cellpading="0" cellspacing"0">';
	  echo '<tr height="25"><td class="availability" colspan="2"><b>&nbsp;' . TEXT_PRODUCT_OPTIONS . '</b></td></tr>';
	  echo '<tr height="10"><td colspan="2"></td></tr>';
      while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {
        $selected = 0;
        $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)) {
			  $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('id[' . $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="'.$id1.'"onchange="javascript:price();"') ;
		echo tep_draw_pull_down_menu('id[' . $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="id[' . $products_options_name_values['products_options_id'] . ']' . '" onchange="javascript:out_stock();"');
        echo '</td>';//</tr>		
      }//while
	  echo '</tr></table></td></tr>';
	  echo '<tr height="30"><td colspan="2"></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  valign="top"><table width="50%" border="0"><tr><td class="availability" colspan="2"><b>&nbsp;' . TEXT_BUY . '</b></td></tr>';
		  echo '<tr><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><td class="main" width="50%"><a class="brown" href="' . tep_href_link(FILENAME_PRODUCT_INFO,'cPath='.$cPath.'&products_id='.$fetch_row['products_id']) . '">' . $fetch_row['products_name'] . '</a></td>';
					echo '<td align="right" class="main">'.$currencies->display_price($fetch_row['products_price'],'').'</td></tr>';
					$count++;
				}
		  }
	  echo '</table></td></tr>';
	 }
	 echo '<tr height="10"><td colspan="2"></td></tr>';
	}
	}
	  else{
		  echo '<table width="50%" align="left" border="0" cellpading="0" cellspacing"0">';
		  echo '<tr height="30"><td colspan="2"></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 colspan="2"><b>&nbsp;' . TEXT_BUY . '</b></td></tr>';
			  echo '<tr height="10"><td colspan="2"></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");
			  $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><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>';
						echo '<td class="main" align="left">'.$currencies->display_price($fetch_row['products_price'],'').'</td></tr>';
						$count++;
			  } 
		}
	}
     echo '<tr height="10"><td colspan="2"></td></tr>';
}
// EOF: attribute options
///////////////////////////////////////////////////////////////////////////
?>
<tr>
		<td colspan="2" >
			<table id="out_of_stock" style="display:none" cellpadding="5" cellspacing="0" width="50%" border="0" bgcolor="c7daef" align="left">
		<?php //if($any_out_of_stock>0 || $attribute_out_of_stock>0) {
				//if(trim(DISPLAY_PRODUCT_REMINDME)=="Enabled"){  //Check Remind Me(alterby admin) Enabled or Not
		 ?>
						<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','','id="txt_email" size="20"') ; ?></td>
						</tr>
						<tr>
							<td align="right" ><?php //echo  '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO,'products_id=' . $HTTP_GET_VARS['products_id'] . '&action_value=remind') . '">' . tep_template_image_button('button_remind_me.gif', IMAGE_BUTTON_REMIND) .'</a>' ; ?>
							<?php  echo tep_template_image_submit('button_remindme.gif', IMAGE_BUTTON_REMINDME,'onclick=javascript:remindme();') ;
									echo tep_draw_hidden('attribute_value');?></td>
						</tr>
			<?php 
					//}
				//}
			 ?>	
					</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
    $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>
        <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 id="add_cart" style="display:block">-->
	 
     <!-- </tr>-->
	  <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
	  <tr id="add_cart" style="display:''">
        <td colspan="2">
		<table border="0" width="100%" align="center" cellspacing="1" cellpadding="2" >
          <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="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_template_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table>
			</td>
          </tr>
        </table>
		</td>
	  </tr>
      <tr>
        <td>
<script>
   
	var is_attribute;		
	var product_stock="<?php echo $product_info["products_quantity"]; ?>";
	if(product_stock <= 0) {
		document.getElementById("out_of_stock").style.display="";
		document.getElementById("add_cart").style.display="none";
	}	
	else {
	 is_attribute='<?php echo $product_info['is_attributes'];?>';
	<?php if($product_info['is_attributes']=='Y'){?>
		  var prd_att = new Array();
		  var prd_att_status = new Array();
		  var prd_attributes = new Array();
		  <?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'] ."';";
		   }
		   echo "var option_array=new Array();";
		   for($li=0,$max=sizeof($attributes_array);$li<$max;$li++){
				echo "option_array[" . $li . "] = " . $attributes_array[$li]['id'] . ";" ;
			}
			echo "option_array=option_array.sort();";
		} ?>
}
function remindme()
{
<?php if($product_info['is_attributes']=='Y'){?>
	document.getElementById('attribute_value').value=get_attribute_value();
<?php }?>
 <?php echo 'document.cart_quantity.action="' . tep_href_link(FILENAME_PRODUCT_INFO,'products_id=' . $HTTP_GET_VARS['products_id']) .'";'. 'document.cart_quantity.action_value.value="remind"' ; ?>
}
function get_option_value(opt)
{
	if(document.getElementById('id[' + opt + ']'))
		return document.getElementById('id[' + opt + ']').value;
	else
		return 0;
}
function get_attribute_value()
{
  attribute_value="";
  if(option_array){
	  for(at=0;at<option_array.length;at++)
	  {
		opt_value=get_option_value(option_array[at]);
		if(opt_value!=0)
		{
			if(attribute_value!="")
				attribute_value+="-";
			   attribute_value+=option_array[at] + "{" + opt_value + "}";
		}
	  }
  }

  return attribute_value;
}

		function out_stock(){
			if(is_attribute=='Y')
			{
			//alert ("att");
			  attribute_value=get_attribute_value();
			 for(i=0;i<prd_att.length;i++){
				if(prd_att[i][1]==attribute_value)
				{
					if(prd_att[i][0]<=0){
						if(document.getElementById("out_of_stock")) 
							document.getElementById("out_of_stock").style.display="";
						if(document.getElementById("add_cart")) 
							document.getElementById("add_cart").style.display="none";
						<?php //echo 'document.cart_quantity.action="' . tep_href_link(FILENAME_PRODUCT_INFO,'products_id=' . $HTTP_GET_VARS['products_id'] . '&action_value=remind') .'";'; ?>
						}
					else {
						if(document.getElementById("out_of_stock"))
						      document.getElementById("out_of_stock").style.display="none";
						if(document.getElementById("add_cart")) 
						      document.getElementById("add_cart").style.display="";
						<?php //echo 'document.cart_quantity.action="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product') . '";'; ?>	
					  }
				   break;
				}
			 }
			 if(i>=prd_att.length)
			   {
					if(document.getElementById("out_of_stock")) 
					  document.getElementById("out_of_stock").style.display="none";
					if(document.getElementById("add_cart")) 
					  document.getElementById("add_cart").style.display="";
					<?php //echo 'document.cart_quantity.action="' . tep_href_link(FILENAME_PRODUCT_INFO,'products_id=' . $HTTP_GET_VARS['products_id'] . '&action_value=remind') .'";'; ?>
			    }
		 }	
		// else {
					//document.getElementById("out_of_stock").style.display="";
					//document.getElementById("add_cart").style.display="none";
					<?php //echo 'document.cart_quantity.action="' . tep_href_link(FILENAME_PRODUCT_INFO,'products_id=' . $HTTP_GET_VARS['products_id'] . '&action_value=remind') .'";'; ?>
		// }
		var att_arr = new Array();
		var selected_att_arr = new Array();
		selected_att_arr = '';
		for(i=0;i<document.cart_quantity.length;i++){
			if(document.cart_quantity.elements[i].type=="select-one"){
				selected_att_arr +=document.cart_quantity.elements[i].value;
			}
		}
		for(i=0;i<prd_attributes.length;i++){
			var split0 = prd_attributes[i].split("-");
			att_arr[i] = '';
			for(j=0;j<split0.length;j++){
				var split1 = split0[j].split("{");
				var split2 = split1[1].split("}");
				att_arr[i] += split2[0];
			}
		}
		for(i=0;i<att_arr.length;i++){
			if(att_arr[i]==selected_att_arr){
				if(prd_att_status[i]==0){
					document.getElementById("out_of_stock").style.display="";
					document.getElementById("add_cart").style.display="none";
				}
			}
		}		
	  }		
 	out_stock();
	</script><?php
//Commented for x-sell
//    if ((USE_CACHE == 'true') && empty($SID)) {
//      echo tep_cache_also_purchased(3600);
//    } else {
//      include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
//    }
//  }
//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);
    }
   }
?>
        </td>
      </tr>
    </table></form>
