<!-- Original:  James P. Dildine (jpd@wlsmail.com) -->
<!-- Web Site:  http://www.mste.uiuc.edu/dildine -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function solveBAC(form) {
var ounces = eval(form.ounces.value);
var percent = eval(form.percent.value);
var weight = eval(form.weight.value);
var hours = eval(form.hours.value);

var result = (ounces * percent * 0.075 / weight) - (hours * 0.015);
if (result < 0) {
message = "There is a negligible amount of alcohol in your system.  You are not legally intoxicated.";
result = "-- neglible amount --";
}
else {
if (result == "NaN")
mesage = "Please try again."; 
if (result > 0.079) 
message = "In California, you would be considered impaired and arrested.";
if (result < 0.079)
message = "You are not legally impaired";
}
form.message.value = message;
form.bacamount.value = result + " %";
}
//  End -->

function validate()
									{
									 try
									 {
										var theForm=document.duiquestionnaire;
										//alert(theForm.q47.selectedIndex);
/*										
										if(theForm.current_offense_date.value!="" && !isDate(theForm.current_offense_date.value))
										{
											alert("Please Enter Valid Date");
											theForm.current_offense_date.focus();
											return false;
										}
										if(theForm.time_when_arrested.value=="")
										{
											alert("Please enter approximately what time were you arrested?");
											theForm.time_when_arrested.focus();
											return false;
										}	
										flag=0;									
										for(i=0;i<theForm.pc_to_stop.length;i++)
										{
											if(theForm.pc_to_stop[i].checked)
											{
												flag=1;
												break;
											}	
										}
										if(flag==0 && theForm.other.value=="")
										{
											alert("please indicate the reason for the stop of your vehicle or contact with you?");
											theForm.other.focus();
											return false;										
										}
										
										if(theForm.alcohol_consumed.value=="Other" && theForm.other1.value=="")
										{
											alert("please indicate type of beverage?");
											theForm.alcohol_consumed.focus();
											return false;
										}
										
										if(theForm.finish_last_drink.value=="" && !theForm.drinks_consumed1.checked)
										{
											alert("Please specify Approximately what time did you finish \n your LAST alcoholic beverage before you were pulled over?");
											theForm.finish_last_drink.focus();
											return false;
										}		
										if(theForm.drugs_consumed.selectedIndex=="12" && theForm.other3.value=="" && !theForm.drinks_consumed2.checked)
										{
											alert("please indicate type of medication or drug?");
											theForm.other3.focus();
											return false;
										}										
										flag=0;									
										for(i=0;i<theForm.types24.length;i++)
										{
											if(theForm.types24[i].checked)
											{
												flag=1;
												break;
											}	
										}										
										if(flag==0 && theForm.other25.value=="" && !theForm.dont25.checked)
										{
											alert("please indicate what they made you do?");
											theForm.other25.focus();
											return false;										
										}										
										if(!theForm.q30[4].checked && theForm.q30[3].checked && theForm.q31.value=="" && !theForm.dont31.checked)
										{
											alert("What were the results of the test, if you know?");
											theForm.q31.focus();
											return false;																				
										}										
										if(theForm.q33[15].checked && theForm.q34.value=="")
										{
											alert("please explain what happened");
											theForm.q34.focus();
											return false;																				
										}	
																				
										if(theForm.q36.value=="Other" && theForm.q37.value=="")
										{
											alert("please indicate what happened?");
											theForm.q37.focus();
											return false;																				
										}		
										
										if(theForm.q40[1].checked && theForm.q41.value=="")
										{
											alert("Please Explane why not?");
											theForm.q41.focus();
											return false;																				
										}		
										
										if(theForm.q46.value=="")
										{
											alert("Name the city where the arrest took place?");
											theForm.q46.focus();
											return false;																				
										}			
										if(theForm.q47.selectedIndex==0)
										{
											alert(" In which California Superior Court are you scheduled to appear?");
											theForm.q47.focus();
											return false;																				
										}			
										if(theForm.q48.selectedIndex==0)
										{
											alert("In which Nevada Justice or Municipal Court are you scheduled to appear?");
											theForm.q48.focus();
											return false;																				
										}																		
										if(theForm.q49.value=="")
										{
											alert("When is your court date?");
											theForm.q49.focus();
											return false;																				
										}		
*/										
										if(theForm.name.value=="")
										{
											alert("Please Enter Your Name");
											theForm.name.focus();
											return false;																				
										}																												
										if(theForm.email.value=="")
										{
											alert("Please Enter Your E-Mail");
											theForm.email.focus();
											return false;																				
										}													
/*										
										if(theForm.address.value=="")
										{
											alert("Please Enter Your Address");
											theForm.address.focus();
											return false;																				
										}													
										if(theForm.city.value=="")
										{
											alert("Please Enter Your City");
											theForm.city.focus();
											return false;																				
										}			
										if(theForm.state.value=="")
										{
											alert("Please Enter Your State");
											theForm.state.focus();
											return false;																				
										}		
*/																				
										if(theForm.hphone.value=="")
										{
											alert("Please Enter Your Phone Number");
											theForm.hphone.focus();
											return false;																				
										}		
										if(theForm.preference.value=="")
										{
											alert("Contact Preference (how do you want to be contacted?)");
											theForm.preference.focus();
											return false;																				
										}				
										
										for(i=0;i<theForm.pc_to_stop.length;i++)
										{
											theForm.pc_to_stop[i].name="pc_to_stop[]";
										}
										for(i=0;i<theForm.types24.length;i++)
										{
											theForm.types24[i].name="types24[]";
										}	
										theForm.alcohol_consumed.name="alcohol_consumed[]";
										theForm.drugs_consumed.name="drugs_consumed[]";
										theForm.q36.name="q36[]";
										theForm.q39.name="q39[]";																	
										
										return true;
									}
									catch(e)
									{
										alert(e);
										return false;
									}																																			
										
									}