<head>
<?php
$table_name = $_SESSION['db_prefix']."_list_timber_class";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId1 = array ();
	$arrName1 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$k = 0;
	while ($k < $position_num) {
		$arrId1[$k] = mysql_result($position_result, $k, "item_name");
		$arrName1[$k] = mysql_result($position_result, $k, "item_name");
		$k++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_timber_width";
    $class_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$class_result = execsql($class_query);
	if ($class_result!="") {
	$class_num = mysql_num_rows($class_result);
	$k = 0;
	while ($k < $class_num) {
		$arrId2[$k] = mysql_result($class_result, $k, "item_name");
		$arrName2[$k] = mysql_result($class_result, $k, "item_name");
		$k++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_timber_depth";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$k = 0;
	while ($k < $position_num) {
		$arrId3[$k] = mysql_result($position_result, $k, "item_name");
		$arrName3[$k] = mysql_result($position_result, $k, "item_name");
		$k++;
	}
	}
	
	
	$table_name = $_SESSION['db_prefix']."_list_timber_length";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId4 = array ();
	$arrName4 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$k = 0;
	while ($k < $position_num) {
		$arrId4[$k] = mysql_result($position_result, $k, "item_name");
		$arrName4[$k] = mysql_result($position_result, $k, "item_name");
		$k++;
	}
	}
	?>
<!--jscript-->
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script> 
 
</head>
<?php include('../include/wait.php') ?>


<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame">
<form id="form1" name="form1" method="get" action="storeWizbase.php" >
  <table width=700 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
    <tr style="height:270px;">
      <td width="679" valign="top" ><?php if ($_SESSION['error']==1) { ?>
        <div class="wizard_warning_frame">&nbsp;
<table width="582" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="47"><img src="../images/error.png" width="16" height="16"></td>
    <td width="535"><label class="label_std">A product / store item with the name "<?php echo $_SESSION['item_name']?>" allready exists, please use another name.</label></td>
  </tr>
</table>
        </div>
        <?php 
	 $_SESSION['productName'] ="";
     $_SESSION['suppliersName'] = "";
	 $_SESSION['color'] = "";
	 
	 $_SESSION['shelf'] = "";
	 $_SESSION['unit'] = "";
	 $_SESSION['returnable'] = "";
	 $_SESSION['quantity'] = "";
	 $_SESSION['minimumStock'] = "";
	 $_SESSION['price'] = "";
	 $_SESSION['depreciation'] = "";
	 $_SESSION['date'] = "";
	 $_SESSION['productSpecs'] = "";
	 $_SESSION['p'] = 1;
	 $_SESSION['error']=0;
	 //$_SESSION['changed']="";
	 //$_SESSION['changed2']="";
	 
		 
	 } ?>
     <?php
     if ( $_SESSION['subCategory'] == "Timber" ) { ?>
	    <div class="wizard_frame">
	      <p><br />
	        <label class="label_std">Enter type and sizes for the timber.
              <br />
              <br />
&nbsp;Class:&nbsp;</label>
	        &nbsp;&nbsp;
	        <select name="class_select" class="select80" autofocus tabindex="1">
	          <option value="<?php echo $_SESSION['class'] ?>" selected="selected"><?php echo $_SESSION['class'] ?></option>
	          <?php
        	for ($k = 0; $k < count($arrId1); $k++) {
    		echo "<option value=" . "\"" . $arrId1[$k] . "\"" . ">" . $arrName1[$k] . "</option>";
	}
?>
            </select>
	        <label class="star">*</label>
</p>
	      <p>
	        <label class="label_std">Depth:&nbsp;&nbsp;&nbsp;
              <select name="depth_select" class="select80"  tabindex="2">
                <option value="<?php echo $_SESSION['depth'] ?>" selected="selected"><?php echo $_SESSION['depth'] ?></option>
                <?php
        	for ($k = 0; $k < count($arrId3); $k++) {
    		echo "<option value=" . "\"" . $arrId3[$k] . "\"" . ">" . $arrName3[$k] . "</option>";
	}
?>
              </select>
            </label>
            <label class="star">*</label>
            <label class="label_std">&nbsp;&nbsp;&nbsp;&nbsp;Width:&nbsp;&nbsp;&nbsp;
              <select name="width_select" class="select80" tabindex="3" >
                <option value="<?php echo $_SESSION['width'] ?>" selected="selected"><?php echo $_SESSION['width'] ?></option>
                <?php
        	for ($k = 0; $k < count($arrId2); $k++) {
    		echo "<option value=" . "\"" . $arrId2[$k] . "\"" . ">" . $arrName2[$k] . "</option>";
	}
?>
              </select>
            </label>
           <label class="star">*</label>
<label class="label_std">&nbsp;&nbsp;</label>
<label class="label_std">&nbsp;&nbsp;</label>
	        <label class="label_std">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Length:&nbsp;&nbsp;
<select name="length_select" class="select80" tabindex="4" >
	            <option value="<?php echo $_SESSION['length'] ?>" selected="selected"><?php echo $_SESSION['length'] ?></option>
	            <?php
        	for ($k = 0; $k < count($arrId4); $k++) {
    		echo "<option value=" . "\"" . $arrId4[$k] . "\"" . ">" . $arrName4[$k] . "</option>";
	}
?>
              </select>
            </label>
            <label class="star">*</label>
</p>
        </div>
     <?php }
	 else {
		 ?>
	   <div class="wizard_frame" ><br />
          <label class="label_std">What is the name of the store item?</label>
          &nbsp;&nbsp;&nbsp;
          <input name="item_name_text" type="text" id="item_name_text" class="text300"  onkeyup="ToLower(this)" onBlur="capitalize(this);" value="<?php echo $_SESSION['item_name'] ?>" autofocus maxlength="50" tabindex="4" />
          <label class="star">*</label>
          <br />
          <br />
        </div>
      <?php } ?></td>
    </tr>
    <tr>
      <td><table width="590" height="50" align="left" id="table_button_bar">
          <tr>
            <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_showHideLayers('wait','','show');MM_goToURL('parent','storeWizbase.php?s=&amp;p=1');return document.MM_returnValue" /></td>
            <td width="82"><input name="error" type="hidden" id="error" value="0" />
              <input name="p" type="hidden" id="p" value="2" />
              <input name="s" type="hidden" id="s" value="2" /></td>
            <td width="132">&nbsp;</td>
            <td width="125" align="left"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php');" value="Cancel" /></td>
            <td width="110" align="left"><input type="submit" name="next_button" id="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); validate();  " tabindex="5" /></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
</div>
<script language="JavaScript" type="text/javascript" xml:space="preserve">

  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  <?php if ($_SESSION['subCategory']=="Timber") { ?>
  frmvalidator.addValidation("class_select","req","Please select class of timber.");
  frmvalidator.addValidation("width_select","req","Please select width.");
  frmvalidator.addValidation("depth_select","req","Please select depth.");
  frmvalidator.addValidation("length_select","req","Please select length.");
  <?php } else { ?>
  frmvalidator.addValidation("item_name_text","req","Please enter an item name.");
  <?php } ?>
  </script>

</body>