<?php
/*
  $Id: advanced_search.php,v 1.1.1.1 2002/11/28 23:21:31 wilt Exp $

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

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_ADVANCED_SEARCH, '', 'NONSSL'));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<LINK href="images/favicon.ico" rel="shortcut icon">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<?php
// BOF: WebMakers.com Changed: Header Tag Controller v1.0
// Replaced by header_tags.php
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
  require(DIR_WS_INCLUDES . 'header_tags.php');
} else {
?>
  <title><?php echo TITLE ?></title>
<?php
}
// EOF: WebMakers.com Changed: Header Tag Controller v1.0
?>
<link rel="stylesheet" type="text/css" href="<? echo THEMA_STYLE;?>">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript"><!--
function check_form() {
  var error_message = "<?php echo JS_ERROR; ?>";
  var error_found = false;
  var error_field;
  var keywords = document.advanced_search.keywords.value;
  var dfrom = document.advanced_search.dfrom.value;
  var dto = document.advanced_search.dto.value;
  var pfrom = document.advanced_search.pfrom.value;
  var pto = document.advanced_search.pto.value;
  var pfrom_float;
  var pto_float;

  if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom == '<?php echo DOB_FORMAT_STRING; ?>') || (dfrom.length < 1)) && ((dto == '') || (dto == '<?php echo DOB_FORMAT_STRING; ?>') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) ) {
    error_message = error_message + "<?php echo JS_AT_LEAST_ONE_INPUT; ?>";
    error_field = document.advanced_search.keywords;
    error_found = true;
  }

  if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>')) {
    if (!IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) {
      error_message = error_message + "<?php echo JS_INVALID_FROM_DATE; ?>";
      error_field = document.advanced_search.dfrom;
      error_found = true;
    }
  }

  if ((dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>')) {
    if (!IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>')) {
      error_message = error_message + "<?php echo JS_INVALID_TO_DATE; ?>";
      error_field = document.advanced_search.dto;
      error_found = true;
    }
  }

  if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) && (dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>'))) {
    if (!CheckDateRange(document.advanced_search.dfrom, document.advanced_search.dto)) {
      error_message = error_message + "<?php echo JS_TO_DATE_LESS_THAN_FROM_DATE; ?>";
      error_field = document.advanced_search.dto;
      error_found = true;
    }
  }

  if (pfrom.length > 0) {
    pfrom_float = parseFloat(pfrom);
    if (isNaN(pfrom_float)) {
      error_message = error_message + "<?php echo JS_PRICE_FROM_MUST_BE_NUM; ?>";
      error_field = document.advanced_search.pfrom;
      error_found = true;
    }
  } else {
    pfrom_float = 0;
  }

  if (pto.length > 0) {
    pto_float = parseFloat(pto);
    if (isNaN(pto_float)) {
      error_message = error_message + "<?php echo JS_PRICE_TO_MUST_BE_NUM; ?>";
      error_field = document.advanced_search.pto;
      error_found = true;
    }
  } else {
    pto_float = 0;
  }

  if ( (pfrom.length > 0) && (pto.length > 0) ) {
    if ( (!isNaN(pfrom_float)) && (!isNaN(pto_float)) && (pto_float < pfrom_float) ) {
      error_message = error_message + "<?php echo JS_PRICE_TO_LESS_THAN_PRICE_FROM; ?>";
      error_field = document.advanced_search.pto;
      error_found = true;
    }
  }

  if (error_found == true) {
    alert(error_message);
    error_field.focus();
    return false;
  } else {
    RemoveFormatString(document.advanced_search.dfrom, "<?php echo DOB_FORMAT_STRING; ?>");
    RemoveFormatString(document.advanced_search.dto, "<?php echo DOB_FORMAT_STRING; ?>");
    return true;
  }
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="780" cellspacing="0" cellpadding="0">
  <tr>
    <td width="186" valign="top" background="images/tableback.gif"><table border="0" width="186" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><?php echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onSubmit="return check_form(this);"'); if (SID) echo tep_draw_hidden_field(tep_session_name(), tep_session_id()); ?><table border="0" cellspacing="0" cellpadding="0">
    <TR>
                <TD>  <br>
                <table border="0" cellpadding="0" cellspacing="5">
        <!--DWLayoutTable-->
        <tr>
          <TD height="4" COLSPAN=3 valign="top"> <IMG SRC="images/product info/template1_03.gif" WIDTH=424 HEIGHT=4 ALT=""></TD>
        </tr>
        <tr>
          <TD width="21" height="18" valign="top"> <IMG SRC="images/product info/template1_05.gif" WIDTH=21 HEIGHT=18 ALT=""></TD>
          <TD width="383" valign="top" background="images/product info/template1_06.gif" ALT="" class="productinfo"><?php echo HEADING_TITLE; ?></TD>
          <TD width="20" valign="top"> <IMG SRC="images/product info/template1_07.gif" WIDTH=20 HEIGHT=18 ALT=""></TD>
        </tr>
        <tr>
          <TD height="7" COLSPAN=3 valign="top"> <IMG SRC="images/product info/template1_08.gif" WIDTH=424 HEIGHT=7 ALT=""></TD>
        </tr>
      </table></td></tr>


       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>


       <TR>
       <TD width=100% class=main align="center">
       <TABLE cellSpacing=0 cellPadding=0 width=100% align=right  border=0>
       <TBODY>
       <TR>
       <TD vAlign=top width=7 rowSpan=4></TD>
       <TD vAlign=top colSpan=3 height=8></TD></TR>
       <TR>
       <TD vAlign=top width=5></TD>
       <TD>
       <TABLE cellSpacing=0 cellPadding=2
                              width="100%" border=0 class="search">
       <TBODY>
       <TR>
       <TD class=main>
       <TABLE cellSpacing=0 cellPadding=2 border=0 width="100%">
       <TBODY>
       <tr>
       <td>
<?php

  $info_box_contents = array();
  $info_box_contents[] = array('text'  => tep_draw_input_field('keywords', '', 'style="width: 100%"'));
  $info_box_contents[] = array('align' => 'left', 'text' => tep_draw_checkbox_field('search_in_description', '1') . ' ' . TEXT_SEARCH_IN_DESCRIPTION);

  new searchbox($info_box_contents);
?>
            </td>


            <td class="smallText"><?php echo '<a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_SEARCH_HELP) . '\')">' . TEXT_SEARCH_HELP_LINK . '</a>'; ?></td>
            <td class="smallText" align="right" valign="bottom"><?php echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH); ?></td>
          </tr>
                            </TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
                            <TD vAlign=top width=6></TD></TR>
                        <TR>
                            <TD vAlign=top colSpan=3 height=18></TD></TR></TR></TBODY></TABLE></TD></TR>
        <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>

                    <TR>
                      <TD class="search">
                        <TABLE cellSpacing=0 cellPadding=0 align=left
                        border=0>
                          <TBODY>
                          <TR>
                            <TD vAlign=top width=7 rowSpan=4></TD>
                            <TD vAlign=top colSpan=3 height=8></TD></TR>
                          <TR>
                            <TD vAlign=top width=5></TD>
                            <TD >
                              <TABLE cellSpacing=0 cellPadding=2
                              width="100%" border=0>
                                <TBODY>
                                <TR>
                                <TD class=main>
                                <TABLE cellSpacing=0 cellPadding=2 border=0 width="100%">
                                <TBODY>
                                <tr>
            <td>
<?php
  $options_box = '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n" .
                 '  <tr>' . "\n" .
                 '    <td class="fieldKey">' . ENTRY_CATEGORIES . '</td>' . "\n" .
                 '    <td class="fieldValue">' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . '<br></td>' . "\n" .
                 '  </tr>' . "\n" .
                 '  <tr>' . "\n" .
                 '    <td class="fieldKey">&nbsp;</td>' . "\n" .
                 '    <td class="smallText">' . tep_draw_checkbox_field('inc_subcat', '1', true) . ' ' . ENTRY_INCLUDE_SUBCATEGORIES . '</td>' . "\n" .
                 '  </tr>' . "\n" .
                 '  <tr>' . "\n" .
                 '    <td class="fieldKey">' . ENTRY_PRICE_FROM . '</td>' . "\n" .
                 '    <td class="fieldValue">' . tep_draw_input_field('pfrom') . '</td>' . "\n" .
                 '  </tr>' . "\n" .
                 '  <tr>' . "\n" .
                 '    <td class="fieldKey">' . ENTRY_PRICE_TO . '</td>' . "\n" .
                 '    <td class="fieldValue">' . tep_draw_input_field('pto') . '</td>' . "\n" .
                 '  </tr>' . "" .
                 '</table>';

  $info_box_contents = array();
  $info_box_contents[] = array('text'  => $options_box);

  new searchBox($info_box_contents);
?>
        </td>
      </tr>
      <tr>
        <td class="main">
<?php
  if ($HTTP_GET_VARS['errorno']) {
    if (($HTTP_GET_VARS['errorno'] & 1) == 1) {
      echo str_replace('\n', '<br>', JS_AT_LEAST_ONE_INPUT);
    }
    if (($HTTP_GET_VARS['errorno'] & 10) == 10) {
      echo str_replace('\n', '<br>', JS_INVALID_FROM_DATE);
    }
    if (($HTTP_GET_VARS['errorno'] & 100) == 100) {
      echo str_replace('\n', '<br>', JS_INVALID_TO_DATE);
    }
    if (($HTTP_GET_VARS['errorno'] & 1000) == 1000) {
      echo str_replace('\n', '<br>', JS_TO_DATE_LESS_THAN_FROM_DATE);
    }
    if (($HTTP_GET_VARS['errorno'] & 10000) == 10000) {
      echo str_replace('\n', '<br>', JS_PRICE_FROM_MUST_BE_NUM);
    }
    if (($HTTP_GET_VARS['errorno'] & 100000) == 100000) {
      echo str_replace('\n', '<br>', JS_PRICE_TO_MUST_BE_NUM);
    }
    if (($HTTP_GET_VARS['errorno'] & 1000000) == 1000000) {
      echo str_replace('\n', '<br>', JS_PRICE_TO_LESS_THAN_PRICE_FROM);
    }
    if (($HTTP_GET_VARS['errorno'] & 10000000) == 10000000) {
      echo str_replace('\n', '<br>', JS_INVALID_KEYWORDS);
    }
  }
?> </td></tr></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
                            <TD vAlign=top width=6></TD></TR>
                        <TR>
                            <TD vAlign=top colSpan=3 height=18></TD></TR></TBODY></TABLE></TD></TR></form></td></table></td>


<!-- body_text_eof //-->
    <td width="138" valign="top" background="images/tableback1.gif"><table border="0" width="138" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>

<!-- body_eof //-->

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