<head>
<?php
$m = $_GET['m'];
if ($m==1) {
	$_SESSION['page_view']='6';
}
if ($m==2) {
	$_SESSION['page_view']='5';
}

$table_name = $_SESSION['db_prefix']."_captured_jobs";
$press_points_query = "SELECT  press_points FROM $table_name WHERE  job_no = '".$_SESSION['job_no']."' ";
$press_points_result = mySQL_query($press_points_query);
$press_points = mysql_result($press_points_result, 0, "press_points");
?>

<?php
$table_name = $_SESSION['db_prefix']."_list_truss_type_1"; 
$type_1_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
$arrId1 = array ();
$arrName1 = array ();
$type_1_result = execsql($type_1_query);
$type_1_num = mysql_num_rows($type_1_result);
$a = 0;
while ($a < $type_1_num) {
		$arrId1[$a] = mysql_result($type_1_result, $a, "item_name");
		$arrName1[$a] = mysql_result($type_1_result, $a, "item_name");
		$a++;
	}
	
$table_name = $_SESSION['db_prefix']."_list_truss_type_2"; 
$type_2_query = "SELECT item_name FROM $table_name";
$arrId2 = array ();
$arrName2 = array ();
$type_2_result = execsql($type_2_query);
$type_2_num = mysql_num_rows($type_2_result);
$a = 0;
while ($a < $type_2_num) {
		$arrId2[$a] = mysql_result($type_2_result, $a, "item_name");
		$arrName2[$a] = mysql_result($type_2_result, $a, "item_name");
		$a++;
	}
	
$table_name = $_SESSION['db_prefix']."_list_truss_type_3"; 
$type_3_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
$arrId3 = array ();
$arrName3 = array ();
$type_3_result = execsql($type_3_query);
$type_3_num = mysql_num_rows($type_3_result);
$a = 0;
while ($a < $type_3_num) {
		$arrId3[$a] = mysql_result($type_3_result, $a, "item_name");
		$arrName3[$a] = mysql_result($type_3_result, $a, "item_name");
		$a++;
	}

if ($_SESSION['page_view']=='5') {	
$table_name = $_SESSION['db_prefix']."_trusses_temp";
$line_query = "SELECT * FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND select_it = 'add' AND user = '".$_SESSION['username']."' ";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);
}

if ($_SESSION['page_view']=='6') {	
$table_name = $_SESSION['db_prefix']."_trusses_temp";
$line_query = "SELECT * FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND user = '".$_SESSION['username']."' ";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);
}
	

?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="../css/main.css" />


<!--jscript-->
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script>
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>

<script type="text/javascript">
function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}
</script>


<script language="javascript">
        function addRow(tableID) {
 
            var table = document.getElementById(tableID);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
			var line_no = rowCount-1;
 
            var cell1 = row.insertCell(0);
            var element1 = document.createElement("input");
            element1.type = "checkbox";
            element1.name="line_checkbox"+line_no;
			element1.id="line_checkbox"+line_no;
			/*element1.checked="checked";*/	
			
            cell1.appendChild(element1);
 
            var cell2 = row.insertCell(1);
            var element5 = document.createElement("select");
            element5.name = "type_1_add_select"+line_no;
			element5.id = "type_1_add_select"+line_no;
			element5.className = "select_no_arrow";
			element5.style = "width:60px; margin-right:3px;";
			/*element5.selected = '1';*/
			
			element5.onchange = function(){document.getElementById("line_checkbox"+line_no).checked = "checked";}
			cell2.appendChild(element5);
			var option0 = document.createElement("option");
   				 	option0.text = "--";
    				option0.value = "--";
				element5.add(option0);
			
			var option1 = document.createElement("option");
   				 	option1.text = "";
    				option1.value = "";
					option1.selected = "selected";
				element5.add(option1);
			
			
			
			<?php
    			for ($j = 0; $j < count($arrId1); $j++) { ?>
				
				var option<?php echo $j?> = document.createElement("option");
   				 	option<?php echo $j?>.text = "<?php echo $arrName1[$j]?>";
    				option<?php echo $j?>.value = "<?php echo $arrId1[$j]?>";
				element5.add(option<?php echo $j?>);
			<?php	
			}
     		?>	
			
            var element7 = document.createElement("select");
            element7.name = "type_2_add_select"+line_no;
			element7.id = "type_2_add_select"+line_no;
			element7.className = "select_no_arrow";
			element7.style = "margin-right:3px;";
			cell2.appendChild(element7);
			var option0 = document.createElement("option");
   				 	option0.text = "--";
    				option0.value = "--";
				element7.add(option0);
				
			var option1 = document.createElement("option");
   				 	option1.text = "";
    				option1.value = "";
					option1.selected = "selected";
				element7.add(option1);	
			
			<?php
    			for ($j = 0; $j < count($arrId2); $j++) { ?>
				
				var option<?php echo $j?> = document.createElement("option");
   				 	option<?php echo $j?>.text = "<?php echo $arrName2[$j]?>";
    				option<?php echo $j?>.value = "<?php echo $arrId2[$j]?>";
				element7.add(option<?php echo $j?>);
			<?php	
			}
     		?>
			
			var element8 = document.createElement("select");
            element8.name = "type_3_add_select"+line_no;
			element8.id = "type_3_add_select"+line_no;
			element8.className = "select_no_arrow";
			element8.style = "margin-right:3px;";
			cell2.appendChild(element8);
			var option1 = document.createElement("option");
   				 	option1.text = "--";
    				option1.value = "--";
				element8.add(option1);
				
			var option1 = document.createElement("option");
   				 	option1.text = "";
    				option1.value = "";
					option1.selected = "selected";
				element8.add(option1);
			
			<?php
    			for ($j = 0; $j < count($arrId3); $j++) { ?>
				
				var option<?php echo $j?> = document.createElement("option");
   				 	option<?php echo $j?>.text = "<?php echo $arrName3[$j]?>";
    				option<?php echo $j?>.value = "<?php echo $arrId3[$j]?>";
				element8.add(option<?php echo $j?>);
			<?php	
			}
     		?>		
 
            var cell3 = row.insertCell(2);
            var element2 = document.createElement("input");
            element2.type = "text";
            element2.name = "span_add_text"+line_no;
			element2.id = "span_add_text"+line_no;
			element2.className = "text100";
			element2.value = "";
			element2.onkeypress = function isNumberKey(evt)
       								{
          							var charCode = (evt.which) ? evt.which : event.keyCode
          							if (charCode > 31            /* charCode != 46 && was removed to take out point */
            						&& (charCode < 48 || charCode > 57))
             						return false;
 
          							return true;
       								}
									;
       		/*element2.style = "text-align:right";*/	
			cell3.appendChild(element2);
			
			var cell4 = row.insertCell(3);
            var element3 = document.createElement("input");
            element3.type = "text";
            element3.name = "press_points_add_text"+line_no;
			element3.id = "press_points_add_text"+line_no;
			element3.className = "text100";
			element3.onkeyup = function() {ToUpper(this)};
            element3.onkeypress = function isNumberKey(evt)
       								{
          							var charCode = (evt.which) ? evt.which : event.keyCode
          							if (charCode > 31            /* charCode != 46 && was removed to take out point */
            						&& (charCode < 48 || charCode > 57))
             						return false;
 
          							return true;
       								}
									;
       		/*element3.style = "text-align:right";*/	
			cell4.appendChild(element3);
			
			
			var cell5 = row.insertCell(4);
			var element6 = document.createElement("input");
            element6.type = "text";
            element6.name = "quantity_add_text"+line_no;
			element6.id = "quantity_add_text"+line_no;
			element6.className = "text60";
			element6.onkeypress = function isNumberKey(evt)
       								{
          							var charCode = (evt.which) ? evt.which : event.keyCode
          							if (charCode > 31            /* charCode != 46 && was removed to take out point */
            						&& (charCode < 48 || charCode > 57))
             						return false;
 
          							return true;
       								}
									;
       		element6.style = "text-align:right";		

            var element4 = document.createElement("input");
            element4.type = "hidden";
            element4.name = "line_num";
			element4.value = rowCount;
            						
			cell5.appendChild(element6);
            cell5.appendChild(element4);
			
			
			var element9 = document.createElement("script");
			element9.setAttribute('type', 'text/javascript');
			element9.innerHTML="var frmvalidator  = new Validator('form2');frmvalidator.EnableMsgsTogether();for (i = 0; i < 10; i++) {frmvalidator.addValidation('type_1_add_select'+i,'req','Please complete truss type on line'+(i+1)+'.');frmvalidator.addValidation('type_2_add_select'+i,'req','Please complete truss type on line '+(i+1)+'.');frmvalidator.addValidation('span_add_text'+i,'req','Please enter span on line '+(i+1)+'.');frmvalidator.addValidation('press_points_add_text'+i,'req','Please enter FT-s no on line '+(i+1)+'.');frmvalidator.addValidation('quantity_add_text'+i,'req','Please enter quantity on line '+(i+1)+'.');}"; 
			document.getElementsByTagName('head').item(0).appendChild(element9);
			


element1.onmouseup = function() {
				 if (document.getElementById('line_checkbox'+line_no).checked) {
					     document.getElementById('type_1_add_select'+line_no).options.selectedIndex = 1;
						 document.getElementById('type_2_add_select'+line_no).options.selectedIndex = 1;
						 document.getElementById('type_3_add_select'+line_no).options.selectedIndex = 1;
                         document.getElementById('type_1_add_select'+line_no).style.background = '#E1E1E1';
						 document.getElementById('type_2_add_select'+line_no).style.background = '#E1E1E1';
						 document.getElementById('type_3_add_select'+line_no).style.background = '#E1E1E1';
						 document.getElementById('span_add_text'+line_no).style.background = '#E1E1E1';
						 document.getElementById('press_points_add_text'+line_no).style.background = '#E1E1E1';
						 document.getElementById('quantity_add_text'+line_no).style.background = '#E1E1E1';
						 
						 document.getElementById('type_1_add_select'+line_no).options.selectedIndex = 0;
						 document.getElementById('type_2_add_select'+line_no).options.selectedIndex = 0;
						 document.getElementById('type_3_add_select'+line_no).options.selectedIndex = 0;
						 document.getElementById('span_add_text'+line_no).value = '-----';
						 document.getElementById('press_points_add_text'+line_no).value = '-----';
						 document.getElementById('quantity_add_text'+line_no).value = '-----';
						 document.getElementById('type_1_add_select'+line_no).disabled = true;
						 document.getElementById('type_2_add_select'+line_no).disabled = true;
						 document.getElementById('type_3_add_select'+line_no).disabled = true;
						 document.getElementById('span_add_text'+line_no).disabled = true;
						 document.getElementById('press_points_add_text'+line_no).disabled = true;
						 document.getElementById('quantity_add_text'+line_no).disabled = true;
						 
                } else {
                        document.getElementById('type_1_add_select'+line_no).style.background = '#FFF';
						document.getElementById('type_2_add_select'+line_no).style.background = '#FFF';
						document.getElementById('type_3_add_select'+line_no).style.background = '#FFF';
						 document.getElementById('span_add_text'+line_no).style.background = '#FFF';
						 document.getElementById('press_points_add_text'+line_no).style.background = '#FFF';
						 document.getElementById('quantity_add_text'+line_no).style.background = '#FFF';
						 
						 document.getElementById('type_1_add_select'+line_no).options.selectedIndex = 1;
						 document.getElementById('type_2_add_select'+line_no).options.selectedIndex = 1;
						 document.getElementById('type_3_add_select'+line_no).options.selectedIndex = 1;
						 document.getElementById('span_add_text'+line_no).value = '';
						 document.getElementById('press_points_add_text'+line_no).value = '';
						 document.getElementById('quantity_add_text'+line_no).value = '';
						 document.getElementById('type_1_add_select'+line_no).disabled = false;
						 document.getElementById('type_2_add_select'+line_no).disabled = false;
						 document.getElementById('type_3_add_select'+line_no).disabled = false;
						 document.getElementById('span_add_text'+line_no).disabled = false;
						 document.getElementById('press_points_add_text'+line_no).disabled = false;
						 document.getElementById('quantity_add_text'+line_no).disabled = false;
                }
				}			
			
}

</script>


<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 1, "asc" ]],
					"aoColumns": [
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": true}
								 ]
				} );
			} );
		</script>

</head>

<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide', 'upload','','hide', <?php if ($_SESSION['page_stage']=='0') { ?>'select','','show'<?php } else { ?>'select','','hide'<?php } ?> , <?php if ($_SESSION['page_stage']=='3') { ?>'import','','show'<?php } else { ?>'import','','hide'<?php } ?>); <?php if ($_SESSION['error2']==2) {?> alertMessage(2, 'iets', 'Trusses in the added list were tempoary saved. If the wizard is not completed, this list will be deleted.'); <?php } ?> <?php if ($_SESSION['error2']==1) {?> alertMessage(2, 'iets', 'Trusses listed below are already in the list and were not added.<br><?php echo $_SESSION['alert_message']?><br>Trusses in the added list were tempoary saved. If the wizard is not completed, this list will be deleted.'); <?php } ?> " onFocus="MM_showHideLayers('wait','','hide');" > 
<?php
$_SESSION['error2']=0;
$_SESSION['alert_message']='';

?>



<?php
If ($_SESSION['page_view']==0) {
?>

<div class="wizard_page_middle_frame" onMouseMove="document.getElementById('upload_file_text').focus();" >
<form enctype="multipart/form-data" action="../include/uploader.php" method="POST" name="form1" onMouseMove="document.getElementById('upload_file_text').focus();">
    
    <div class="wizard_frame" >
    <div class="lay_out_frame_small" style="height:30px; width:70px;"><font color="#FF9933"; size=5;><b>1</b></font>&nbsp;&nbsp;&nbsp;Select</div>
    <div class="lay_out_frame_small" style="height:30px; width:500px;" id='select' onfocus="MM_showHideLayers('select','','hide')">
        <input type="hidden" name="MAX_FILE_SIZE" value="100000" /><input type="hidden" name="m" id="m" value="0">
        <label class="label_std">Select a file to upload:</label>
  &nbsp;&nbsp;&nbsp;
  <input name="uploadedfile" id="uploadedfile" type="file" class="imagebutton"  onChange="MM_showHideLayers('upload','','show');MM_showHideLayers('select','','hide'); "  onBlur="document.getElementById('upload_file_text').value = document.getElementById('uploadedfile').value; "  />
  OR 
  <input name="manual_button" type="button" class="imagebutton" id="manual_button" onClick="needToConfirm = false; MM_goToURL('parent','../production/trussesJobWizbase.php?p=2&s=&m=1');return document.MM_returnValue" value="Manual Entry" style="height:26px;">
    </div> 
  <div class="lay_out_frame_small" style="height:30px; width:70px;" ><font color="#FF9933"; size=5;><b>2</b></font>&nbsp;&nbsp;&nbsp;Upload</div>
  <div class="lay_out_frame_small" style="height:30px; width:475px;" id='upload' on >
  <label class="label_std">Selected file:</label>&nbsp;
  <label for="upload_file_text"></label>
  <input type="text" name="upload_file_text" id="upload_file_text"  style="border:hidden; background-color:inherit; font-weight:bold; color:#F96;">
  &nbsp;&nbsp;<input name="upload_button" type="submit" value="Upload file" onClick="needToConfirm = false; MM_showHideLayers('import','','show');MM_showHideLayers('upload','','hide')" class="imagebutton" ><input type="hidden" name="m" id="m" value="0">
     <input name="import_button" type="button" onClick="needToConfirm = false; <?php $_SESSION['page_stage']='0';?> MM_goToURL('parent','trussesJobWizbase.php?p=2&s=&m=0');return document.MM_returnValue" value="Cancel" class="imagebutton">
     <input type="hidden" name="alert_message" id="alert_message" value="">
     
    
<input type="hidden" name="error" id="error" value="0">
  </div>
       
  <div class="lay_out_frame_small" style="height:30px; width:70px;"><font color="#FF9933"; size=5;><b>3</b></font>&nbsp;&nbsp;&nbsp;Import</div>
    <div class="lay_out_frame_small" style="height:100px; width:475px;" id='import'>
    
    <?php if ($_SESSION['error'] == '0') { ?>
    <?php if ($_SESSION['job_no']==$_SESSION['file_job_no']) { ?>
    <div class="lay_out_frame_small" style="width:20px; height:30px; border:hidden;"><img src="../images/success_32.png" width="24" height="24"></div>
    <div class="lay_out_frame_small" style="width:360px; border:hidden;"><label class="label_std">The file "<?php echo $_SESSION['file_name'] ?>" for job no <?php echo 'J'.$_SESSION['file_job_no']?> was uploaded successfully. Click the Import button to import the contents of this file.</label></div>
    <?php } else { ?>
    <div class="lay_out_frame_small" style="width:20px; height:30px; border:hidden;"><img src="../images/warning.png" width="24" height="24"></div>
    <div class="lay_out_frame_small" style="width:360px; border:hidden;"><label class="label_std">The file "<?php echo $_SESSION['file_name'] ?>" was uploaded successfully but is not for <?php echo 'J'.$_SESSION['job_no']?> in this wizard. If you want to use this file to import, click Import. To select a new file, click Start again.</label></div>
    <?php } ?>
    <br>
<br><div align="center">
    <input name="import_button" type="button" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); MM_goToURL('parent','truss_upload.php');return document.MM_returnValue; " value="Import truss list" class="imagebutton">
    <input name="import_button" type="button" onClick="needToConfirm = false; <?php $_SESSION['page_stage']='0';?> MM_goToURL('parent','trussesJobWizbase.php?p=2&s=&m=0');return document.MM_returnValue" value="Cancel" class="imagebutton"></div>
    <?php } ?>
    <?php if ($_SESSION['error'] == '2') { ?>
    <div class="lay_out_frame_small" style="width:20px; height:30px; border:hidden;"><img src="../images/warning.png" width="24" height="24"></div>
     <div class="lay_out_frame_small" style="width:360px; border:hidden;"><label class="label_std">The file "<?php echo $_SESSION['file_name'] ?>" was already uploaded. If you want to use this file to import, click the Import button, if you want to upload another file, click Try again..</label></div>
    <br>
<br>
   <div align="center"> <input name="import_button" type="button" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); MM_goToURL('parent','truss_upload.php'); return document.MM_returnValue; " value="Import truss list" class="imagebutton">
    <input name="import_button" type="button" onClick="needToConfirm = false; <?php $_SESSION['page_stage']='0';?> MM_goToURL('parent','trussesJobWizbase.php?p=2&s=&m=0');return document.MM_returnValue" value="Cancel" class="imagebutton"></div>
    <?php } ?>
    <?php if ($_SESSION['error'] == '3') { ?>
    <div class="lay_out_frame_small" style="width:20px; height:30px; border:hidden;"><img src="../images/error_32.png" width="24" height="24"></div>
     <div class="lay_out_frame_small" style="width:360px; border:hidden;"><label class="label_std">The file "<?php echo $_SESSION['file_name'] ?>" is not a valid file, only ".csv" can be used. If you want to upload another file, click Start again.</label></div>
    <br>
<br>
   <div align="center"><input name="import_button" type="button" onClick="needToConfirm = false; <?php $_SESSION['page_stage']='0';?> MM_goToURL('parent','trussesJobWizbase.php?p=2&s=');return document.MM_returnValue" value="Start again" class="imagebutton"></div>
    <?php } ?>
    </div>
 </div>   
</form> 

<?php } ?>
<div class="spacer_frame" style="height:10px;"></div>    

<?php if ( ($_SESSION['page_view']==5) OR($_SESSION['page_view']==6) ) { ?>

<form id="form2" name="form2" method="post" action="trussesJobWizbase.php?p=3&s=2">


<?php if ($_SESSION['page_view']==5) { ?>
<div class="wizard_page_middle_frame">

<div class="wizard_frame"> Estimated FT: <?php echo $press_points; ?> </div>
<br>
<div class="wizard_frame"> 

    <?php
	$table_name = $_SESSION['db_prefix']."_trusses_temp";
	$truss_query = "SELECT truss_id, truss_type, qty, span, press_points, select_it  FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND  user =  '".$_SESSION['username']."' AND select_it<>'add' ";
	//echo '<br>'.$truss_query;
	$truss_result = mySQL_query($truss_query);
	$truss_num = mysql_num_rows($truss_result);
	?>
    
    <table width="600" id="scroll_table" class="data_display">
 <thead> 
 <tr>
   <th width="31">&nbsp;</th>
    <th width="153">Truss type</th>
    <th width="75">Span</th>
    <th width="187">FT</th>
    <th width="130">Quantity</th>
  </tr>
  </thead>
  <?php
 $i=0;
 while ($i<$truss_num) {
	 $truss_id = mysql_result($truss_result, $i, "truss_id");
	 $truss_type = mysql_result($truss_result, $i, "truss_type");
	 $qty = mysql_result($truss_result, $i, "qty");
	 $span = mysql_result($truss_result, $i, "span");
	 $press_points = mysql_result($truss_result, $i, "press_points");
	 $select_it = mysql_result($truss_result, $i, "select_it");
?>
  <tr>
    <td>
      <input type="checkbox" name="truss_checkbox_<?php echo $i ?>" id="truss_checkbox_<?php echo $i ?>" <?php if ($select_it=='yes') { echo 'checked=checked'; } ?> >
      <input type="hidden" name="truss_id_<?php echo $i ?>" id="truss_id_<?php echo $i ?>" value="<?php echo $truss_id?>" >
      
    </td>
    <td><?php echo $truss_type?></td>
    <td><input name="span_text_<?php echo $i ?>" type="text" class="text50" id="span_text_<?php echo $i ?>" value="<?php echo $span?>"></td>
    <td><input name="press_points_text_<?php echo $i ?>" type="text" class="text50" id="press_points_text_<?php echo $i ?>" value="<?php echo $press_points?>"></td>
    <td><input name="truss_qty_text_<?php echo $i ?>" type="text" class="text50" id="truss_qty_text_<?php echo $i ?>" value="<?php echo $qty?>"></td>
  </tr>
  <?php
  $i++;
  $_SESSION['line_no_2']=$i;
 }
 ?>
</table>
    <br>
    
</div> 
 


<div class="wizard_frame">

<p>Add trusses: </p>
<table id="dataTable" width="628" border="1" style="border-collapse:collapse;">
  <?php
  
  if ($line_num==0) {
	       $a0='';
		   $a1='';
		   $a2='';
		   $a3='';
		   $a4='';
		   $a5='';
	   }
	   else {
		    $a0 = mysql_result($line_result, 0, "type_1");
			$a1 = mysql_result($line_result, 0, "type_2");
			$a2 = mysql_result($line_result, 0, "type_3");
			$a3 = mysql_result($line_result, 0, "span");
			$a4 = mysql_result($line_result, 0, "press_points");
			$a5 = mysql_result($line_result, 0, "qty");
	   }
		?>
  <thead>
    <tr>
      <td>&nbsp;</td>
      <td>Truss type</TD>
      <td>Span</td>
      <td>FT</td>
      <TD>No</td>
    </tr>
  </thead>
  <tr>
  <script>
			 function check_it() {
				 if (document.getElementById('line_checkbox0').checked) {
                         document.getElementById('type_1_add_select0').style.background = '#E1E1E1';
						 document.getElementById('type_2_add_select0').style.background = '#E1E1E1';
						 document.getElementById('type_3_add_select0').style.background = '#E1E1E1';
						 document.getElementById('span_add_text0').style.background = '#E1E1E1';
						 document.getElementById('press_points_add_text0').style.background = '#E1E1E1';
						 document.getElementById('quantity_add_text0').style.background = '#E1E1E1';
						 
						 document.getElementById('type_1_add_select0').options.selectedIndex = 0;
						 document.getElementById('type_2_add_select0').options.selectedIndex = 0;
						 document.getElementById('type_3_add_select0').options.selectedIndex = 0;
						 document.getElementById('span_add_text0').value = '-----';
						 document.getElementById('press_points_add_text0').value = '-----';
						 document.getElementById('quantity_add_text0').value = '-----';
						 document.getElementById('type_1_add_select0').disabled = true;
						 document.getElementById('type_2_add_select0').disabled = true;
						 document.getElementById('type_3_add_select0').disabled = true;
						 document.getElementById('span_add_text0').disabled = true;
						 document.getElementById('press_points_add_text0').disabled = true;
						 document.getElementById('quantity_add_text0').disabled = true;
						 
                } else {
                        document.getElementById('type_1_add_select0').style.background = '#FFF';
						document.getElementById('type_2_add_select0').style.background = '#FFF';
						document.getElementById('type_3_add_select0').style.background = '#FFF';
						 document.getElementById('span_add_text0').style.background = '#FFF';
						 document.getElementById('press_points_add_text0').style.background = '#FFF';
						 document.getElementById('quantity_add_text0').style.background = '#FFF';
						 
						 document.getElementById('type_1_add_select0').options.selectedIndex = 1;
						 document.getElementById('type_2_add_select0').options.selectedIndex = 1;
						 document.getElementById('type_3_add_select0').options.selectedIndex = 1;
						 document.getElementById('span_add_text0').value = '';
						 document.getElementById('press_points_add_text0').value = '';
						 document.getElementById('quantity_add_text0').value = '';
						 document.getElementById('type_1_add_select0').disabled = false;
						 document.getElementById('type_2_add_select0').disabled = false;
						 document.getElementById('type_3_add_select0').disabled = false;
						 document.getElementById('span_add_text0').disabled = false;
						 document.getElementById('press_points_add_text0').disabled = false;
						 document.getElementById('quantity_add_text0').disabled = false;
                }
				}
				
				function clear_it() {
					     document.getElementById('type_2_add_select0').options.selectedIndex = 1;
						 document.getElementById('type_3_add_select0').options.selectedIndex = 1;
						 document.getElementById('span_add_text0').value = '';
						 document.getElementById('press_points_add_text0').value = '';
						 document.getElementById('quantity_add_text0').value = '';
				}
		     </script>
       <?php 
	   if ($a0=='') {$a0 = '.';}
	   if ($a1=='') {$a1 = '.';}
	   if ($a3=='') {$a3 = '.';}
	   if ($a4=='') {$a4 = '.';}
	   if ($a5=='') {$a5 = '.';}	
	   ?>      
    <td width="25"><input type="checkbox" name="line_checkbox0" id="line_checkbox0"  onMouseUp="check_it()" <?php if (($a0!='') AND ($a0!='.')) { ?> checked="checked" <?php } ?>/></td>
    <td width="262"><label id="closeOnSelect">
      <!--<input type="checkbox" /> Close on selection-->
    </label>
      
      <select name="type_1_add_select0" id="type_1_add_select0" class="select_no_arrow" style="width:60px;"  onChange="document.getElementById('line_checkbox0').checked = 'checked'; clear_it();">
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a0?>" selected="selected"><?php echo $a0?></option>
        <?php
    	for ($i = 0; $i < count($arrId1); $i++) {
		echo "<option value=" . "\"" . $arrId1[$i] . "\"" . ">" . $arrName1[$i] . "</option>";
		
		}
     ?>
      </select>
      <select name="type_2_add_select0" id="type_2_add_select0" class="select_no_arrow" >
        <option value="-">-</option>
        <option value=" "> </option>
        <option value="<?php echo $a1?>" selected="selected"><?php echo $a1?></option>
        <?php
    	for ($i = 0; $i < count($arrId2); $i++) {
		echo "<option value=" . "\"" . $arrId2[$i] . "\"" . ">" . $arrName2[$i] . "</option>";
		}
     ?>
      </select>
      <select name="type_3_add_select0" id="type_3_add_select0" class="select_no_arrow" >
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a2?>" selected="selected"><?php echo $a2?></option>
        <?php
    	for ($i = 0; $i < count($arrId3); $i++) {
		echo "<option value=" . "\"" . $arrId3[$i] . "\"" . ">" . $arrName3[$i] . "</option>";
		
		}
     ?>
      </select></td>
      
    <td width="125"><input name="span_add_text0" type="text" class="text100" id="span_add_text0"  value="<?php echo $a3 ?>"/></td>
    <td width="107"><input  name="press_points_add_text0" type="text" class="text100" id="press_points_add_text0" value="<?php echo $a4 ?>" onKeyUp="ToUpper(this)"/></td>
    <TD width="75"><input  name="quantity_add_text0" type="text" class="text60" id="quantity_add_text0" value="<?php echo $a5?>" onKeyPress="return numbersonly(this, event)" style="text-align:right"/>
      <input type="hidden" name="line_num" id="line_num" value="1" >
      <!--<input name="textfield0" type="text" id="textfield0" size="5" value="1"></td>-->
    </tr>
  <?php
		$i=1;
				
		while ($i<$line_num) {
		$a0 = mysql_result($line_result, $i, "type_1");
		$a1 = mysql_result($line_result, $i, "type_2");
		$a2 = mysql_result($line_result, $i, "type_3");
		$a3 = mysql_result($line_result, $i, "span");
		$a4 = mysql_result($line_result, $i, "press_points");
		$a5 = mysql_result($line_result, $i, "qty");
		
			
		?>
  <tr>
    <td width="25"><input type="checkbox" name="line_checkbox<?php echo $i ?>" id="line_checkbox<?php echo $i ?>" checked="checked" onMouseUp="{
				 if (document.getElementById('line_checkbox<?php echo $i ?>').checked) {
                         document.getElementById('type_1_add_select<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('type_2_add_select<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('type_3_add_select<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('span_add_text<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('press_points_add_text<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('quantity_add_text<?php echo $i ?>').style.background = '#E1E1E1';
						 
						 document.getElementById('type_1_add_select<?php echo $i ?>').options.selectedIndex = 0;
						 document.getElementById('type_2_add_select<?php echo $i ?>').options.selectedIndex = 0;
						 document.getElementById('type_3_add_select<?php echo $i ?>').options.selectedIndex = 0;
						 document.getElementById('span_add_text<?php echo $i ?>').value = '-----';
						 document.getElementById('press_points_add_text<?php echo $i ?>').value = '-----';
						 document.getElementById('quantity_add_text<?php echo $i ?>').value = '-----';
						 document.getElementById('type_1_add_select<?php echo $i ?>').disabled = true;
						 document.getElementById('type_2_add_select<?php echo $i ?>').disabled = true;
						 document.getElementById('type_3_add_select<?php echo $i ?>').disabled = true;
						 document.getElementById('span_add_text<?php echo $i ?>').disabled = true;
						 document.getElementById('press_points_add_text<?php echo $i ?>').disabled = true;
						 document.getElementById('quantity_add_text<?php echo $i ?>').disabled = true;
						 
                } else {
                        document.getElementById('type_1_add_select<?php echo $i ?>').style.background = '#FFF';
						document.getElementById('type_2_add_select<?php echo $i ?>').style.background = '#FFF';
						document.getElementById('type_3_add_select<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('span_add_text<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('press_points_add_text<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('quantity_add_text<?php echo $i ?>').style.background = '#FFF';
						 
						 document.getElementById('type_1_add_select<?php echo $i ?>').options.selectedIndex = 1;
						 document.getElementById('type_2_add_select<?php echo $i ?>').options.selectedIndex = 1;
						 document.getElementById('type_3_add_select<?php echo $i ?>').options.selectedIndex = 1;
						 document.getElementById('span_add_text<?php echo $i ?>').value = '';
						 document.getElementById('press_points_add_text<?php echo $i ?>').value = '';
						 document.getElementById('quantity_add_text<?php echo $i ?>').value = '';
						 document.getElementById('type_1_add_select<?php echo $i ?>').disabled = false;
						 document.getElementById('type_2_add_select<?php echo $i ?>').disabled = false;
						 document.getElementById('type_3_add_select<?php echo $i ?>').disabled = false;
						 document.getElementById('span_add_text<?php echo $i ?>').disabled = false;
						 document.getElementById('press_points_add_text<?php echo $i ?>').disabled = false;
						 document.getElementById('quantity_add_text<?php echo $i ?>').disabled = false;
                }
				}
                "/></td>
    <td width="262"><label id="closeOnSelect">
      <!--<input type="checkbox" /> Close on selection-->
    </label>
    
    <select name="type_1_add_select<?php echo $i ?>" id="type_1_add_select<?php echo $i ?>" class="select_no_arrow" style="width:60px;" autofocus>
      <option value="-">-</option>
      <option> </option>
      <option value="<?php echo $a0?>" selected><?php echo $a0?></option>
        <?php
    	for ($j = 0; $j < count($arrId1); $j++) {
		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
		
		}
     ?>
      </select>
      <select name="type_2_add_select<?php echo $i ?>" id="type_2_add_select<?php echo $i ?>" class="select_no_arrow" >
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a1?>" selected><?php echo $a1?></option>
        <?php
    	for ($j = 0; $j < count($arrId2); $j++) {
		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
		
		}
     ?>
      </select>
      <select name="type_3_add_select<?php echo $i ?>" id="type_3_add_select<?php echo $i ?>" class="select_no_arrow" >
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a2?>" selected="selected"><?php echo $a2?></option>
        <?php
    	for ($j = 0; $j < count($arrId3); $j++) {
		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
		
		}
     ?>
      </select></td>
    <td width="125"><input name="span_add_text<?php echo $i ?>" type="text" class="text100" id="span_add_text<?php echo $i ?>" value="<?php echo $a3 ?>"/></td>
    <td width="107"><input  name="press_points_add_text<?php echo $i ?>" type="text" class="text100" id="press_points_add_text<?php echo $i ?>" value="<?php echo $a4 ?>"/></td>
    <td width="75"><input  name="quantity_add_text<?php echo $i ?>" type="text" class="text60" id="quantity_add_text<?php echo $i ?>" value="<?php echo $a5 ?>" onKeyPress="return isNumberKey(event)" onChange=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right"/>
      <input type="hidden" name="line_num" id="line_num" value="<?php echo $line_num?>"></td>
  </tr>
  <?php
		$i++;
		}
		?>
</table>
<input type="button" class="imagebutton" onClick="addRow('dataTable')" value="Add line" />
<input name="temp_save_button" type="submit" class="imagebutton" id="temp_save_button" value="Temp Save" onClick="needToConfirm = false; form2.action='trussesJobWiz2_save.php';" style="visibility:hidden;">
<div align="right"><label class="label_small">Not to save a line uncheck the line box.</label></div>
</div>
   
  <br>
<br>

 <?php 
	}?>

<?php if ($_SESSION['page_view']==6) { ?>
<div class="wizard_page_middle_frame">
  
  <div class="wizard_frame"> Estimated FT: <?php echo $press_points; ?> </div>
<br>

<div class="wizard_frame">

<p>Add trusses: </p>
<table id="dataTable" width="628" border="1" style="border-collapse:collapse;">
  <?php
  
  if ($line_num==0) {
	       $a0='';
		   $a1='';
		   $a2='';
		   $a3='';
		   $a4='';
		   $a5='';
	   }
	   else {
		    $a0 = mysql_result($line_result, 0, "type_1");
			$a1 = mysql_result($line_result, 0, "type_2");
			$a2 = mysql_result($line_result, 0, "type_3");
			$a3 = mysql_result($line_result, 0, "span");
			$a4 = mysql_result($line_result, 0, "press_points");
			$a5 = mysql_result($line_result, 0, "qty");
	   }
		?>
  <thead>
    <tr>
      <td>&nbsp;</td>
      <td>Truss type</TD>
      <td>Span</td>
      <td>FT</td>
      <TD>No</td>
    </tr>
  </thead>
  <tr>
  <script>
			 function check_it() {
				 if (document.getElementById('line_checkbox0').checked) {
                         document.getElementById('type_1_add_select0').style.background = '#E1E1E1';
						 document.getElementById('type_2_add_select0').style.background = '#E1E1E1';
						 document.getElementById('type_3_add_select0').style.background = '#E1E1E1';
						 document.getElementById('span_add_text0').style.background = '#E1E1E1';
						 document.getElementById('press_points_add_text0').style.background = '#E1E1E1';
						 document.getElementById('quantity_add_text0').style.background = '#E1E1E1';
						 
						 document.getElementById('type_1_add_select0').options.selectedIndex = 0;
						 document.getElementById('type_2_add_select0').options.selectedIndex = 0;
						 document.getElementById('type_3_add_select0').options.selectedIndex = 0;
						 document.getElementById('span_add_text0').value = '-----';
						 document.getElementById('press_points_add_text0').value = '-----';
						 document.getElementById('quantity_add_text0').value = '-----';
						 document.getElementById('type_1_add_select0').disabled = true;
						 document.getElementById('type_2_add_select0').disabled = true;
						 document.getElementById('type_3_add_select0').disabled = true;
						 document.getElementById('span_add_text0').disabled = true;
						 document.getElementById('press_points_add_text0').disabled = true;
						 document.getElementById('quantity_add_text0').disabled = true;
						 
                } else {
                        document.getElementById('type_1_add_select0').style.background = '#FFF';
						document.getElementById('type_2_add_select0').style.background = '#FFF';
						document.getElementById('type_3_add_select0').style.background = '#FFF';
						 document.getElementById('span_add_text0').style.background = '#FFF';
						 document.getElementById('press_points_add_text0').style.background = '#FFF';
						 document.getElementById('quantity_add_text0').style.background = '#FFF';
						 
						 document.getElementById('type_1_add_select0').options.selectedIndex = 1;
						 document.getElementById('type_2_add_select0').options.selectedIndex = 1;
						 document.getElementById('type_3_add_select0').options.selectedIndex = 1;
						 document.getElementById('span_add_text0').value = '';
						 document.getElementById('press_points_add_text0').value = '';
						 document.getElementById('quantity_add_text0').value = '';
						 document.getElementById('type_1_add_select0').disabled = false;
						 document.getElementById('type_2_add_select0').disabled = false;
						 document.getElementById('type_3_add_select0').disabled = false;
						 document.getElementById('span_add_text0').disabled = false;
						 document.getElementById('press_points_add_text0').disabled = false;
						 document.getElementById('quantity_add_text0').disabled = false;
                }
				}
		     </script>
    <td width="25"><input type="checkbox" name="line_checkbox0" id="line_checkbox0"  onMouseUp="check_it()" <?php if ($a0!='') { ?> checked="checked" <?php } ?>/></td>
    <td width="262"><label id="closeOnSelect">
      <!--<input type="checkbox" /> Close on selection-->
    </label>
      
      <select name="type_1_add_select0" id="type_1_add_select0" class="select_no_arrow" style="width:60px;" onChange="document.getElementById('line_checkbox0').checked = 'checked';">
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a0?>" selected="selected"><?php echo $a0?></option>
        <?php
    	for ($i = 0; $i < count($arrId1); $i++) {
		echo "<option value=" . "\"" . $arrId1[$i] . "\"" . ">" . $arrName1[$i] . "</option>";
		
		}
     ?>
      </select>
      <select name="type_2_add_select0" id="type_2_add_select0" class="select_no_arrow" >
        <option value="-">-</option>
        <option value=" "> </option>
        <option value="<?php echo $a1?>" selected="selected"><?php echo $a1?></option>
        <?php
    	for ($i = 0; $i < count($arrId2); $i++) {
		echo "<option value=" . "\"" . $arrId2[$i] . "\"" . ">" . $arrName2[$i] . "</option>";
		}
     ?>
      </select>
      <select name="type_3_add_select0" id="type_3_add_select0" class="select_no_arrow" >
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a2?>" selected="selected"><?php echo $a2?></option>
        <?php
    	for ($i = 0; $i < count($arrId3); $i++) {
		echo "<option value=" . "\"" . $arrId3[$i] . "\"" . ">" . $arrName3[$i] . "</option>";
		
		}
     ?>
      </select></td>
    <td width="125"><input name="span_add_text0" type="text" class="text100" id="span_add_text0"  value="<?php echo $a3 ?>"/></td>
    <td width="107"><input  name="press_points_add_text0" type="text" class="text100" id="press_points_add_text0" value="<?php echo $a4 ?>" onKeyUp="ToUpper(this)"/></td>
    <TD width="75"><input  name="quantity_add_text0" type="text" class="text60" id="quantity_add_text0" value="<?php echo $a5?>" onKeyPress="return numbersonly(this, event)" style="text-align:right"/>
      <input type="hidden" name="line_num" id="line_num" value="1" >
      <!--<input name="textfield0" type="text" id="textfield0" size="5" value="1"></td>-->
    </tr>
  <?php
		$i=1;
		while ($i<$line_num) {
		$a0 = mysql_result($line_result, $i, "type_1");
		$a1 = mysql_result($line_result, $i, "type_2");
		$a2 = mysql_result($line_result, $i, "type_3");
		$a3 = mysql_result($line_result, $i, "span");
		$a4 = mysql_result($line_result, $i, "press_points");
		$a5 = mysql_result($line_result, $i, "qty");
		?>
  <tr>
    <td width="25"><input type="checkbox" name="line_checkbox<?php echo $i ?>" id="line_checkbox<?php echo $i ?>" checked="checked" onMouseUp="{
				 if (document.getElementById('line_checkbox<?php echo $i ?>').checked) {
                         document.getElementById('type_1_add_select<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('type_2_add_select<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('type_3_add_select<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('span_add_text<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('press_points_add_text<?php echo $i ?>').style.background = '#E1E1E1';
						 document.getElementById('quantity_add_text<?php echo $i ?>').style.background = '#E1E1E1';
						 
						 document.getElementById('type_1_add_select<?php echo $i ?>').options.selectedIndex = 0;
						 document.getElementById('type_2_add_select<?php echo $i ?>').options.selectedIndex = 0;
						 document.getElementById('type_3_add_select<?php echo $i ?>').options.selectedIndex = 0;
						 document.getElementById('span_add_text<?php echo $i ?>').value = '-----';
						 document.getElementById('press_points_add_text<?php echo $i ?>').value = '-----';
						 document.getElementById('quantity_add_text<?php echo $i ?>').value = '-----';
						 document.getElementById('type_1_add_select<?php echo $i ?>').disabled = true;
						 document.getElementById('type_2_add_select<?php echo $i ?>').disabled = true;
						 document.getElementById('type_3_add_select<?php echo $i ?>').disabled = true;
						 document.getElementById('span_add_text<?php echo $i ?>').disabled = true;
						 document.getElementById('press_points_add_text<?php echo $i ?>').disabled = true;
						 document.getElementById('quantity_add_text<?php echo $i ?>').disabled = true;
						 
                } else {
                        document.getElementById('type_1_add_select<?php echo $i ?>').style.background = '#FFF';
						document.getElementById('type_2_add_select<?php echo $i ?>').style.background = '#FFF';
						document.getElementById('type_3_add_select<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('span_add_text<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('press_points_add_text<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('quantity_add_text<?php echo $i ?>').style.background = '#FFF';
						 
						 document.getElementById('type_1_add_select<?php echo $i ?>').options.selectedIndex = 1;
						 document.getElementById('type_2_add_select<?php echo $i ?>').options.selectedIndex = 1;
						 document.getElementById('type_3_add_select<?php echo $i ?>').options.selectedIndex = 1;
						 document.getElementById('span_add_text<?php echo $i ?>').value = '';
						 document.getElementById('press_points_add_text<?php echo $i ?>').value = '';
						 document.getElementById('quantity_add_text<?php echo $i ?>').value = '';
						 document.getElementById('type_1_add_select<?php echo $i ?>').disabled = false;
						 document.getElementById('type_2_add_select<?php echo $i ?>').disabled = false;
						 document.getElementById('type_3_add_select<?php echo $i ?>').disabled = false;
						 document.getElementById('span_add_text<?php echo $i ?>').disabled = false;
						 document.getElementById('press_points_add_text<?php echo $i ?>').disabled = false;
						 document.getElementById('quantity_add_text<?php echo $i ?>').disabled = false;
                }
				}
                "/></td>
    <td width="262"><label id="closeOnSelect">
      <!--<input type="checkbox" /> Close on selection-->
    </label>
    
    <select name="type_1_add_select<?php echo $i ?>" id="type_1_add_select<?php echo $i ?>" class="select_no_arrow" style="width:60px;" autofocus>
      <option value="-">-</option>
      <option> </option>
      <option value="<?php echo $a0?>" selected><?php echo $a0?></option>
        <?php
    	for ($j = 0; $j < count($arrId1); $j++) {
		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
		
		}
     ?>
      </select>
      <select name="type_2_add_select<?php echo $i ?>" id="type_2_add_select<?php echo $i ?>" class="select_no_arrow" >
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a1?>" selected><?php echo $a1?></option>
        <?php
    	for ($j = 0; $j < count($arrId2); $j++) {
		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
		
		}
     ?>
      </select>
      <select name="type_3_add_select<?php echo $i ?>" id="type_3_add_select<?php echo $i ?>" class="select_no_arrow" >
        <option value="-">-</option>
        <option> </option>
        <option value="<?php echo $a2?>" selected="selected"><?php echo $a2?></option>
        <?php
    	for ($j = 0; $j < count($arrId3); $j++) {
		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
		
		}
     ?>
      </select></td>
    <td width="125"><input name="span_add_text<?php echo $i ?>" type="text" class="text100" id="span_add_text<?php echo $i ?>" value="<?php echo $a3 ?>"/></td>
    <td width="107"><input  name="press_points_add_text<?php echo $i ?>" type="text" class="text100" id="press_points_add_text<?php echo $i ?>" value="<?php echo $a4 ?>"/></td>
    <td width="75"><input  name="quantity_add_text<?php echo $i ?>" type="text" class="text60" id="quantity_add_text<?php echo $i ?>" value="<?php echo $a5 ?>" onKeyPress="return isNumberKey(event)" onChange=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right"/>
      <input type="hidden" name="line_num" id="line_num" value="<?php echo $line_num?>"></td>
  </tr>
  <?php
		$i++;
		}
		?>
</table>
<input type="button" class="imagebutton" onClick="addRow('dataTable')" value="Add line" />
<input name="temp_save_button" type="submit" class="imagebutton" id="temp_save_button" value="Temp Save" onClick="needToConfirm = false; form2.action='trussesJobWiz2_save.php';" style="visibility:hidden;">
<div align="right"><label class="label_small">Not to save a line uncheck the line box.</label></div>
</div>
    
  <br>
<br>
       
      
<?php }
}?>
<div class="spacer_frame" style="height:10px;"></div>    
<div class="wizard_frame">
<div class="button_bar_frame">
     <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','trussesJobWizbase.php?s=&p=1');return document.MM_returnValue" /></td>
          <td width="115"><input name="p" type="hidden" id="p" value="2" />
          <input name="s" type="hidden" id="s" value="2" /></td>
          <td width="99">&nbsp;</td>
          <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../production/production_main.php')" value="Cancel" /></td>
          <td width="110" align="right"><input type="submit" name="next_button"  <?php  if ($_SESSION['page_view']!=0) { echo 'class="imagebutton"' ; } else { echo 'class="dis_imagebutton" disabled="disabled"' ; }?> value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show'); " /></td>
        </tr>
      </table>
 </div>

</form>
<?php if (($_SESSION['page_view']==5) OR ($_SESSION['page_view']==6) ) { ?>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form2");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("type_1_add_select0","req","Please complete truss type on line 1");
  frmvalidator.addValidation("type_2_add_select0","req","Please complete truss type on line 1");
  frmvalidator.addValidation("span_add_text0","req","Please enter span on line 1");
  frmvalidator.addValidation("press_points_add_text0","req","Please enter FT no on line 1");
  frmvalidator.addValidation("quantity_add_text0","req","Please enter quantity on line 1");
  for (i = 0; i < 10; i++) {
	frmvalidator.addValidation("type_1_add_select"+i,"req","Please complete truss type on line "+(i+1));
  	frmvalidator.addValidation("type_2_add_select"+i,"req","Please complete truss type on line "+(i+1)); 
    frmvalidator.addValidation("span_add_text"+i,"req","Please enter span on line "+(i+1));
	frmvalidator.addValidation("press_points_add_text"+i,"req","Please FT no on line "+(i+1));
  	frmvalidator.addValidation("quantity_add_text"+i,"req","Please enter quantity on line "+(i+1));
}
</script>
<?php } ?>

</div>


</body>      