// JavaScript Document

// Feedback Form Validation
// Developed by Hooman Noori 
// for ShoeSurfing Network Feedback Forms
// Copyright 2009 



function valbutton(thisform) {
// Question 1
  q1Opt = -1;
  for (i=thisform.question1.length-1; i > -1; i--) {
  if (thisform.question1[i].checked) {
  q1Opt = i; i = -1;
  }
  }
  if (q1Opt == -1) {
  alert("Please respond to Question 1.");
  return false;
  }
  
// Question 2
  q2Opt = -1;
  for (i=thisform.question2.length-1; i > -1; i--) {
  if (thisform.question2[i].checked) {
  q2Opt = i; i = -1;
  }
  }
  if (q2Opt == -1) {
  alert("Please respond to Question 2.");
  return false;
  }
  
// Question 4
  q4Opt = -1;
  for (i=thisform.question4.length-1; i > -1; i--) {
  if (thisform.question4[i].checked) {
  q4Opt = i; i = -1;
  }
  }
  if (q4Opt == -1) {
  alert("Please respond to Question 4.");
  return false;
  }
  
// Question 5
  q5Opt = -1;
  for (i=thisform.question5.length-1; i > -1; i--) {
  if (thisform.question5[i].checked) {
  q5Opt = i; i = -1;
  }
  }
  if (q5Opt == -1) {
  alert("Please respond to Question 5.");
  return false;
  }
  
// Question 7
  q7Opt = -1;
  for (i=thisform.question7.length-1; i > -1; i--) {
  if (thisform.question7[i].checked) {
  q7Opt = i; i = -1;
  }
  }
  if (q7Opt == -1) {
  alert("Please respond to Question 7.");
  return false;
  }
  
// Question 8
  q8Opt = -1;
  for (i=thisform.question8.length-1; i > -1; i--) {
  if (thisform.question8[i].checked) {
  q8Opt = i; i = -1;
  }
  }
  if (q8Opt == -1) {
  alert("Please respond to Question 8.");
  return false;
  }
  
// Question 8 A
  
  q8aOpt = -1;
  for (i=thisform.question8a.length-1; i > -1; i--) {
  if (thisform.question8a[i].checked) {
  q8aOpt = i; i = -1;
  }
  }
    if (q8aOpt == -1) {
    alert("Please respond to Question 8a.");
    return false;
  }
    
  // Question 8 B
    q8bOpt = -1;
    for (i=thisform.question8b.length-1; i > -1; i--) {
    if (thisform.question8b[i].checked) {
    q8bOpt = i; i = -1;
    }
    }
      if (q8bOpt == -1) {
      alert("Please respond to Question 8b.");
      return false;
  }
  
// Question 9
  q9Opt = -1;
  for (i=thisform.question9.length-1; i > -1; i--) {
  if (thisform.question9[i].checked) {
  q9Opt = i; i = -1;
  }
  }
  if (q9Opt == -1) {
  alert("Please respond to Question 9.");
  return false;
  }

//Store Variables: 
  
  //Question 1
  var q1Var = "";
  var q1Var = (thisform.question1[q1Opt].value);
  document.feedback_form.q1hid.value = q1Var;
  
  //Question 2
  var q2Var = "";
  var q2Var = (thisform.question2[q2Opt].value);
  document.feedback_form.q2hid.value = q2Var;
  
  //Question 3
  var q3Var = "";
  var q3Var = (thisform.question3.value);
  document.feedback_form.q3hid.value = q3Var;
  
  //Question 4
  var q4Var = "";
  var q4Var = (thisform.question4[q4Opt].value);
  document.feedback_form.q4hid.value = q4Var;
  
  //Question 5
  var q5Var = "";
  var q5Var = (thisform.question5[q5Opt].value);
  document.feedback_form.q5hid.value = q5Var;
  
    //Question 5b (textarea)
    var q5bVar = "";
    var q5bVar = (thisform.question5b.value);
    document.feedback_form.q5bhid.value = q5bVar;
  
  //Question 6
  var q6Var = "";
  var q6Var = (thisform.question6.value);
  document.feedback_form.q6hid.value = q6Var;
  
  //Question 7
  var q7Var = "";
  var q7Var = (thisform.question7[q7Opt].value);
  document.feedback_form.q7hid.value = q7Var;
  
  //Question 8
  var q8Var = "";
  var q8Var = (thisform.question8[q8Opt].value);
  document.feedback_form.q8hid.value = q8Var;
  
    //Question 8 A
    var q8aVar = "";
    var q8aVar = (thisform.question8a[q8aOpt].value);
    document.feedback_form.q8ahid.value = q8aVar;
    
    //Question 8 B
    var q8bVar = "";
    var q8bVar = (thisform.question8b[q8bOpt].value);
    document.feedback_form.q8bhid.value = q8bVar;
  
  //Question 9
  var q9Var = "";
  var q9Var = (thisform.question9[q9Opt].value);
  document.feedback_form.q9hid.value = q9Var;
  
  //Question 10 (textarea)
  var q10Var = "";
  var q10Var = (thisform.question10.value);
  document.feedback_form.q10hid.value = q10Var;
  
  //Name (input)
  var subscriberVar = "";
  var subscriberVar = (thisform.subscriber.value);
  document.feedback_form.subscriberhid.value = subscriberVar;

  //Email (input)
  var emailVar = "";
  var emailVar = (thisform.email.value);
  document.feedback_form.emailhid.value = emailVar;
  
// submit form after validating
  thisform.submit(); 
  
  }
