<?php
	//If user is not signed in redirect
	if(!$user->signed) redirect("?page=login");	
?>

<script>
$(document).ready(function() {
	
	
	//form validation rules
	//add a custom method to check for zeros
	$.validator.addMethod("notEqual", function(value, element, param) {
  		return this.optional(element) || value != param;
	  }, "Please enter a number >0");
	// we need to have the validation plugin still validate hidden fields which we dynamically set with display:none propert
	 $.validator.setDefaults({
        ignore: []
    });

	
	var validator = $( "#bdry" ).validate({
  		rules: {
			
			inlet_vol_flow: {
     	 		required: true,
				number: true,
      		 	min: 0
    		},
			inlet_temperature: {
     	 		required: true,
				number: true,
				range: [-10, 100]
    		},
			heat_power: {
     	 		required: true,
				number: true,
				min: 0
    		},
			
			bc_val_heat_footprint: {
     	 		required: true,
				number: true,
				min: 0
    		},
			bc_type_heat_footprint: {
     	 		required: true
    		},
			outlet_drop_coeff: {
     	 		required: true,
				number: true,
				min: 0
    		},	
			inlet_drop_coeff: {
     	 		required: true,
				number: true,
				min: 0
    		},	
			inlet_pressure: {
     	 		required: true,
				number: true,
				min: 0
    		}
			
		},
		messages: {
			//we will turn some messages off (the hidden fields)
			bc_val_heat_footprint: ""
		}
	});
	
	<?php if($_SESSION['sim_data']['bdry']['hasinput']) { 
	?> $( "#bdry" ).valid(); <?php } else { $_SESSION['sim_data']['bdry']['hasinput'] = true; }?>
	
	
	
})
	
</script>

<form id="bdry" action="#" enctype="application/x-www-form-urlencoded" class="sim-form"> 
<div class="subcontent" id="bdry">
    			<h3>BOUNDARY CONDITIONS</h3>
    			<hr  class="breaklightblue" />
                <div class="leftcol">
                		<p><label class="formLabel">Flow Rate [V]</label>
                	   		<input type="text" name="inlet_vol_flow" size="5"/> (Liters/min)
                            <label for="inlet_vol_flow" class="error" generated="true"></label>
          				</p>
                        <p><label class="formLabel">Inlet Temp [T]</label>
                	   	   <input type="text" name="inlet_temperature" size="5"/> (&deg;C)
                           <label for="inlet_temperature" class="error" generated="true"></label>
          				</p>
                        <p><label class="formLabel">Power on Heat Source [Q]</label>
                	   	   <input type="text" id="heat_power" name="heat_power" size="5"/> (W)
                           <label for="heat_power" class="error" generated="true"></label>
          				</p>  
                        <p>
                        	<input type="hidden" id = "bc_val_heat_footprint" name="bc_val_heat_footprint" size="5" value="0"/>
                            <label for="bc_val_heat_footprint" class="error" generated="true"></label>
                            <input type="hidden" name="bc_type_heat_footprint" size="5" value="HF"/>
                            <label for="bc_type_heat_footprint" class="error" generated="true"></label>
                            <input type="hidden" name="outlet_drop_coeff" value="0" size="5"/>   
                            <label for="outlet_drop_coeff" class="error" generated="true"></label>
                            <input type="hidden" name="inlet_drop_coeff" value="0" size="5" /> 
                            <label for="inlet_drop_coeff" class="error" generated="true"></label>
                            <input type="hidden" name="inlet_pressure" size="5" value="10"/>
                            <label for="inlet_pressure" class="error" generated="true"></label>
                        </p> 
                        	             
                </div><!-- End .leftcol -->
                <div class = "rightcol">
                	<p><img alt="Cold Plate Geometry" src="assets/images/boundary_conditions.png" width="300"/></p>
 					<p style="float:right;">
                    	<input onclick="window.location.href='?page=geom';" type="button"  value="BACK" style="width: 
                        	120px; height: 70px; -webkit-appearance: none; background-color:#00457c; font-weight:bold; 
                            font-size:18px; color:#adafb2; margin-top:20px; margin-bottom:20px; margin-right:10px; display
                            : inline;" /> 
                    	<input onclick="window.location.href='?page=mat';" type="button"  value="NEXT" style="width: 
                    		120px; height: 70px; -webkit-appearance: none; background-color:#00457c; font-weight:bold; 
                            font-size:18px; color:#adafb2; margin-top:20px; margin-bottom:20px; display:inline;" />
                    </p>    
                </div><!-- End .rightcol -->
            </div><!-- end .subcontent-->   
</form>