

<?php
   if($_SESSION['p']==1) {
		    $_SESSION['reg_no'] = $_GET['reg_no_text'];
	}
	
	$query = "SELECT reg_no FROM vehicle WHERE  reg_no = '". $_SESSION['reg_no']."' " ;
	$result = mySQL_query($query) or die ("Error in query:   $query . * ". mySQL_error());
	$num = mysql_num_rows($result);
	
	if ($num!=0) { 
	$_SESSION['error']=1;
	$_SESSION['p']=1;
	
	?>
    <script language="javascript" type="text/javascript">
        <!--
		needToConfirm = false;
	 window.location="vehicleWizbase.php?s=0&p=1 ";
        -->
     </script>

<?php	
       }
    else{


   include ('../include/formValidations.php')
?>


<?php
$table_name = "rad_list_vehicle";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId2[$b] = mysql_result($position_result, $b, "item_name");
		$arrName2[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
	$table_name = "rad_list_model";
    $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);
	$b = 0;
	while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
?>

<script language="JavaScript" src="gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>  <!--form validation-->
<script type="text/javascript" src="../css/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />

<!--form validation-->


<script language="javascript" type="text/javascript" >
<!--
function confirmRefresh() {
var okToRefresh = confirm("Do you really want to cancel this entry?");
var url='vehicleList.php'
if (okToRefresh)
	{
			window.location=url;
	}
}
// -->
</script>

<script language="JavaScript">
var needToConfirm = true;
  window.onbeforeunload = confirmExit;
   function confirmExit()
  {
    if (needToConfirm)
      return "You did not finish the wizard./nIf you leave now your data will not be saved.";
  }
</script>



<form id="feedbackform" method="GET" onsubmit="mysubmit();return false" action="vehicleWizbase.php">
    <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
          <tr>
            <td width="525" ><p class="wizard">
              <label class="std">Make:</label>
              
                &nbsp;&nbsp;&nbsp;<span class="right">
                <select name="vehicleMake_select" class="wizard1"  >
                  <option value="<?php echo $_SESSION['VehicleMake'] ?>" selected="selected"><?php echo $_SESSION['VehicleMake'] ?></option>
                  <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
                </select>
                </span>
<label class="star">*</label>
                <br />
                <br />
              <label class="std">Model:</label>
&nbsp;&nbsp;&nbsp;
<label class="star">
  <select name="vehicleModel_select" class="wizard1"  >
    <option value="<?php echo $_SESSION['VehicleModel'] ?>" selected="selected"><?php echo $_SESSION['VehicleModel'] ?></option>
    <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
  </select>
  *</label>
<br />
              </p>
              <p class="wizard">
                
                <label class="std">Year of manufacturing:</label>
                
              &nbsp;&nbsp;
              <select name="year_select" id="year_select" class="wizard2">
                <option value="1995">1995</option>
                <option value="1996">1996</option>
                <option value="1997">1997</option>
                <option value="1998">1998</option>
                <option value="1999">1999</option>
                <option value="2000">2000</option>
                <option value="2001">2001</option>
                <option value="2002">2002</option>
                <option value="2003">2003</option>
                <option value="2004">2004</option>
                <option value="2005">2005</option>
                <option value="2006">2006</option>
                <option value="2007">2007</option>
                <option value="2008">2008</option>
                <option value="2009">2009</option>
                <option value="2010">2010</option>
                <option value="2011">2011</option>
                <option value="2012">2012</option>
                <option value="2013">2013</option>
                <option value="2014">2014</option>
                <option value="2015">2015</option>
                <option value="<?php echo $_SESSION['year'] ?>" selected="selected"><?php echo $_SESSION['year'] ?></option>
                
              </select>
              <br />
              <br />
              <label class="std">Chassis number:</label>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="chassis_no_text" id="chassis_no_text" class="wizard0" onkeyup="ToUpper(this)" value="<?php echo $_SESSION['chassis_no'] ?>" />
              </p>
            <p class="wizard">
              <label class="std">Fuel:</label>&nbsp;&nbsp;&nbsp;
              <select name="fuelSelect" id="fuelSelect" class="wizard2">
                <option value="Petrol">Petrol</option>
                <option value="Diesel">Diesel</option>
                <option value="<?php echo $_SESSION['fuel'] ?>" selected="selected"><?php echo $_SESSION['fuel'] ?></option>
              </select>
              <label class="star">*</label>
            </p></td>
            
          </tr>
          <tr>
            <td>
              <table width="590" height="50" align="center" id="tableButtonBar">
                <tr>
                  <td width="117"><input type="submit" name="prev_button" id="prev_button" class="imagebutton" value="Prev" onclick="needToConfirm = false; " /></td>
                  <td width="115"><span class="wizard">
                    <input name="p" type="hidden" id="p" value="2" />
                  <input name="s" type="hidden" id="s" value="2" />
                  </span></td>
                  <td width="99">&nbsp;</td>
                  <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onclick="needToConfirm = false; confirmRefresh();" value="Cancel" /></td>
                  <td width="110" align="left"><input type="submit" name="next_button" class="imagebutton" value="Next" onclick="validate(); needToConfirm = false; " /></td>
                </tr>
              </table></td>
          </tr>
        </table>
  </table>
  
</form>
<script language="javascript" type="text/javascript" >

var frmvalidator  = new Validator("feedbackform");
frmvalidator.EnableMsgsTogether();
  
function validate(){
  frmvalidator.addValidation("vehicleMake_select","req","Please select make of the vehicle.");
  frmvalidator.addValidation("vehicleModel_select","req","Please select model of the vehicle.");
  frmvalidator.addValidation("fuelSelect","req","Please select type of fuel used.");
}
  
  
  </script>


  





 <?php
	}
	?>