<?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
*/
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
//###############################################
/*  if ( (USE_CACHE == 'true') && !defined('SID')) {
    echo tep_cache_manufacturers_box();
  } else { */
//##############################################

	$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
	if (tep_db_num_rows($manufacturers_query)>0){
?>
<!-- manufacturers //-->
<tr>
	<td valign="top">
<?php
	if(!defined('BOX_HEADING_MANUFACTURERS'))define('BOX_HEADING_MANUFACTURERS', 'Manufactures');
	$info_box_contents = array();
	$info_box_contents[] = array('text'  =>  BOX_HEADING_MANUFACTURERS );
	new infoBoxHeading($info_box_contents, true, true);
	
	$template_html='<tr>
						<td width="{{INITIAL_WIDTH}}"></td><td class="{{CLASS}}">{{SPACER}}{{ICON}}<a href={{LINK_1}}>{{NAME}}</a></td>
					</tr>
					<tr>
						<td height="5"></td>
					</tr>
					';
	$replace_array=array();
	$replace_array["INITIAL_WIDTH"]=$INITIAL_WIDTH;
	$replace_array["CLASS"]="infoBoxNavigation";
	$replace_array["SPACER"]=tep_draw_separator('pixel_trans.gif',10,1);
	$replace_array["ICON"]=$CONTENT_ICON;
	$replace_html=$template_html;

	reset($replace_array);
	while(list($key,)=each($replace_array)){
		$replace_html=str_replace("{{" . $key . "}}",$replace_array[$key],$replace_html);
	}

	if (tep_db_num_rows($manufacturers_query) <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
		// Display a list
		$manufacturers_list = '';
		while ($manufacturers_values = tep_db_fetch_array($manufacturers_query)) {
			$replace_string=$replace_html;
			$replace_string=str_replace("{{LINK_1}}",tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers_values['manufacturers_id'], 'NONSSL'),$replace_string);
			$replace_string=str_replace("{{NAME}}",substr($manufacturers_values['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN),$replace_string);
			$manufacturers_list.=$replace_string;
		}
		$info_box_contents = array();
		$info_box_contents[] = array(	'align' => 'left',
								 		'text'  => '<table border="0" cellpadding="0" cellspacing="0" width="100%">' . $manufacturers_list . '</table>');
	} else {
		// Display a drop-down
		$select_box .= '<table cellpadding=3 cellspacing=2 width="100%"><tr><td>';
		$select_box .= '<select name="manufacturers_id" onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%">';
		if (MAX_MANUFACTURERS_LIST < 2) {
		$select_box .= '<option value="">' . PULL_DOWN_DEFAULT . '</option>';
		}
		while ($manufacturers_values = tep_db_fetch_array($manufacturers_query)) {
		$select_box .= '<option value="' . $manufacturers_values['manufacturers_id'] . '"';
		if ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers_values['manufacturers_id']) $select_box .= ' SELECTED';
		$select_box .= '>' . substr($manufacturers_values['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '</option>';
		}
		$select_box .= "</select></td></tr></table>";
		$select_box .= tep_hide_session_id();
		
		$info_box_contents = array();
		$info_box_contents[] = array('form'  => '<form name="manufacturers" method="get" action="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '">',
								 'align' => 'left',
								 'text'  => $select_box);
	}

	new $infobox_template($info_box_contents);
	
	$info_box_contents = array();
	$info_box_contents[] = array('align' => 'left',
	'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
							  );
	new infoboxFooter($info_box_contents, true, true);

?>
            </td>
          </tr>
<?php
	}
//}
?>
<!-- manufacturers_eof //-->
