<?php
/*
osCommerce, Open Source E-Commerce Solutions 
http://www.oscommerce.com 

Copyright (c) 2003 osCommerce 

osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 Zac Inc 

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
  require('includes/application_top.php');
  require('includes/classes/split_page_results_event.php');
  tep_get_last_access_file();
  set_time_limit(5);
  $server_date = getServerDate(true);
  $languages = tep_get_languages();
  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  $pID=isset($HTTP_GET_VARS['pID'])?$HTTP_GET_VARS['pID']:$HTTP_POST_VARS['product_id'];
  $page=(isset($HTTP_GET_VARS['page'])?$HTTP_GET_VARS['page']:'1');
  if($action!=""){
	if($action=='product_mail'){
		$product_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$pID . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");		 
		if(tep_db_num_rows($product_query)>0){
			$product = tep_db_fetch_array($product_query);
			$pInfo = new objectInfo($product);
		}
		$product_mail="";
		$product_mail.="<table border='0' cellspacing='2' cellpadding='1' width='100%'><tr><td width='17' align='center'>".tep_image('images/template/img_message.gif').'</td>';
		$product_mail.='<td width="500" align="left" class="inner_title">'.TEXT_INFO_HEADING_EMAIL_PRODUCT . '</td></tr>';
		$product_mail.='<tr><td></td><td width="500" align="left" class="main">'.TEXT_EMAIL_PRODUCT_INTRO. '</td></tr>';
		$product_mail.='<tr><td></td><td  width="500" align="left" class="main"><b>'.$pInfo->products_name. '</b></td></tr>';
		$product_mail.='<tr><td colspan="2">'.tep_draw_separator('pixel_trans.gif',50,20).'</td></tr>';		        		
		$product_mail.='<input type=hidden name=attribute_value><div id=cus_text></div><table border="0" cellpading="0" cellspacing"0" class="infoBox">';	
		$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='" . $pInfo->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'" . " order by popt.products_options_sort_order");      	
      	while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {
        	$selected = 0;
        	$products_options_array = array();		 	
		    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 = '" . $pInfo->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 = '" . $pInfo->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");
            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']);
	       	$product_mail.='<tr><td class="infoBoxContent" nowrap>' . $products_options_name_values['products_options_name'] . ':</td><td>' . tep_draw_pull_down_menu('id[' . $products_options_name_values['products_options_id'] . ']', $products_options_array,'','onchange="javascript:customer_count()";').'</td></tr>';
        }
      	$product_mail.='</table>';		
		echo 'product_mail'.$product_mail;		
	} else if($action=='page_navigation'){ 
		echo 'page_navigation';
		table_write();
	}
  	exit;
  }
  tep_db_query("update " . TABLE_PRODUCTS . " set products_date_available = '0000-00-00' where to_days('" . $server_date . "') > to_days('" . $products_date_available . "')");
  function table_write(){
  global $languages_id,$products_split,$page;
    ?>
  	<table border="0" width="100%" cellspacing="0" cellpadding="0">
    			<?php
				  $products_query_raw = "select pd.products_id, pd.products_name, p.is_attributes,p.products_date_available from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p where p.products_id = pd.products_id and p.products_date_available != '' and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_available DESC";
				  $products_split = new splitPageResultsEvent($page, MAX_DISPLAY_UPCOMING_PRODUCTS, $products_query_raw, $products_query_numrows);
				  $products_query = tep_db_query($products_query_raw);
				  $i=0;
				  while ($products = tep_db_fetch_array($products_query)) {
				    $pInfo = new objectInfo($products);
				    $class="dataTableRowEven";
					if($i%2==0) $class="dataTableRowOdd";
				    $i++;
				    if($products['products_name']){  			   			 
					    echo '<tr class="'.$class.'" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'head_'.$products['products_id'].'\').style.display==\'none\') product_expected(\'get_details\',' . $products['products_id'] . ');">' . "\n";?>
							<td>
						      <div id="data_<?php echo $products['products_id'];?>">
						       <table border="0" cellspacing="0" cellpadding="3" width="100%">
						         <tr>	
				                	<td class="dataTableContent" width="50%" align="left"><?php echo $products['products_name']; ?></td>				
				                	<td class="dataTableContent" align="left" width="50%"><?php echo $products['products_date_available']; ?></td>				
				                 </tr>
						       </table>
						       </div>
						      <div style="display:none" class="openContent" id="head_<?php echo $products['products_id'];?>"></div> 
						    </td>		 		  	 	  	
			       	   </tr>            
				<?php
				   }
			  }
			?>
              <tr>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_UPCOMING_PRODUCTS, $page, TEXT_DISPLAY_NUMBER_OF_PRODUCTS_EXPECTED); ?></td>                    
                    <td class="smallText" align="right"><?php echo $products_split->display_script_links($products_query_numrows, MAX_DISPLAY_UPCOMING_PRODUCTS, MAX_DISPLAY_PAGE_LINKS, $page,'1','product_expected(\'page_navigation\'',1); ?></td>
                  </tr>
                </table></td>
              </tr>
            </table>
 <?php  } ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/date-picker.js"></script>
<script type="text/javascript" src="htmlarea/htmlarea.js"></script>
<script type="text/javascript" src="htmlarea/editor.js"></script>
<script language="javascript" src="includes/http.js"></script>
<script language="javascript">	
	var option_array=new Array();
	var attributes_array=new Array();
	var values_arr=new Array();
	var e_option_array=new Array();
	var previous_id='';	
	<?php 
	 //get products mainpage link	
	  	$menu_link="";
	  	$admin_menus_query=tep_db_query("select  am.menu_pos,am.filename from ".TABLE_ADMIN_MENUS." am,".TABLE_ADMIN_MENUS_DESCRIPTION." amd where am.menu_id=amd.menu_id and amd.menu_text='Products' and language_id='".(int)$languages_id."'");
	  	if(tep_db_num_rows($admin_menus_query)>0){
	  		$admin_menus=tep_db_fetch_array($admin_menus_query);
	  		$menu_link=$admin_menus['filename'].'?top=1&mPath='.$admin_menus['menu_pos'].'&source=products_expected';
	  	}
	//get products mainpage link
			$attributes_array=array(); 														
			$options_array=tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_sort_order");			
			while($option_result=tep_db_fetch_array($options_array)){
				$value_query=tep_db_query("select pov.products_options_values_id, pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $option_result['products_options_id'] . "' and pov.language_id = '" . $languages_id . "'");
				while($value_result=tep_db_fetch_array($value_query)){
					$options_values_array[]=array('options_id' =>$option_result["products_options_id"],
												'values_id' =>$value_result["products_options_values_id"],
												'value_name' => $value_result["products_options_values_name"]);
				}
				$attributes_array[]=array("id"=>$option_result['products_options_id']);
			}
			for($li=0,$max=sizeof($attributes_array);$li<$max;$li++){
				echo "e_option_array[" . $li . "] = " . $attributes_array[$li]['id'].";";
				echo "e_option_array=e_option_array.sort();";
			}	 
 	?>
	var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
	function sendemail(url)
	{
		if(get_attribute_value()!="")
		url=url + '&attribute_value=' + get_attribute_value();
		location.href=url;
	}
function get_option_value(opt)
{
	if(document.getElementById('id[' + opt + ']'))
		return document.getElementById('id[' + opt + ']').value;
	else
		return 0;
}
function get_attribute_value()
{
  var attribute_value='';
  if(e_option_array){
	  for(at=0;at<e_option_array.length;at++)
	  {
		opt_value=get_option_value(e_option_array[at]);
		if(opt_value!=0)
		{
			if(attribute_value!="")
				attribute_value+="-";
			attribute_value+=e_option_array[at] + "{" + opt_value + "}";
		}
	  }
  }
  return attribute_value;
}	
function customer_count(){
	  var attribute_value=get_attribute_value();
	  if(!prd_att)
	  	return;
	 for(i=0;i<prd_att.length;i++){
		if(prd_att[i][1]==attribute_value)
		{
			if(prd_att[i][0]>=0){
				document.getElementById("cus_text").innerText="There are " + prd_att[i][0] + " customer(s) to send email";
				}
			else {
				document.getElementById("cus_text").innerText="There is no customer to send email";
			  }
		   break;
		}
	 }
	 if(i>=prd_att.length)
	   {
		 document.getElementById("cus_text").innerText="There is no customer to send email";
		}
 }		
 function product_expected(action,id,r_type,sta){		
		if(document.getElementById("span_edit") && document.getElementById("span_edit").style.display=="" && action=='page_navigation' && !sta) action='get_details';
		if(!sta) sta="";
		var obj=document.getElementById("page_1");
		if(action=='page_navigation' && obj && sta!=""){
 	 		id=parseInt(obj.options[obj.selectedIndex].value);
 	 		if(sta=='next') {
 	 			if(obj.length==obj.selectedIndex+1) return;
 	 			id+=1;
 	 		}else if(sta=='prev') {
 	 			if(obj.selectedIndex==0) return;
 	 			id-=1;
 	 		}
 	 		if(id<=1) id=1;
 	 	}else if(action=='page_navigation' && sta=="") id="";
 	 	var res_display=document.getElementById("res_display"); 	 	 	 	 	 	 	 	 	 		 	  	 	
 	 	if(res_display) res_display.style.display="none"; 	 		 	 	
 	 	 if(action!='page_navigation' && document.new_product && document.new_product.product_id && document.new_product.product_id.value>0)  {
			var old_ids=document.new_product.product_id.value;			
			var pre_data_id=document.getElementById("data_"+old_ids);
			var pre_head=document.getElementById("head_"+old_ids);			
			var loadings=document.getElementById("loading");						
			if(loadings) loadings.style.display="none";
			if(action=='page_navigation' && pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		 }		 				 	 			
			if(document.new_product.product_id && id>0 && document.new_product.product_id.value>0 && document.new_product.product_id.value!=id){			   			   
			   if(pre_head && pre_head.style.display=="") pre_head.style.display="none";
			   if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";			   			   			  
			   document.new_product.product_id.value=id;			   
			}
		if(action!='page_navigation' && document.new_product && document.new_product.product_id) document.new_product.product_id.value=id;									 								 	 	 	 
 	 	if(action){
 	 		var span_details=document.getElementById("span_details");
 	 		var span_edit=document.getElementById("span_edit");			
			var span_email=document.getElementById("span_email");								
			var data_id=document.getElementById("data_"+id);						
			var head=document.getElementById("head_"+id);
			var img_save=document.getElementById("img_save");			
			var command="";																		 
 	 		switch(action){ 	 			
 	 			case 'page_navigation':
 	 			       var page=""; 	 			       
 	 			       if(id!="") page="&page="+id; 
 	 			       command="<?php echo tep_href_link(FILENAME_PRODUCTS_EXPECTED,'action=page_navigation');?>"+page;
 	 			   	   if(document.getElementById("ajax_details")) document.getElementById("ajax_details").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>"; 	 			   	    	 			   					   
 	 			break; 	 			 	 			
 	 			case 'get_details':
				   if(head && head.style.display==""){
 	 			   	  if(span_details.style.display==""){
 	 			   	    head.style.display="none"; 	 			   	    
 	 			   	  	data_id.style.display=""; 	 			   	  	
 	 			   	  }else {
 	 			   	  	if(span_edit.style.display=="") span_edit.style.display="none";
 	 			   	  	if(span_email.style.display=="") span_email.style.display="none"; 	 			   	  	 	 			   	  	
 	 			   	  	span_details.style.display="";
 	 			   	  	if(img_save) img_save.style.display="none"; 
 	 			   	  	if(document.getElementById("img_ids")){
 	 			   	  		var tr_obj=document.getElementById("img_ids"); 	 			   	  		
 	 			   	  		if(tr_obj.childNodes[1].childNodes[0].src==img_src+'template/img_edit_hover.gif')	
 	 			   	  			tr_obj.childNodes[1].childNodes[0].src=img_src+'template/img_edit.gif';
 	 			   	  		else if(tr_obj.childNodes[2].childNodes[0].src==img_src+'template/img_message_hover.gif')	
 	 			   	  			tr_obj.childNodes[2].childNodes[0].src=img_src+'template/img_message.gif';	 	 			   	  			
 	 			   	  	}	 			   	  	  	 			   	  	 	 			   	  	
 	 			   	  }	 	 			    			   	   	 			   
 	 			 }else { 	 		
				 	if(previous_id!='')
						if(document.getElementById('head_'+previous_id))
							document.getElementById('head_'+previous_id).innerHTML='';	 	 	 			 	
 	 			 	if(data_id && data_id.style.display=="") data_id.style.display="none";
 	 			 	if(pre_head && pre_head.style.display=="") pre_head.style.display="none"; 	 			 	
 	 			 	if(head) {
 	 			 	 	head.style.display=""; 	 			 	 	 	 			 	  	 			
 	 			 		head.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	 			 		
 	 			 	}
 	 			 	command="<?php echo tep_href_link(FILENAME_PRODUCTS_MAINPAGE,'action=get_details');?>&pID="+id; 	 			 	 	 			 	
					previous_id=id;
 	 			 } 
 	 			break;
 	 			case 'edit_product':
 	 					var menu_link="<?php echo $menu_link;?>&cID="+r_type+"&pID="+id;
						if(menu_link) location.href=menu_link;
 	 			break; 	 			
 	 			case 'product_mail': 
 	 					span_email.style.display="";
 	 					span_edit.style.display=span_details.style.display="none";
 	 					span_email.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					command="<?php echo tep_href_link(FILENAME_PRODUCTS_EXPECTED,'action=product_mail');?>&pID="+id;
 	 			break; 	 
				case 'close':
		 	 			  if(head && data_id){
		 	 			  	head.style.display="none";
		 	 			  	head.innerHTML="";
		 	 			  	data_id.style.display="";	
		 	 			  } 
		 	 			break;	 												
 	 		}
 	 		if(command!="") do_get_command(command);
 	 	}
 	 } 	  	 
   function do_result(result){
   	  if(result!=""){
   	    if(result.substr(0,11)=='get_details') print_product_expected_details('get_details',result.substr(12));
		else if(result.substr(0,15)=='page_navigation') print_product_expected_details('page_navigation',result.substr(15));
		else if(result.substr(0,13)=='diff_category') {
			result_splt=result.split('#');	
			if(result_splt[1]) print_product_expected_details('get_details',result_splt[1].substr(12));	
		}
		else if(result.substr(0,12)=='product_mail') print_product_expected_details('product_mail',result.substr(12));
		else if(result.substr(0,18)=='email_sent_success') print_product_expected_details('email_sent_success','email_sent_success');
		else print_product_expected_details('edit',result);				 	 			 	 			 	 				 	 											   	 
   	  }
   }
   function print_product_expected_details(action,result){
 	 	var no_result="";
		if(result.substr(0,15)=='No Record Found')
 	 		no_result="No Record Found";
 	 	else if(result!='' && result.length>0 && action!='edit' && result.substr(0,15)!='No Record Found'){
 	 		splt_str=result.split("{}"); 	 		  	 		
 	 		var  product_id="";
			var  product_name="";
			var  product_description="";						
			var  product_last_modified="";
			var categories_id="";			
			var  new_product="";
 	 		product_id=splt_str[0]; 	 		
 	 		product_name=splt_str[1];
 	 		product_description=splt_str[2];	 		 	 									
 	 		product_last_modified=splt_str[6];
 	 		categories_id=splt_str[splt_str.length-1];
			new_product=splt_str[10];
 	 	}
 		if(document.new_product && document.new_product.product_id) var id=document.new_product.product_id.value; 		 		 		
 		var span_details=document.getElementById("span_details");	
 		var span_edit=document.getElementById("span_edit"); 	 		 	 		
 		var span_email=document.getElementById("span_email"); 						 
 		var head=document.getElementById("head_"+id); 		 		 		  
 		var data_id=document.getElementById("data_"+id);
 		var res_display=document.getElementById("res_display");
 		var img_save=document.getElementById("img_save");
		if(img_save && action!='get_details') img_save.style.display="";		
 	 	switch(action){ 	 		 	 		 	 		 	 		
 	 		case 'get_details': 	 		 	 	 		 	 		
 	 		if(head  && no_result!="")
				head.innerHTML=no_result; 	 			 	 		
 	 		else if(head && no_result==""){
	 	 		if(data_id){
	 	 			data_id.innerHTML='<table border="0" cellpadding="3" cellspacing="0" width="100%">'+
						          '<tbody><tr>'+
						         	'<td class="dataTableContent" width="50%" align="left">'+product_name+'</td>'+						         				         
					  			 	'<td class="dataTableContent" width="50%" align="left">'+new_product+'</td>'+  
						         '</tr>'+
						      	'</tbody></table>';
	 	 		}
	 	 		include="<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				"<tr height='40' class='openContent_top'>"+
				  "<td width='10'></td>"+	
				  '<td width="350" style="cursor:pointer;cursor:hand;" onclick="javascript:product_expected(\'close\','+product_id+');" align="left" valign="middle" width="200" class="inner_title">&nbsp;&nbsp;'+product_name+'</td>'+
				  "<td width='5' align='left' class='main' valign='top'>"+
				  	"<table border='0' cellspacing='0' cellpadding='0' style='height:30px;display:inline;position:relative;'>"+
				  	  "<tr class='img_move' id='img_ids'>"+
				  	  	"<td class='cell_bg_popm_left' width='5'>&nbsp;</td>"+
				  	    '<td width="5" onclick="javascript:change_class(this,1);product_expected(\'edit_product\','+product_id+','+categories_id+');" onmouseover="javascript:change_class(this,2);" onmouseout="javascript:change_class(this,3);"><img alt="Edit" title="Edit" src="images/template/img_edit.gif"></td>'+
				  	    '<td width="5" onclick="javascript:change_class(this,1);product_expected(\'product_mail\','+product_id+');" onmouseover="javascript:change_class(this,2);" onmouseout="javascript:change_class(this,3);"><img alt="Mail" title="Mail" src="images/template/img_message.gif"></td>'+				  	    				  	    
				  	    "<td class='cell_bg_popm_right' width='5'>&nbsp;</td>"+
				  	  "</tr>"+
				  	"</table>"+
				  "</td>"+
				  '<td width="300" style="cursor:pointer;cursor:hand;" onclick="javascript:product_expected(\'close\','+product_id+');">&nbsp;</td>'+
				 '<td width="80" align="right"><span id="img_save" style="display:none"><input type="image" src="images/template/img_savel.gif" alt="save" title="save" border="0">&nbsp;&nbsp;<a href="javascript:product_expected(\'get_details\','+product_id+');"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</span></td>'+
				"</tr>"+
				"<tr style='height:10'><td id='loading' style='display:none' colspan='5'><img src='images/24-1.gif' alt='Loading...' title='Loading...'></td></tr>"+				
				"<tr>"+
				  "<td colspan='8' class='main'><span style='display:none' id='span_edit'></span><span style='display:none' id='span_email'></span><span id='span_details'>"+	"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				  		"<tr>"+
				  			"<td width='50'>&nbsp;</td>"+				  							  			
							"<td width='100%'>"+				  							  			
				  				"<table width='60%' border='0' cellspacing='0' cellpadding='3' class='main'>";
				  					if(new_product!=""){
				  						include+="<tr>"+
					  						"<td align='left' width='15%' valign='top'><b><?php echo TEXT_INFO_DATE_EXPECTED;?></b></td>"+
					  						"<td align='left' width='45%' valign='top'>"+new_product+"</td>"+
				  						"</tr>";
				  					}	
				  					if(product_last_modified!=""){		  					
					  					include+="<tr>"+
					  						"<td align='left' width='15%'><b><?php echo TEXT_LAST_MODIFIED;?></b></td>"+
					  						"<td align='left' width='45%'>"+product_last_modified+"</td>"+
					  					"</tr>";						
				  					}							  					
				  			  		include+="</table></td></tr>";
						  			if(product_description){							  
										include+="<tr>"+
						  					"<td width='50%'></td><td align='left' valign='top' class='main'><div style='width:1050;height:50;overflow:auto;'>"+
						  						product_description
						  					"</div></td>"+			  			
										"</tr>";
						  			}			
								include+="<tr>"+
										'<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif',50,20); ?></td>'+
									"</tr>";	  							
					include+="</span>"+
				  "</td>"+
				"</tr>"+
			"</table>";
			head.innerHTML=include;
 	 		} 	 			 	 		
 	 	break;
 	 	case 'edit': 	 		 	 		 	 		 	 		
			if(span_edit) span_edit.style.display="";			
 	 		if(span_edit && span_details){ 	 			 	 			
 	 			span_edit.innerHTML=result; 	 			
 	 			span_details.style.display='none';
 	 		}									
       <?php 	$languages = tep_get_languages();
		   if (HTML_AREA_WYSIWYG_DISABLE=='Enable') { 
			 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
		 		initEditor('products_description[<?php echo $languages[$i]['id']; ?>]');
  	   <?php } 
		  }?>					 		  						
		toggle_panel('Cost','false','','0');
		toggle_panel('Stock','false','','0');		
		toggle_panel('Image','false','','0');
		toggle_panel('Attribute_Inventory_control','false','','0');
		change();			
		updateGross();
		init_page();				
 	 	break; 	 		
 	 	case 'page_navigation':
 	 		if(document.getElementById("ajax_details"))
 	 		 document.getElementById("ajax_details").innerHTML=result;
 	 	break;
 	 	case 'product_mail':
 	 		if(span_email) span_email.style.display="";			
 	 		if(span_email && span_details){ 	 			 	 			
 	 			span_email.innerHTML=result; 	 			
 	 			span_details.style.display='none';
 	 		}
 	 	break;	 	
 	 	case 'email_sent_success':
 	 		if(head && data_id){
 	 			head.style.display="none";
 	 			data_id.style.display="";
 	 		}
 	 		if(res_display){
 	 			res_display.style.display="";
 	 			res_display.innerHTML="<?php echo TEXT_EMAIL_SENT_SUCCESSFULLY;?>";
 	 		}
 	 	break; 		
 	 	case 'page_navigation':
 	 		if(document.getElementById("ajax_details"))
 	 		 document.getElementById("ajax_details").innerHTML=result;
 	 	break;	
 	 	}
 	 	if(res_display.style.display=="") setTimeout("res_display.style.display='none'",2000); 	 	 	 	
 	 	clearTimeout();
	  } 
	  function change_class(obj,eve){ 		 		 	 			 
		 var span_details=document.getElementById("span_details"); 
		 var span_edit=document.getElementById("span_edit");
		 var span_email=document.getElementById("span_email");				 		 			 
		 if(obj){		   		    		    
		    var img_get_src=obj.childNodes[0];
			if(img_get_src){			    
			    if(img_get_src.src==img_src+'template/img_edit.gif') {
					if(span_edit && span_edit.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_edit_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_edit_hover.gif' && span_edit && span_edit.style.display=="none") img_get_src.src=img_src+'template/img_edit.gif';
			    if(img_get_src.src==img_src+'template/img_message.gif') {
					if(span_email && span_email.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_message_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_message_hover.gif' && span_email && span_email.style.display=="none") img_get_src.src=img_src+'template/img_message.gif';		    		    		     		   	
		  }
		 }		 
	  }		
	  
	  function ValidateForm(){		
		var id=0;
		if(document.new_product && document.new_product.product_id) id=document.new_product.product_id.value;						 
		var span_details=document.getElementById("span_details");				
		var span_email=document.getElementById("span_email");		
		var loadings=document.getElementById("loading");							
		if(span_details && span_details.style.display=="") return false;		
		if(span_email && span_email.style.display==""){
			span_details.innerHTML=span_email.innerHTML="";			
			command="<?php echo tep_href_link(FILENAME_PRODUCTS_MESSAGE,'action=send_message&type=REM&return=PE');?>&pID="+id;						
			if(loadings) loadings.style.display=""; 					
			if(span_email) span_email.style.display="none";			
		}
		do_post_command('new_product',command);
		return false;
	}  
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr> 	
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="3">
         <tr><td id="res_display" class="main" style="display:none"></td></tr>
          <tr>
            <td valign="top">
            <?php echo tep_draw_form('new_product', FILENAME_PRODUCTS_EXPECTED, '', 'post', ' onsubmit="javascript:return ValidateForm();"');?>
            <table border="0" width="100%" cellspacing="0" cellpadding="2">
               <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent" width="50%"><?php echo TABLE_HEADING_PRODUCTS; ?></td>				
                <td class="dataTableHeadingContent" align="left" width="50%"><?php echo TABLE_HEADING_DATE_EXPECTED; ?></td>				
               </tr>              
               <tr>
              	<td colspan="2" id="ajax_details">
              		<?php table_write(); ?>
                </td>
               </tr>                             	 
               <input type="hidden" name="product_id" id="product_id">
               <input type="hidden" id="is_attributes" name="is_attributes">
            </form>            
           </table>
           	</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
