<?php
/*
  $Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

// check if the 'install' directory exists, and warn of its existence
  if (WARN_INSTALL_EXISTENCE == 'true') {
    if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {
      $messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');
    }
  }

// check if the configure.php file is writeable
  if (WARN_CONFIG_WRITEABLE == 'true') {
    if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {
      $messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');
    }
  }

// check if the session folder is writeable
  if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {
    if (STORE_SESSIONS == '') {
      if (!is_dir(tep_session_save_path())) {
        $messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');
      } elseif (!is_writeable(tep_session_save_path())) {
        $messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');
      }
    }
  }

// check session.auto_start is disabled
  if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {
    if (ini_get('session.auto_start') == '1') {
      $messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');
    }
  }

  if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {
    if (!is_dir(DIR_FS_DOWNLOAD)) {
      $messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');
    }
  }

  if ($messageStack->size('header') > 0) {
    echo $messageStack->output('header');
  }
?>
<!--

              


<?   // ---- MANUFACTURERS


  $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
  if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {

      echo '<table cellspacing=0 cellpadding=0 width=177 align=center> '.
              tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get')
             .' <tr><td colspan=2><b>Search by manufacturers:</b></td></tr>
                <tr><td height=2 colspan=2></td></tr>
                <tr><td colspan=2>
           ';      
      
      $manufacturers_array = array();
      while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
        $manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
        $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
                                       'text' => $manufacturers_name);
      }

      echo tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" class=se1') . tep_hide_session_id();
      echo ' </td>
          </form>
         </table>
           ';
  }

?>


-->



<table align="center" width="719" cellpadding="0" cellspacing="0">
	<tr>
		<td height="15"></td>
	</tr>
	<tr>
		<td>
			<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0">
				<tr><td height="4"></td></tr>
				<tr>
				<td width="6"></td>
				<td>
					<table cellpadding="0" border="0" cellspacing="0">
						<tr>
							<td valign="top">
								<table cellpadding="0" align="center" cellspacing="0">
									<tr>
										<td valign="middle" bgcolor="#F4F0ED" width="707" height="32">
											<table  cellpadding="0" cellspacing="0" align="right">
												<tr>
													<td valign="middle"><span class="ch4">Currensies:</span></td>
													<td width="4"></td>
													<td valign="middle">
<? // CURRENCIES

    echo tep_draw_form('currencies', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get');

    reset($currencies->currencies);
    $currencies_array = array();
    while (list($key, $value) = each($currencies->currencies)) {
      $currencies_array[] = array('id' => $key, 'text' => $value['title']);
    }

    $hidden_get_variables = '';
    reset($HTTP_GET_VARS);
    while (list($key, $value) = each($HTTP_GET_VARS)) {
      if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) {
        $hidden_get_variables .= tep_draw_hidden_field($key, $value);
      }
    }

    echo tep_draw_pull_down_menu('currency', $currencies_array, $currency, 'onChange="this.form.submit(); " style="width:100px; font-size: 9px" ') . $hidden_get_variables . tep_hide_session_id();
    echo '</form>';
    
?>               


													</td>
													<td width="10"></td>
													<td width="1"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="#D3CBBF" width="1" height="23"></td></tr></table></td>
													<td width="3"></td>
													<td><a href=<?=tep_href_link('shopping_cart.php')?>><img width="24" height="20" border="0" src="images/m04.jpg"></a></td>
													<td>now in your cart <a class="ch5" href=<?=tep_href_link('shopping_cart.php')?>><?=$cart->count_contents()?> items</a></td>
													<td width="15"></td>
												</tr>
										</table>
									</td>
								</tr>
								<tr><td height="5"></td></tr>
								<tr>
									<td valign="top">
										<table cellpadding="0" cellspacing="0">
											<tr>
												<td valign="top">
													<table border="0" cellpadding="0" cellspacing="0">
														<tr>
															<td>
																<table cellpadding="0" cellspacing="0">
																	<tr><td height="9"></td></tr>
																	<tr>
																		<td width="15"></td>
																		<td valign="top"><a href=<?=tep_href_link('index.php')?>><img border="0" width="268" height="58" src="images/m02.jpg"></a></td>
																		<td width="15"></td>
																	</tr>
																	<tr><td height="12"></td></tr>
																</table>
															</td>
														</tr>
														<tr>		
															<td valign="middle" align="right" height="33" bgcolor="#F4F0ED">
																<table cellpadding="0" cellspacing="0">
																	<tr>
 																	<td style="padding-right:7px" align=right><span class="ch4">Choose your language: </span></td>
 																	<td align=left>
<? // LANGUAGES

  if (!isset($lng) || (isset($lng) && !is_object($lng))) {
    include(DIR_WS_CLASSES . 'language.php');
    $lng = new language;
  }

  $languages_string = '';
  reset($lng->catalog_languages);
  while (list($key, $value) = each($lng->catalog_languages)) {
    $languages_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES .  $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a> ';
  }

  echo $languages_string;

?>     
 																	
	                  </td>
 																	<td width="5"></td>
																	</tr>
																</table>
															</td>
														</tr>
														<tr><td height="4"></td></tr>
														<tr>
															<td><a href=<?=tep_href_link('index.php','cPath=44')?>><img border="0" width="307" height="125" src="images/m03.jpg"></a></td>
														</tr>
												</table>
											</td>
											<td width="3"></td>
											<td valign="top"><img width="398" height="241" src="images/m01.jpg"></td>
										</tr>
									</table>
								</td>
							</tr>
					</table>
				</td>
			</tr>
			<tr><td bgcolor="#FFFFFF" height="3" valign="top"></td></tr>
				<tr>
						<td>
							<table  cellpadding="0" cellspacing="0">
								<tr>
										<td><a href=<?=tep_href_link('index.php')?>><img width="118" height="35" border="0" src="images/b01.jpg"></a></td>
										<td><a href=<?=tep_href_link('about_us.php')?>><img width="117" height="35" border="0" src="images/b02.jpg"></a></td>
										<td><a href=<?=tep_href_link('products_new.php')?>><img width="117" height="35" border="0" src="images/b03.jpg"></a></td>
										<td><a href=<?=tep_href_link('account.php')?>><img width="117" height="35" border="0" src="images/b04.jpg"></a></td>
										<td><a href=<?=tep_href_link('shopping_cart.php')?>><img width="117" height="35" border="0" src="images/b05.jpg"></a></td>
										<td><a href=<?=tep_href_link('checkout_shipping.php')?>><img width="121" height="35" border="0" src="images/b06.jpg"></a></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr><td height="3"></td></tr>
						<tr>
						<td>
						<table cellpadding="0" cellspacing="0">
						<tr>
						<td valign="top" width="197">
							<table cellpadding="0" border="0" cellspacing="0">
								<tr>
									<td valign="middle" bgcolor="#F4F0ED" height="33">
										<table cellpadding="0" border="0" cellspacing="0">
											<tr>
												<td width="5"></td>
												<td><img width="30" height="20" src="images/m07.jpg"></td>
												<td width="5"></td>
												<td align="left" width="157"><span class="ch6">Our Categories</span></td>
											</tr>
										</table>
									</td>
								</tr>
								<tr><td height="1"></td></tr>
								<tr>
									<td valign="top">
										<table cellpadding="0" cellspacing="0">

<?   // ---- CATEGORIES

  function tep_show_category($counter) {
    global $tree, $categories_string, $cPath_array;

   if(!$tree[$counter]['level']){               
                     
    $categories_string .= $categories_string ? '<tr><td colspan=3  height="1"></td></tr>' : '';             

    $categories_string .= '		<tr>
								                 				<td><img width="19" height="19" src="images/m00.jpg"></td>
										                 		<td bgcolor="#EEE9E4" width="17"></td>
											                 	<td width="161" align="left" bgcolor="#EEE9E4"><a class="menu" href=
    ';
    
    if ($tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $tree[$counter]['path'];
    }
    $categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display categry name
    $categories_string .= $tree[$counter]['name'];
    $categories_string .= '</a></td></tr>';
   
   }else{  // SUBCATEGORY
   
    $categories_string .= '<tr><td bgcolor="#EEE9E4"></td><td bgcolor="#EEE9E4" width="17"></td><td width="161" align="left" bgcolor="#EEE9E4"> &nbsp; &nbsp; ';

    for($i=0;$i<$tree[$counter]['le vel'];$i++)
     $categories_string .= '&nbsp;&nbsp;&nbsp;';
    
    $categories_string .= ' - <a class=menu style="font-weight:normal;" href=';   
    if ($tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $tree[$counter]['path'];
    }
    $categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display category name
    $categories_string .= $tree[$counter]['name'];
    $categories_string .= '</a></td></tr>';
   }  

    if ($tree[$counter]['next_id'] != false) {
      tep_show_category($tree[$counter]['next_id']);
    }  
  }



  define(TABLE_CATEGORIES, "categories");
  define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");
  $categories_string = '';
  $tree = array();

  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
  while ($categories = tep_db_fetch_array($categories_query))  {
    $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                'parent' => $categories['parent_id'],
                                                'level' => 0,
                                                'path' => $categories['categories_id'],
                                                'next_id' => false);

    if (isset($parent_id)) {
      $tree[$parent_id]['next_id'] = $categories['categories_id'];
    }

    $parent_id = $categories['categories_id'];

    if (!isset($first_element)) {
      $first_element = $categories['categories_id'];
    }
  }

  //------------------------
  if ($cPath) {
    $new_path = '';
    reset($cPath_array);
    while (list($key, $value) = each($cPath_array)) {
      unset($parent_id);
      unset($first_id);
      $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
      if (tep_db_num_rows($categories_query)) {
        $new_path .= $value;
        while ($row = tep_db_fetch_array($categories_query)) {
          $tree[$row['categories_id']] = array('name' => $row['categories_name'],
                                               'parent' => $row['parent_id'],
                                               'level' => $key+1,
                                               'path' => $new_path . '_' . $row['categories_id'],
                                               'next_id' => false);

          if (isset($parent_id)) {
            $tree[$parent_id]['next_id'] = $row['categories_id'];
          }

          $parent_id = $row['categories_id'];

          if (!isset($first_id)) {
            $first_id = $row['categories_id'];
          }

          $last_id = $row['categories_id'];
        }
        $tree[$last_id]['next_id'] = $tree[$value]['next_id'];
        $tree[$value]['next_id'] = $first_id;
        $new_path .= '_';
      } else {
        break;
      }
    }
  }
  $categories_string .=  '';
  tep_show_category($first_element); 
  $categories_string .=  '';

  echo $categories_string;
?>

										</table>
									</td>
											</tr>
										</table>
										</td>
										<td width="4"></td>
									<td bgcolor=#ffffff  align="left" valign="top">







<!--


  <table cellspacing=0 cellpadding=0 width=736 align=center>
   <tr><td height=36 align=right>
        <table cellspacing=0 cellpadding=0>
         <tr><td height=20></td></tr>
        <tr><td><a class=ml  href=<?=tep_href_link('specials.php')?>>Specials</a>&nbsp; <font color=#ffffff>|</font>&nbsp; <a class=ml  href=<?=tep_href_link('contact_us.php')?>>Contact Us</a>&nbsp; <font color=#ffffff>|</font>&nbsp; <a class=ml  href=<?=tep_href_link('create_account.php')?>>Create an account</a>&nbsp; <font color=#ffffff>|</font>&nbsp; <a class=ml  href=<?=tep_href_link('login.php')?>>Customer Login</a>&nbsp;</td></tr>
         <tr><td height=6></td></tr>
        </table>
   </td></tr>
   <tr><td bgcolor=#ffffff>


    <table cellspacing=0 cellpadding=0 width=728 align=center>
     <tr><td>
          <table cellspacing=0 cellpadding=0>
           <tr><td width=249>
                <table cellspacing=0 cellpadding=0>
                 <tr><td><a href=<?=tep_href_link('index.php')?>><img src=images/m01.gif width=249 height=142 border=0></a></td></tr>
                 <tr><td width=249 height=42 bgcolor=#CED5E1>
                      
                       
                       
<? // SEARCH ?>
               <table cellspacing=0 cellpadding=0 width=223 align=center>
               <tr><td height=10 colspan=3></td></tr>
               <tr><td class=ps>Product search:</td><td>
               <?=tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get')?>
               <?=tep_draw_input_field('keywords', '', 'size="20" maxlength="30" class=go') . '&nbsp;' . tep_hide_session_id()?></td><td><input type=image src=images/m09.gif width=19 height=17 border=0></td></tr>
               <tr><td height=10 colspan=3></td></tr>
              </form>
              </table>
<? // END SEARCH ?>





                 </td></tr>
                 <tr><td height=3></td></tr>
                </table>
               </td>
               <td width=6></td>
               <td width=191>
                <table cellspacing=0 cellpadding=0>
                </table>
               </td>
               <td width=282><img src=images/m07.jpg width=144 height=188><img src=images/m08.jpg width=138 height=188></td></tr>
            <tr><td height=3 width=728 bgcolor=#B9C3D4 colspan=4></td></tr>
            <tr><td height=2 colspan=4></td></tr>
          </table>
          <table cellspacing=0 cellpadding=0 width=728 bgcolor=#8596B3>
           <tr><td width=255 height=36>
                <table cellspacing=0 cellpadding=0>
                 <tr><td height=10 colspan=3></td></tr>
                 <tr><td width=15></td><td valign=middle class=ps1>Choose your language: </td><td>&nbsp; 
                 </td></tr>
                 <tr><td height=10 colspan=3></td></tr>
                </table>
               </td>
               <td width=191 height=36>
                <table cellspacing=0 cellpadding=0>
                 <tr><td height=2></td></tr>
                 <tr><td height=32 width=191 bgcolor=#CED5E1>
                      <table cellspacing=0 cellpadding=0 width=163 align=center>
                       <tr><td height=8 colspan=2></td></tr>
                       <tr><td class=ps1><font color=#5F5F5F>Currencies:</font></td><td>
                       </td></tr>
                       <tr><td height=7 colspan=2></td></tr>
                      </table>
                 </td></tr>
                 <tr><td height=2></td></tr>
                </table>
               </td>
               <td width=282 height=36>
                <table cellspacing=0 cellpadding=0>
                 <tr><td height=8 colspan=3></td></tr>
                 <tr><td width=16></td><td width=45><a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/m13.gif width=30 height=22 border=0></a></td><td width=221 class=ml>In your shopping cart <b><a class=ml href= items</a></b></td></tr>
                 <tr><td height=6 colspan=3></td></tr>
                </table>
           </td></tr>
           <tr><td height=2 colspan=3 bgcolor=#ffffff></td></tr>
          </table>
          <table cellspacing=0 cellpadding=0>
           <tr><td width=250 valign=top>
                <table cellspacing=0 cellpadding=0>
                 <tr><td width=250 class=br>
                      <table cellspacing=0 cellpadding=0 width=223 align=center>
                       <tr><td height=14></td></tr>
                       <tr><td><img src=images/m14.gif width=136 height=23></td></tr>
                       <tr><td><img src=images/m15.gif width=223 height=2></td></tr>
                       <tr><td height=10></td></tr>





                       <tr><td height=7></td></tr>                       
                      </table>
                 </td></tr>
                 <tr><td height=2></td></tr>
                 <tr><td><a href=<?=tep_href_link('product_info.php','products_id=166')?>><img src=images/m18.jpg width=250 height=78 border=0></a></td></tr>
                </table>
               </td>
               <td width=5></td>
               <td width=473 valign=top>


-->
