<?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 ZacWare

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );

  require('includes/application_top.php');
  tep_get_last_access_file();
  require('includes/classes/split_page_results_event.php');
  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  $banners_id= (isset($HTTP_GET_VARS['mID']) ? (int)$HTTP_GET_VARS['mID'] : $HTTP_POST_VARS['banner_id']);
  $page = (isset($HTTP_GET_VARS['page']) ? (int)$HTTP_GET_VARS['page'] : 1);
  require('includes/functions/events_tree.php');
  require('includes/functions/subscription_tree.php');
  require('includes/functions/services_tree.php');
  $products_array=array('id' =>'-1', 'text' => TEXT_SELECT);
  $events_array=array('id' =>'-1', 'text' => TEXT_SELECT);
  $subscriptions_array=array('id' =>'-1', 'text' => TEXT_SELECT);
  $services_array=array('id' =>'-1', 'text' => TEXT_SELECT);
  $server_date = getServerDate(true);
  if($action!=""){
  	if($HTTP_GET_VARS['mID']){
  		$banners_query_raw = tep_db_query("select * from " . TABLE_AFFILIATE_BANNERS . " where  affiliate_banners_id='" . (int)$banners_id ." ' order by affiliate_banners_title, affiliate_banners_group");
  		if(tep_db_num_rows($banners_query_raw)>0){
  			$manufacturers=tep_db_fetch_array($banners_query_raw);
      		$binfo = new objectInfo($manufacturers);
  		}  					  		
  	}
  	if($action=='get_details'){
  		echo_get_details();
  	}else if($action=='page_navigation'){
  		echo 'page_navigation';
		table_write();
  	}else if($action=='file_upload'){              
       	if ($banner_image = new upload('affiliate_banners_image', DIR_FS_CATALOG_IMAGES)){        	        	
        	$sql_array=array();
        	$sql_array=array('affiliate_banners_image'=>$banner_image->filename);
        	if($HTTP_POST_VARS['action_type']=='new'){	        	
	        	$sql_array=array('affiliate_banners_image'=>$banner_image->filename,'affiliate_date_added'=>$server_date);	        	
	        	tep_db_perform(TABLE_AFFILIATE_BANNERS,$sql_array);	        	
	          	echo tep_db_insert_id();
        	}else if($HTTP_POST_VARS['action_type']=='edit')
				tep_db_perform(TABLE_AFFILIATE_BANNERS,$sql_array, 'update', "affiliate_banners_id = '" . (int)$HTTP_POST_VARS['banner_id'] . "'");	
       	}
  	}else if($action=='edit'){
  		if(!$HTTP_GET_VARS['mID']) echo "new";
  		else if($HTTP_GET_VARS['mID']) echo 'edit';
  		tep_create_manufact();
  	}else if($action=='update'){ 
        $affiliate_banners_title = tep_db_prepare_input($HTTP_POST_VARS['affiliate_banners_title']);
		$affiliate_products_id  = tep_db_prepare_input($HTTP_POST_VARS['affiliate_products_id']);
		$affiliate_products_type = tep_db_prepare_input($HTTP_POST_VARS['category_type']);
		$flash_banner=(isset($HTTP_POST_VARS['chk_banner'])?tep_db_prepare_input($HTTP_POST_VARS['chk_banner']):'N');
        $new_affiliate_banners_group = tep_db_prepare_input($HTTP_POST_VARS['new_affiliate_banners_group']);
        $affiliate_banners_group = (empty($new_affiliate_banners_group)) ? tep_db_prepare_input($HTTP_POST_VARS['affiliate_banners_group']) : $new_affiliate_banners_group;
        $affiliate_html_text = tep_db_prepare_input($HTTP_POST_VARS['affiliate_html_text']);
        $affiliate_banners_image_local = tep_db_prepare_input($HTTP_POST_VARS['affiliate_banners_image_local']);
		$banner_height=tep_db_prepare_input($HTTP_POST_VARS['banner_height']);
		$banner_width=tep_db_prepare_input($HTTP_POST_VARS['banner_width']);
		if (!$affiliate_products_id) $affiliate_products_id="0";
        $sql_data_array = array('affiliate_banners_title' => $affiliate_banners_title, 
								'affiliate_products_id' =>$affiliate_products_id,
								'flash_banner' => $flash_banner,
                                'affiliate_banners_group' => $affiliate_banners_group,
							    'affiliate_products_type' =>$affiliate_products_type,
								'affiliate_flash_banner_width' =>$banner_width,
									'affiliate_flash_banner_height' =>$banner_height);
								
								
        if(!$HTTP_GET_VARS['mID']){
          $insert_sql_data = array('affiliate_date_added' => $server_date,
		  							 'affiliate_status' => '1');
          $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
          tep_db_perform(TABLE_AFFILIATE_BANNERS, $sql_data_array);
          $banner_id = tep_db_insert_id();
          $action='insert';
        }else  if ($HTTP_GET_VARS['mID']) {
          $update_sql_data = array('affiliate_date_status_change' => $server_date);
          $sql_data_array = array_merge($sql_data_array, $update_sql_data);
          tep_db_perform(TABLE_AFFILIATE_BANNERS, $sql_data_array, 'update', "affiliate_banners_id = '" . (int)$HTTP_GET_VARS['mID'] . "'");
          $action='save';
        }      
		if($HTTP_POST_VARS['action_type']=='new')          	
        	echo 'new_banner'.$HTTP_GET_VARS['mID'].'||'.$affiliate_banners_title;
        else if($HTTP_POST_VARS['action_type']=='edit') 
        	echo_get_details();		
  	}else if($action=='delete'){
  	  $manu='delete';  	  
  	  $manu.="<table border='0' cellspacing='2' cellpadding='1' width='100%'><tr><td width='17' align='center'>".tep_image('images/template/img_trash.gif').'</td>';
	  $manu.='<td width="500" align="left" class="inner_title">'.TEXT_HEADING_DELETE_BANNER . '</td></tr>';
	  $manu.='<tr><td></td><td width="500" align="left" class="main">'.TEXT_DELETE_INTRO. '</td></tr>';
	  $manu.='<tr><td></td><td  width="500" align="left" class="main"><b>'.$binfo->affiliate_banners_title. '</b></td></tr>';
      if($binfo->affiliate_banners_image)  $manu.='<tr><td></td><td  width="500" align="left" class="main"><b>'.tep_draw_checkbox_field('delete_image', '1', true) . ' ' . TEXT_DELETE_IMAGE. '</b></td></tr>';  	                 
      $manu.='<tr><td colspan="2">'.tep_draw_separator("pixel_trans.gif",5,10).'</td></tr></table>';
      echo $manu; 
  	}else if($action=='delete_confirm'){
  		if ($HTTP_POST_VARS['delete_image']==1) {
          $ban_query = tep_db_query("select affiliate_banners_image from " . TABLE_AFFILIATE_BANNERS . " where affiliate_banners_id = '" . (int)$HTTP_GET_VARS['mID'] . "'");
          $manufacturer = tep_db_fetch_array($ban_query);
          $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['affiliate_banners_image'];
          if (file_exists($image_location)) @unlink($image_location);
        }
        tep_db_query("delete from " . TABLE_AFFILIATE_BANNERS . " where affiliate_banners_id = '" . (int)$HTTP_GET_VARS['mID'] . "'");
        echo 'delete_success';          		
  	}
  	exit;
  }  
  function echo_get_details(){
  	global $mID,$languages_id;	
	    $affiliate_banners_query_raw = "select * from " . TABLE_AFFILIATE_BANNERS . " where affiliate_banners_id = '" . (int)$mID ."' ";		
		$affiliate_banners_query = tep_db_query($affiliate_banners_query_raw);
   		$affiliate_banners = tep_db_fetch_array($affiliate_banners_query);
		$info_query = tep_db_query("select sum(affiliate_banners_shown) as affiliate_banners_shown, sum(affiliate_banners_clicks) as affiliate_banners_clicks from " . TABLE_AFFILIATE_BANNERS_HISTORY . " where affiliate_banners_id = '" . (int)$affiliate_banners_id . "'");
      	$info = tep_db_fetch_array($info_query);
		$affiliate_banners_shown = ($info['affiliate_banners_shown'] != '') ? $info['affiliate_banners_shown'] : '0';
     	$affiliate_banners_clicked = ($info['affiliate_banners_clicks'] != '') ? $info['affiliate_banners_clicks'] : '0';
		$affiliate_products_id=$affiliate_banners['affiliate_products_id'];
		$affiliate_products_type=$affiliate_banners['affiliate_products_type'];
		if($affiliate_products_id>0){
			switch ($affiliate_products_type){
				case 'P':
  			    	$sql = "select products_name as name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$affiliate_products_id . "' and language_id = '" . (int)$languages_id . "'"; 
				break;
				case 'E':
  			    	$sql = "select events_name  as name from " . TABLE_EVENTS_DESCRIPTION . " where events_id = '" . (int)$affiliate_products_id . "' and language_id = '" . (int)$languages_id . "'"; 
				break;
				case 'S':
  			    	$sql = "select subscription_name as name from " . TABLE_SUBSCRIPTIONS_DESCRIPTION . " where subscription_id = '" . (int)$affiliate_products_id . "' and language_id = '" . (int)$languages_id . "'"; 
				break;
				case 'V':
  			    	$sql = "select service_name as name from " . TABLE_SERVICES_DESCRIPTION . " where service_id = '" . (int)$affiliate_products_id . "' and language_id = '" . (int)$languages_id . "'"; 
				break;
			}
        $product_description_query = tep_db_query($sql);
        $product_description = tep_db_fetch_array($product_description_query);
		}
  		$str_vals= $affiliate_banners['affiliate_banners_id'] . '||' .$affiliate_banners['affiliate_banners_title'] . '||' .$affiliate_banners['affiliate_date_added'] .'||' .$affiliate_banners['affiliate_date_status_change'] .'||' .$product_description['name'] .'||' .$affiliate_products_id . '||' .$affiliate_banners_shown .'||' .$affiliate_banners_clicked .'||'. $affiliate_banners['affiliate_banners_image'];
		echo 'get_details'.$str_vals;
  }
  function tep_create_manufact(){
   global $HTTP_GET_VARS,$banners_id; 
   $binfo=array();
   if($HTTP_GET_VARS['mID']){
  		$banners_query_raw = tep_db_query("select * from " . TABLE_AFFILIATE_BANNERS . " where  affiliate_banners_id='" . (int)$banners_id ." ' order by affiliate_banners_title, affiliate_banners_group");
  		if(tep_db_num_rows($banners_query_raw)>0){
  			$manufacturers=tep_db_fetch_array($banners_query_raw);
      		$binfo = new objectInfo($manufacturers);
  		}  					  		
  	}	
   ?>
  	<table border="0" cellspacing="0" cellpadding="3" width="100%">
  			<?php if(!$HTTP_GET_VARS['mID']){ ?>
  			<tr class="openContent_top">
	      	 <td colspan="5">
	      	 	 <table cellpadding="0" cellspacing="0" border="0" width="100%">	  	
		   	 		<tr align="right">
		   	 			<td colspan="2" align='right'><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href='javascript:expand_category(<?php echo (($HTTP_GET_VARS['itID'])?$HTTP_GET_VARS['itID'].',3':'0,1');?>);'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td>
		   			</tr>
		         </table>
		     </td>
  	  		</tr>
  	  	<?php } ?>
  			<tr>
  			  <td  colspan="5" class='inner_title'><?php echo ((!$HTTP_GET_VARS['mID'])?TEXT_HEADING_NEW_BANNER:TEXT_HEADING_EDIT_BANNER);?></td>
  			</tr>

			 <tr>
            <td class="main"><?php  echo TEXT_BANNERS_TITLE; ?></td>
            <td class="main" width="550"><?php echo tep_draw_input_field('affiliate_banners_title', $binfo->affiliate_banners_title, '', true); ?></td>
          </tr>
          <tr>
            <td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
		  <tr>
		  	<td class="main" width="130"><?php echo TEXT_CATEGORY;?></td>
			<td>
				<table cellpadding="0" cellspacing="2" border="0" width="50%">
					<tr>
						<td class="main"><?php echo tep_draw_radio_field('category_type','P',(($binfo->affiliate_products_type=='P')?'CHECKED':''),'','onClick=javascript:do_action();') . TEXT_PRODUCTS;?></td>
						<td class="main"><?php echo tep_draw_radio_field('category_type','E',(($binfo->affiliate_products_type=='E')?'CHECKED':''),'','onClick=javascript:do_action();'). TEXT_EVENTS;?></td>
						<td class="main"><?php echo tep_draw_radio_field('category_type','S',(($binfo->affiliate_products_type=='S')?'CHECKED':''),'','onClick=javascript:do_action();') . TEXT_SUBSCRIPTIONS;?></td>
						<td class="main"><?php echo tep_draw_radio_field('category_type','V',(($binfo->affiliate_products_type=='V')?'CHECKED':''),'','onClick=javascript:do_action();'). TEXT_SERVICES;?></td>
					</tr>
				</table>
			</td>
		</tr>	
		
		 <tr >
			<td class="main" id="select" style="display:none" width="130"><?php echo  TEXT_SELECT_CATEGORIES ;?> </td>
			<td class="main" colspan="3" align="left">
				<?php 
					$prd_id=(($binfo->affiliate_products_type=='P')?$binfo->affiliate_products_id:'');
					$events_id=(($binfo->affiliate_products_type=='E')?$binfo->affiliate_products_id:'');
					$subs_id=(($binfo->affiliate_products_type=='S')?$binfo->affiliate_products_id:'');
					$service_id=(($binfo->affiliate_products_type=='V')?$binfo->affiliate_products_id:'');
					if($prd_id ) $style = 'style="display:"';
					else $style='style="display:none"';
					if($prd_id || $events_id || $service_id || $subs_id) $style = 'style="display:"';
					else $style='style="display:none"';
				?>
				<span  id="products" style="display:<?php echo (is_numeric($prd_id)?'':'none'); ?>" class="main"><?php echo tep_draw_product_select_menu('cmb_products',$products_array,$prd_id,'id="cmb_products"',false,'0','1');?></span>
				<span id="events" style="display:<?php echo (is_numeric($events_id)?'':'none'); ?>" class="main"><?php echo tep_draw_event_select_menu('cmb_events',$events_array,$events_id,'id="cmb_events"',false,'0','1');?></span>
				<span  id="subscriptions" style="display:<?php echo (is_numeric($subs_id)?'':'none'); ?>" class="main"><?php echo tep_draw_subscription_select_menu('cmb_subscriptions',$subscriptions_array,$subs_id,'id="cmb_subscriptions"',false,'0','1') ;?></span>
				<span  id="services" style="display:<?php echo (is_numeric($service_id)?'':'none'); ?>" class="main"><?php echo tep_draw_service_select_menu('cmb_services',$services_array,$service_id,'id="cmb_services"',false,'0','1');?></span>
			</td>
		</tr>
			<?php	$sty_img="none";    
				if($binfo->flash_banner=='Y'){
					$img_w=$binfo->affiliate_flash_banner_width;
			    	$img_he=$binfo->affiliate_flash_banner_height;				  					
					if($img_w || $img_he ) {
						$style = 'style="display:"';
						$sty_img="";
					}
					else $style='style="display:none"';				
				}
			 ?>			 	
			  <tr>
		  	<td class="main"><?php echo tep_draw_checkbox_field('chk_banner','Y',(($binfo->flash_banner=='Y')?'Checked':''),'','onClick="javascript:do_banner(this)";') . '&nbsp;' . TEXT_FLASH_BANNER;?></td>
			<td>
				<table border="0" cellpadding="0" cellspacing="0" width="100%">
				 <tr id="flash_banner" style="display:<?php echo $sty_img; ?>">			 	 
						<td  nowrap="nowrap" class="main" ><?php echo TEXT_WIDTH ?></td>
						<td class="main" width="550"> <?php echo tep_draw_input_field('banner_width',$binfo->affiliate_flash_banner_width);?></td>					
						<td class="main" nowrap="nowrap"><?php echo TEXT_HEIGHT;?></td>
						<td class="main" width="550"><?php echo tep_draw_input_field('banner_height',$binfo->affiliate_flash_banner_height);?></td>
					</tr>				
				</table>
			</td>
		</tr>		
		<tr>
            <td class="main" colspan=5><?php echo TEXT_BANNERS_LINKED_PRODUCT_NOTE ?></td>
          </tr>
	    <tr>
            <td class="main" valign="top"><?php echo TEXT_BANNERS_IMAGE; ?></td>
            <td class="main"><?php 
			 echo tep_draw_file_field('affiliate_banners_image') .tep_draw_hidden_field('affiliate_banners_image'). '<br>' . $binfo->affiliate_banners_image;?></td>
          </tr>
	  </table> 
<?php }
  function table_write(){
  global $page,$languages_id;?>
  <table border="0" width="100%" cellspacing="0" cellpadding="0">  
  <tr>
 	<td colspan="5" id="ajax_details">
   	   <table border="0" cellpadding="0" cellspacing="0" width="100%">	    	
		<?php 
		  $banners_query_raw = "select * from " . TABLE_AFFILIATE_BANNERS . " order by affiliate_banners_title, affiliate_banners_group";
		  $banners_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $banners_query_raw, $banners_query_numrows);
		  $banners_query = tep_db_query($banners_query_raw);
		  $i=0;
		  while ($manufacturers = tep_db_fetch_array($banners_query)) {
		   $info_query = tep_db_query("select sum(affiliate_banners_shown) as affiliate_banners_shown, sum(affiliate_banners_clicks) as affiliate_banners_clicks from " . TABLE_AFFILIATE_BANNERS_HISTORY . " where affiliate_banners_id = '" . (int)$manufacturers['affiliate_banners_id'] . "'");
     	   $info = tep_db_fetch_array($info_query);
		    $affiliate_banners_shown = ($info['affiliate_banners_shown'] != '') ? $info['affiliate_banners_shown'] : '0';
     	    $affiliate_banners_clicked = ($info['affiliate_banners_clicks'] != '') ? $info['affiliate_banners_clicks'] : '0';
		      $class="dataTableRowEven";
			  if($i%2==0) $class="dataTableRowOdd";
			  $i++;      
		      echo '<tr class="'.$class.'" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'head_'.$manufacturers['affiliate_banners_id'].'\').style.display==\'none\') expand_category(' . $manufacturers['affiliate_banners_id'] . ',3);">' . "\n";    
		  ?>
  			<td colspan="5">
			   <div id="data_<?php echo $manufacturers['affiliate_banners_id'];?>">
			     <table border="0" cellspacing="0" cellpadding="3" width="100%">
			    <tr>
				
                	<td class="dataTableContent" width="350"><?php echo  $manufacturers['affiliate_banners_title']; ?></td>
					<td class="dataTableContent" width="450"><?php if ($manufacturers['affiliate_products_id']>0) echo $manufacturers['affiliate_products_id']; else echo '&nbsp;'; ?></td>
					<td class="dataTableContent"><?php echo $affiliate_banners_shown . '/' . $affiliate_banners_clicked;?></td>
					
                	</tr>
              	</table>
                </div>
                <div style="display:none" class="openContent" id="head_<?php echo $manufacturers['affiliate_banners_id'];?>"></div>
             </td>
            </tr>                               	
<?php }
 if(!tep_db_num_rows($banners_query)){ ?>
	<tr><td class="main" id="no_record"  align="center"><?php echo TEXT_NO_RECORDS_FOUND; ?></td></tr>
<?php } ?>	
  <tr id="new_manufact" style="display:none" class="openContent">
			<td colspan="5" class="openContent_top">	
				<table cellpadding="1" cellspacing="0" border="0" width="100%">
					<tr>
						<td class="inner_title"><?php echo 'New Banner';?></td>
						<td width='240' align='right' ><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href='javascript:drop_new_manufact();'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td>
					</tr>
					<tr><td colspan='5' ><div id="span_new" style="display:none"></div></td></tr>
				</table>
			</td>
		</tr>
              <tr>
                <td colspan="2" align="right"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php  echo $banners_split->display_count($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page, TEXT_DISPLAY_NUMBER_OF_BANNERS); ?></td>
                    <td class="smallText" align="right"><?php echo $banners_split->display_script_links($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page,1,'expand_category(\'\'','1'); ?></td>                     
                  </tr>
                </table></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/http.js"></script>
<script language="javascript" src="includes/aim.js"></script>
<script language="javascript" type="text/javascript">
	var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";	 	
    function startCallback_banner() {
	  var span_edit=document.getElementById("span_edit");
	  var image_types=Array(".png",".jpg",".jpeg",".gif",".swf");
	  var frm = document.frm_banner;
	  var error = "";
	  if(frm.action_type) var action_type=frm.action_type.value;
	  if(frm && frm.banner_id) id=frm.banner_id.value;
	  var span_edit=document.getElementById("span_edit");
	  var ids="";
	  if(span_edit && span_edit.style.display=="" || document.getElementById("new_create") && document.getElementById("new_create").style.display==""){			
	       banner=frm.affiliate_banners_title.value;
			if(banner=="" || str_trim(banner)=="" ) error+="<?php echo ERROR_BANNER_TITLE_REQUIRED;?>";				
			var type=frm.category_type;
		    for(i=0;i<type.length;i++){
			if(type[i].checked){
				switch (type[i].value) {
					case 'P':
						frm.affiliate_products_id.value=document.getElementById('cmb_products').value;
						if(document.getElementById('cmb_products').value==-1){
							error+='<?php echo ERR_SELECT_PRODUCTS;?>\n';
							}
						break;
					case 'E':
						frm.affiliate_products_id.value=document.getElementById('cmb_events').value;
						if(document.getElementById('cmb_events').value==-1) error+='<?php echo ERR_SELECT_EVENTS;?>\n';						
						break;
					case 'S':
						frm.affiliate_products_id.value=document.getElementById('cmb_subscriptions').value;
						if(document.getElementById('cmb_subscriptions').value==-1) error+='<?php echo ERR_SELECT_SUBSCRIPTIONS;?>\n';							
						break;
					case 'V':
						frm.affiliate_products_id.value=document.getElementById('cmb_services').value;
						if(document.getElementById('cmb_services').value==-1) error+='<?php echo ERR_SELECT_SERVICES;?>\n';						
						break;
				  } 
			   }
		  }  	
		  if(document.getElementById("affiliate_banners_image") && document.getElementById("affiliate_banners_image").value!="" && !check_mime_type(document.getElementById("affiliate_banners_image"),image_types))
				error+="* <?php echo ERR_IMAGE_UPLOAD_TYPE;?>\n";			  	
	  }	  
  	  if(error!=""){
  	  		alert(error);
  	  		return false;
  	  }else if(error=="" && document.getElementById("affiliate_banners_image") && document.getElementById("affiliate_banners_image").value!="")
  	  		return true;
  	  else if(document.getElementById("affiliate_banners_image") && document.getElementById("affiliate_banners_image").value=="" || span_delete && span_delete.style.display==""){
	  		ValidateForm();
	  		return false;	  
	  }	    							
  	}
  	function completeCallback_banner(response) {
  		ValidateForm(response);
  	}
	function popupImageWindow(url) {
  		window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
	}
	function do_banner(obj){		
		document.getElementById('flash_banner').style.display="";			
		if(!obj.checked) document.getElementById('flash_banner').style.display="none";
	}
	function do_action(){
		var type=document.frm_banner.category_type;
		for(i=0;i<type.length;i++){
			if(type[i].checked){
				document.frm_banner.cmb_products.value=-1;
				document.frm_banner.cmb_events.value=-1;
				document.frm_banner.cmb_subscriptions.value=-1;
				document.frm_banner.cmb_services.value=-1;
				document.getElementById('select').style.display="";
				switch (type[i].value){
					case 'P':
						document.getElementById('products').style.display="";
						document.getElementById("events").style.display="none";
						document.getElementById("subscriptions").style.display="none";
						document.getElementById("services").style.display="none";
					break;
					case 'E':
						document.getElementById('products').style.display="none";
						document.getElementById("events").style.display="";
						document.getElementById("subscriptions").style.display="none";
						document.getElementById("services").style.display="none";
					break;
					case 'S':
						document.getElementById('products').style.display="none";
						document.getElementById("events").style.display="none";
						document.getElementById("subscriptions").style.display="";
						document.getElementById("services").style.display="none";
					break;
					case 'V':
						document.getElementById('products').style.display="none";
						document.getElementById("events").style.display="none";
						document.getElementById("subscriptions").style.display="none";
						document.getElementById("services").style.display="";
					break;
				}
		  }
	  }
	}
	function ValidateForm(m_id){
		var frm = document.frm_banner;		
		if(frm.action_type) var action_type=frm.action_type.value;
		if(frm && frm.banner_id) id=frm.banner_id.value;		
		var span_details=document.getElementById("span_details");
		var span_edit=document.getElementById("span_edit");				
		var span_delete=document.getElementById("span_delete");
		var loadings=document.getElementById("loading");
		var ids="";
		if(span_edit && span_edit.style.display=="" || document.getElementById("new_create") && document.getElementById("new_create").style.display==""){
			if (span_edit && span_edit.style.display=="" || document.getElementById("new_create") && document.getElementById("new_create").style.display=="") {
				if(frm.action_type && frm.action_type.value=='edit')  ids="&mID="+id;
				if(m_id>0) ids="&mID="+m_id;																				
				command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=update');?>"+ids;
				if(loadings) loadings.style.display=""; 					
				if(span_edit) span_edit.style.display="none";
				if(document.getElementById("new_create") && document.getElementById("new_create").style.display=="") {
					if(span_edit) span_edit.innerHTML="";
					document.getElementById("new_create").style.display="none";	
				}	
				
				if(document.getElementById("new_create")){document.getElementById("new_create").style.display="none";
			document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
			display_flag=1;		
			}		
			}								 
		}else if(span_delete && span_delete.style.display=="" ){								
				span_details.innerHTML=span_edit.innerHTML="";
				command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=delete_confirm');?>&mID="+id;										
				if(loadings) loadings.style.display=""; 					
				if(span_delete) span_delete.style.display="none";			
	 	} 
	 	do_post_command('frm_banner',command);
	 	return false;		
	}
	function validate_image(){
		var image_types=Array(".png",".jpg",".jpeg",".gif");
		var frm = document.frm_banner;		
		var error = "";		
		if (document.getElementById("affiliate_banners_image") && document.getElementById("affiliate_banners_image").value!="" && !check_mime_type(document.getElementById("affiliate_banners_image"),image_types)){
			alert("* <?php echo ERR_IMAGE_UPLOAD_TYPE;?>\n");
			return false;
		}else return true;
	}	
	function expand_category(id,category,r_type,sta){
	if(id==0 && category==2){
 		if(document.getElementById('no_record'))
			document.getElementById('no_record').style.display='none';
		display_flag=0;
	}
	if(id==0 && category==1){
 		if(document.getElementById('no_record'))
			document.getElementById('no_record').style.display='';
		document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
		display_flag=1;
	}
		var span_edit=document.getElementById("span_edit");
		if(category==3 && document.getElementById('head_'+id) && document.getElementById('head_'+id).style.display!='none' && document.getElementById("span_edit") && document.getElementById("span_edit").style.display=='none' && document.getElementById("span_delete") && document.getElementById("span_delete").style.display=='none') return;
		if(!sta) sta="";
		var obj=document.getElementById("page_1");
		if(category=='1' && 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(category=='1' && sta=="") id=""; 	 	
 	 	if((category==1 || category==3) && document.getElementById("new_create").style.display==""){
 	 		document.getElementById("new_create").style.display="none"; 	 		
 	 		document.getElementById("new_create").innerHTML="";
 	 	}
 	 	if(category==2 && id==0 && document.frm_banner.banner_id && document.frm_banner.banner_id.value>0 && document.getElementById("head_"+document.frm_banner.banner_id.value) && document.getElementById("data_"+document.frm_banner.banner_id.value)){
			if(span_edit) span_edit.innerHTML="";
			document.getElementById("head_"+document.frm_banner.banner_id.value).style.display="none";
			document.getElementById("data_"+document.frm_banner.banner_id.value).style.display="";
			if(document.getElementById("new_create")) document.getElementById("new_create").style.display="";						
 	 	}
 	 	var res_display=document.getElementById("res_display");
 	 	if(res_display) res_display.style.display="none";
 	 	 if(category!=1 && document.frm_banner && document.frm_banner.banner_id && document.frm_banner.banner_id.value>0)  {
			var old_ids=document.frm_banner.banner_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(category==1 && pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		 }		 		 	 
		if(id>0 && document.frm_banner.banner_id.value>0 && document.frm_banner.banner_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.frm_banner.banner_id.value=id;			   
		}	
		if(id>0 && category!=1 && document.frm_banner && document.frm_banner.banner_id) document.frm_banner.banner_id.value=id; 														 								 	 	 	
 	 	if(category){
 	 		var span_details=document.getElementById("span_details"); 	 					
			var span_delete=document.getElementById("span_delete");								
			var data_id=document.getElementById("data_"+id);						
			var head=document.getElementById("head_"+id);
			var img_save=document.getElementById("img_save");			
			var command="";																		 
 	 		switch(category){ 	 			
 	 			case '1':
 	 			       var ser="";
 	 			       var page="";
 	 			       if(document.getElementById("search") && document.getElementById("search").value!="" && sta=="" && !r_type) {
					   	ser="&search="+document.getElementById("search").value;
						id="";
					   }else if(document.getElementById("search") && document.getElementById("search").value=="" && sta=="" && !r_type) return;
					    else if(document.getElementById("search") && document.getElementById("search").value=="" && sta=="" && r_type=='reset') id=1;
 	 			       if(id!="") page="&page="+id;
 	 			       command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=page_navigation');?>"+page+ser;
 	 			   	   if(document.getElementById("ajax_details")) document.getElementById("ajax_details").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 			break;
 	 			case 2:
 	 				 
 	 				 if(span_edit) span_edit.innerHTML="";
 	 				 if(document.frm_banner.action_type) document.frm_banner.action_type.value='new';
 	 				 document.getElementById("new_create").style.display="";
					 document.getElementById("new_create").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 				 command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=edit');?>"; 	 				 
 	 			break;
 	 			case 3:
 	 			  // if(document.getElementById("new_create")) document.getElementById("new_create").style.display="none"; 	
				   if(document.getElementById("new_create")){ document.getElementById("new_create").style.display="none"; 	 			   
				  document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
					display_flag=1;
					} 			   
 	 			   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_delete.style.display=="") span_delete.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';
 	 			   	  		if(tr_obj.childNodes[2].childNodes[0].src==img_src+'template/img_trash_hover.gif')	
 	 			   	  			tr_obj.childNodes[2].childNodes[0].src=img_src+'template/img_trash.gif';	 	 			   	  			
 	 			   	  	}	 			   	  	  	 			   	  	 	 			   	  	
 	 			   	  }	 	 			    			   	   	 			   
 	 			 }else { 	 			 	 	 			 	
 	 			 	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_MARKETING_AFFILIATE_BANNERS,'action=get_details');?>&mID="+id; 	 			 	 	 			 	
 	 			 }
 	 			break;
 	 			case 4:
 	 					span_edit.style.display=""; 	 					
 	 					span_details.style.display=span_delete.style.display="none";
 	 					span_edit.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					if(document.frm_banner.action_type) document.frm_banner.action_type.value='edit'; 	 					
 	 					command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=edit');?>&mID="+id; 
							 		 	 					 	 					 	 				 	 		
 	 			break; 	 			
 	 			case 5:	 	 				 	 				 	 		 	 				
 	 					span_delete.style.display="";
 	 					span_edit.style.display=span_details.style.display="none";
 	 					if(document.frm_banner.action_type) document.frm_banner.action_type.value='delete';
 	 					span_delete.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=delete');?>&mID="+id; 	 	 	 					 	 					 	 			
 	 			break; 	 	 			
 	 		}
 	 		if(command!="") do_get_command(command);
 	 	}
 	 }
   function do_result(result){ //alert(result);
   	  if(result!=""){
   	    if(result.substr(0,11)=='get_details') print_details('get_details',result.substr(11));
   	    else if(result.substr(0,4)=='edit') print_details('edit',result.substr(4));  	 		 				 				
		else if(result.substr(0,14)=='delete_success') print_details('delete_success',result.substr(14));
		else if(result.substr(0,6)=='delete') print_details('delete',result.substr(6));
		else if(result.substr(0,15)=='page_navigation') print_details('page_navigation',result.substr(15));		
		else if(result.substr(0,10)=='new_banner') print_details('new_banner',result.substr(10));
		else if(result.substr(0,3)=='new') {
			document.getElementById("new_create").style.display="";
			document.getElementById("new_create").innerHTML=result.substr(3);
		}				   	   
   	  }
   }
   function print_details(category,result){ 	 	 	 	 	 	 	 	 	 	
 	 	var no_result="";
		if(result.substr(0,15)=='No Record Found')
 	 		no_result="No Record Found";
 	 	else if(result!='' && result.length>0 && category!='edit' && result.substr(0,15)!='No Record Found'){
 	 		splt_str=result.split("||"); 	 		 	 		  	 		
 	 		var  banner_id="";
			var  banner_name="";
			var  banner_prod_id="";
			var  banner_image="";			
			var  banner_date_added="";
			var  banner_last_modified="";
			var  banner_prod_desc="";	
			var  stat="";		
			var stat1="";
 	 		banner_id=splt_str[0];
 	 		banner_name=splt_str[1];
			banner_date_added=splt_str[2];
 	 		banner_last_modified=splt_str[3];
			banner_prod_desc=splt_str[4];
			banner_prod_id=splt_str[5];
			stat=splt_str[6];
			stat1=splt_str[7];
 	 		banner_image=splt_str[8];			
 	 	}
 		if(document.frm_banner && document.frm_banner.banner_id) var id=document.frm_banner.banner_id.value; 				 		 		 		 	
 		var span_details=document.getElementById("span_details");	
 		var span_edit=document.getElementById("span_edit"); 	 		 	 		
 		var span_delete=document.getElementById("span_delete");				 	
 		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 && category!='get_details') img_save.style.display="";			
 	 	switch(category){ 	 		 	 		 	 		 	 		
 	 		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="0" cellspacing="0" width="100%">'+
						          '<tbody><tr style="height:20">'+
						         	'<td align="left" class="dataTableContent" width="360">'+banner_name+'</td>'+	
									'<td align="left" class="dataTableContent" width="455">'+banner_prod_id+'</td>'+	
									'<td align="left" class="dataTableContent" >'+stat+'/'+stat1+'</td>'+
						         '</tr>'+
						      	'</tbody></table>';
	 	 		}	
	 	 		include="<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				"<tr heigth='50' class='openContent_top'>"+
				  "<td width='20'></td>"+				  							  				  
				  "<td align='left' valign='middle' width='350'  class='main'>"+banner_name+"</td>"+
				  "<td width='470' align='left' class='main' valign='top'>"+
				  	"<table border='0' cellspacing='0' cellpadding='0' style='width:100;height:30px;display:inline;position:relative;'>"+
				  	  "<tr class='img_move' id='img_ids'>"+
				  	  	"<td class='cell_bg_popm_left' width='10'>&nbsp;</td>"+				  	  	
				  	    "<td width='10%' onclick='javascript:change_class(this,1);expand_category("+banner_id+",4);' 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='10%' onclick='javascript:change_class(this,1);expand_category("+banner_id+",5);' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);'><img alt='Delete' title='Delete' src='images/template/img_trash.gif'></td>"+				  	    
				  	    "<td class='cell_bg_popm_right' width='10'>&nbsp;</td>"+
				  	  "</tr>"+
				  	"</table>"+
				  "</td>"+
				 "<td width='240' align='right' 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:expand_category("+banner_id+",3);'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</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_delete'></span><span id='span_details'>"+	"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				  		"<tr>"+
				  			"<td width='10' align='center'></td>"+
							"<td width='600'>"+
				  				"<table width='50%' border='0' cellspacing='0' cellpadding='3' class='main'>";
				  					if(banner_date_added!=""){
				  						include+="<tr>"+
					  						"<td align='left' width='10%' valign='top'><?php echo TEXT_DATE_ADDED;?></td>"+
					  						"<td align='left' width='20%' valign='top'>"+banner_date_added+"</td>"+
				  						"</tr>";
				  					}
				  					if(banner_last_modified!=""){
					  					include+="<tr>"+
					  						"<td align='left' width='10%'><?php echo TEXT_LAST_MODIFIED;?></td>"+
					  						"<td align='left' width='20%'>"+banner_last_modified+"</td>"+
					  					"</tr>";
				  					}
									if(banner_prod_desc!=""){
					  					include+="<tr>"+
					  						"<td align='left' width='10%'><?php //echo TEXT_LAST_MODIFIED;?></td>"+
					  						"<td align='left' width='20%'>"+banner_prod_desc+"</td>"+
					  					"</tr>";						
				  					}							  									  			  			  						
					include+="<tr><td colspan='8'><img src='images/pixel_trans.gif' border='0' alt='' width='100%' height='20'></td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr></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';
 	 		}									       			
 	 	break;
 	 	case 'delete': 	 				 	 	
 	 		if(span_delete) span_delete.style.display="";
 	 		if(span_delete){ 	 			
 	 			span_delete.innerHTML=result; 	 			
 	 			span_details.style.display=span_edit.style.display='none';
 	 		} 	 								   			   
 	 	break; 	 	
 	 	case 'delete_success':			 
 	    	 var len=1;
 	    	 if(head && data_id) {
			 	var tbl_obj=head.parentNode.parentNode.parentNode.parentNode;			 				 				 	
			 	if(tbl_obj) tbl_obj.deleteRow(head.parentNode.parentNode.rowIndex);
			 	data_id.innerHTML=head.innerHTML="";
			 	data_id.style.display=head.style.display="none";			 				 			
			 }
 	    	 if(res_display){
	    	 	res_display.innerHTML="<?php echo TEXT_BANNER_DELETE_SUCCESS;?>";
 	    	 	res_display.style.display="";
 	    	 	var obj=document.getElementById("page_''");
 	    	 	if(obj) len=obj.options[obj.selectedIndex].value; 	    	 		 	    	 	 	    	 	
 	    	 	command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=page_navigation');?>&page="+len;				
				do_get_command(command);
 	    	 } 	    	 			 			 			
 	 	break;	
 	 	case 'page_navigation':
 	 		if(document.getElementById("ajax_details"))
 	 		 document.getElementById("ajax_details").innerHTML=result;
 	 	break;	 	 	
		case 'new_banner':														
				command="<?php echo tep_href_link(FILENAME_MARKETING_AFFILIATE_BANNERS,'action=page_navigation');?>&page=1";
				do_get_command(command);			 						
		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_delete=document.getElementById("span_delete");				 		 			 
		 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_trash.gif') {
					if(span_delete && span_delete.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_trash_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_trash_hover.gif' && span_delete && span_delete.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';		    		    		     		   	
		  }
		 }		 
	  }	
	  

</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><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr  style="height:23px" class="dataTableHeadingRow">           
         <td class="pageHeading" align="left" valign="bottom"><a alt="New" title="New" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"  id="img_new" href="javascript:expand_category(0,2);"><?php echo tep_image('images/template/img_new.gif');?></a></td>            		
          </tr>
          <tr><td><?php  echo tep_draw_separator('pixel_trans.gif',5,10); ?></td></tr>	
          <tr>
            <td valign="top" colspan="3">
            	<?php echo tep_draw_form('frm_banner',FILENAME_MARKETING_AFFILIATE_BANNERS, 'action=file_upload', 'post', ' onSubmit="javascript:return AIM.submit(document.frm_banner, {\'onStart\' : startCallback_banner, \'onComplete\' : completeCallback_banner});" enctype="multipart/form-data" '); ?> 	
            	<table border="0" width="100%" cellspacing="0" cellpadding="2">
	              <tr><td id="res_display" class="main" style="display:none"></td></tr>		
	              <tr class="dataTableHeadingRow">
	                <td class="dataTableHeadingContent" width="150"><?php echo TABLE_HEADING_BANNERS; ?></td>    
					<td class="dataTableHeadingContent" width="250"><?php echo TABLE_HEADING_PRODUCT_ID; ?></td> 
					<td class="dataTableHeadingContent" width="150"><?php echo TABLE_HEADING_STATISTICS; ?></td> 
	              </tr>
	              <tr>
	               <td colspan="5">
	                <?php table_write();?>
	               </td>
	              </tr>
	              <tr><td colspan="3" style="display:none" class="openContent" id="new_create"></td></tr>
                </table>
               	<input type="hidden" name="action_type" id="action_type">
               	<input type="hidden" name="banner_id" id="banner_id">
				<input type="hidden" name="affiliate_products_id" id="affiliate_products_id">
				<input type="hidden" name="affiliate_banners_image" id="affiliate_banners_image">
              </form>
              </td>
          </tr>
        </table></td>
      </tr>
    </table>
   </td>
   </tr>
   </table>
<!-- 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'); ?>
<script language="javascript">
	var display_flag=1;
	function do_hover_change(element,mode){
	if(display_flag==1){
	if (element.mode && mode==element.mode) return;
	if (mode==2)
		element.firstChild.src=element.firstChild.src.replace(".gif","_hover.gif");
	else
		element.firstChild.src=element.firstChild.src.replace("_hover.gif",".gif");
	}
	element.mode=mode;
	}
	function change_new_image(element){
	display_flag=1;
	element.firstChild.src=element.firstChild.src.replace('_hover.gif','.gif');
	}
</script>
