var bigstring = " ";

function doesexist(inputValue, inputExpected) {
  var aCharExists=0
  if (inputValue) {
    for (var i=0; i<inputValue.length; i++) {
      if (inputValue.charAt(i) != " ") {
        aCharExists = 1
      }
    }
    //print(inputValue)
  }
  if (!aCharExists) {
    bigstring = bigstring += inputExpected += "\n ";
  }
}
function doesexistradio(inputValue, inputExpected, size) {
	sum=0;
	for(i=0; i<size; i++)
		if (inputValue[i].checked == true)
			sum++;
	if (!sum) {
		bigstring = bigstring += inputExpected += "\n ";
		return false
  	}
  	return true
  	
}

function validate_rate_fields() {
  doesexist(document.Form1.product.value, '- Product')
  doesexist(document.Form1.pick_up_location.value, '- Pick Up Location')
  doesexist(document.Form1.delivery_location.value, '- Delivery Location')
  doesexist(document.Form1.contact_person.value, '- Contact Person')
  doesexist(document.Form1.email.value, '- Email')
  doesexist(document.Form1.phone_number.value, '- Phone Number')
  
  
  //if ((document.form1.owner_operator.checked == "")&&(document.form1.company_driver.checked == 0)&&(document.form1.student.checked == 0)){
  //  inputExpected = '- To Whom Would You Like The Message Go\n ';    
  //  bigstring = bigstring += inputExpected
  //} 
  if (bigstring != " "){
    alert("Please complete the following fields: \n" + bigstring)
    bigstring = " "
    return false
  }
  return true
}
function validate_application_fields() {
		
	doesexist(document.Form2.full_name.value, '- Full Name')
	doesexist(document.Form2.address.value, '- Address')
	doesexist(document.Form2.city.value, '- City')
	doesexist(document.Form2.state.value, '- State')
	doesexist(document.Form2.zip.value, '- Zip')
	doesexist(document.Form2.home_phone.value, '- Home Phone')
	doesexist(document.Form2.dob_month.value, '- DOB Month')
	doesexist(document.Form2.dob_day.value, '- DOB Day')
	doesexist(document.Form2.dob_year.value, '- DOB Year')
	doesexist(document.Form2.ssn1.value, '- SSN First Part')
	doesexist(document.Form2.ssn2.value, '- SSN Second Part')
	doesexist(document.Form2.ssn3.value, '- SSN Third Part')
	
//	doesexist(document.Form2.emp_0_name.value, '- Most Recent Employer Name')
//	doesexist(document.Form2.emp_0_address.value, '- Most Recent Employer Address')
//	doesexist(document.Form2.emp_0_city.value, '- Most Recent Employer City')
//	doesexist(document.Form2.emp_0_state.value, '- Most Recent Employer State')
//	doesexist(document.Form2.emp_0_zip.value, '- Most Recent Employer ZIP')
//	doesexist(document.Form2.emp_0_contact.value, '- Most Recent Employer Contact Name')
//	doesexist(document.Form2.emp_0_phone.value, '- Most Recent Employer Phone')
//	doesexist(document.Form2.emp_0_position_held.value, '- Most Recent Employer Position Held')
//	doesexist(document.Form2.emp_0_pay.value, '- Most Recent Employer Pay')
//	doesexist(document.Form2.emp_0_from_date.value, '- Most Recent Employer From Date')
//	doesexist(document.Form2.emp_0_to_date.value, '- Most Recent Employer To Date')
//	doesexist(document.Form2.emp_0_reason_left.value, '- Most Recent Employer Reason Left')

	doesexist(document.Form2.highest_grade.value, '- Highest Grade Completed')
	doesexist(document.Form2.cdl_0_state.value, '- Most Recent CDL State')
	doesexist(document.Form2.cdl_0_number.value, '- Most Recent CDL Number')
	doesexist(document.Form2.cdl_0_type.value, '- Most Recent CDL Type')
	doesexist(document.Form2.cdl_0_expire.value, '- Most Recent CDL Expiration Date')
  
	doesexistradio(document.Form2.work_in_US, '- Right To Work In US',2)
	doesexistradio(document.Form2.worked_here_before, '- Worked Here Before',2)
	doesexistradio(document.Form2.currently_employed, '- Are You Currently Employed',2)
	doesexistradio(document.Form2.unable_to_perform, '- Is there any reason you might be unable to perform the functions of the job for which you have applied',2)
	doesexistradio(document.Form2.cdl_denied, '- Have you been denied a license, permit, or privilege to operate a motor vehicle',2)
	doesexistradio(document.Form2.cdl_revoked, '- Has any license, permit, or privilege ever been suspended or revoked',2)

  if (bigstring != " "){
    alert("Please complete the following fields: \n" + bigstring)
    bigstring = " "
    return false
  }
  return true
}