﻿function formVal()
{

  if (document.theForm.once.checked == false && document.theForm.twoandfour.checked == false && document.theForm.five.checked == false && document.theForm.never.checked == false && document.theForm.few_year.checked == false && document.theForm.few_month.checked == false && document.theForm.fivemoreweek.checked == false)

  {
    alert("Please tell us how many times a week you exercise.");
    return (false);
  }


  if (document.theForm.home.checked == false && document.theForm.outside.checked == false && document.theForm.gym.checked == false)

  {
    alert("Please tell us where you exercise.");
    return (false);
  }

  if (document.theForm.tread1.checked == false && document.theForm.row1.checked == false && document.theForm.fw1.checked == false && document.theForm.ellip1.checked == false && document.theForm.multigym1.checked == false && document.theForm.bike1.checked == false && document.theForm.funct_trainer1.checked == false && document.theForm.stepper1.checked == false && document.theForm.other1.checked == false && document.theForm.no_equip1.checked == false)

  {
    alert("Please tell us what exercise equipment you are currently using.");
    return (false);
  }

  if (document.theForm.tread2.checked == false && document.theForm.row2.checked == false && document.theForm.fw2.checked == false && document.theForm.ellip2.checked == false && document.theForm.multigym2.checked == false && document.theForm.bike2.checked == false && document.theForm.funct_trainer2.checked == false && document.theForm.stepper2.checked == false && document.theForm.other2.checked == false && document.theForm.no_equip2.checked == false)

  {
    alert("Please tell us what exercise equipment you own.");
    return (false);
  }

  if (document.theForm.no_equip2.checked == false && document.theForm.tread3.checked == false && document.theForm.row3.checked == false && document.theForm.fw3.checked == false && document.theForm.ellip3.checked == false && document.theForm.multigym3.checked == false && document.theForm.bike3.checked == false && document.theForm.funct_trainer3.checked == false && document.theForm.stepper3.checked == false && document.theForm.other3.checked == false && document.theForm.no_equip3.checked == false)

  {
    alert("Please tell us what exercise equipment you own and never use.");
    return (false);
  }

  if (document.theForm.run.checked == false && document.theForm.cycle.checked == false && document.theForm.swim.checked == false && document.theForm.walk.checked == false && document.theForm.cardio.checked == false && document.theForm.yoga.checked == false && document.theForm.spin.checked == false && document.theForm.pilates.checked == false && document.theForm.wt.checked == false && document.theForm.kb.checked == false && document.theForm.aerobics.checked == false && document.theForm.sports.checked == false && document.theForm.other_form.checked == false && document.theForm.none.checked == false)

  {
    alert("Please tell us what type(s) of exercise you have done this year.");
    return (false);
  }
  
   if (document.theForm.other_form.checked == true && document.theForm.descr_other_form.value == "")

  {
	
	alert("Please tell us what other type of exercise you have done in the space provided.");
	document.theForm.descr_other_form.focus();
	return (false);
  }
 
     if (document.theForm.other_form.checked == true && document.theForm.descr_other_form.value.length < 3)

  {
	
	alert("Please tell us what other type of exercise you have done in the space provided.  You must enter at least 3 characters in this field.");
	document.theForm.descr_other_form.focus();
	return (false);
  }

       if (document.theForm.other_form.checked == true && document.theForm.descr_other_form.value.length > 12)

  {
	
	alert("Please do not enter more than 12 characters for the type of exercise you listed.");
	document.theForm.descr_other_form.focus();
	return (false);
  }

  
  if (document.theForm.weightloss.checked == false && document.theForm.flex.checked == false && document.theForm.health.checked == false && document.theForm.enjoyment.checked == false && document.theForm.cardiovasfit.checked == false && document.theForm.strength.checked == false && document.theForm.mass.checked == false && document.theForm.other_reason.checked == false)

  {
    alert("Please tell us why you exercise.");
    return (false);
  }

  if (document.theForm.other_reason.checked == true && document.theForm.descr_other_reason.value == "")

  {
	
	alert("In one to two words in the space provided, please tell us why you exercise.");
	document.theForm.descr_other_reason.focus();
	return (false);
  }

  if (document.theForm.other_reason.checked == true && document.theForm.descr_other_reason.value.length < 4)

  {
	
	alert("In one to two words in the space provided, please tell us why you exercise.  You must enter at least 4 characters in this field.");
	document.theForm.descr_other_reason.focus();
	return (false);
  }

  if (document.theForm.other_reason.checked == true && document.theForm.descr_other_reason.value.length > 12)

  {
	
	alert("Please do not enter more than 12 characters for your description of why you exercise.");
	document.theForm.descr_other_reason.focus();
	return (false);
  }

  if (document.theForm.myself.checked == false && document.theForm.friendrel.checked == false && document.theForm.pet.checked == false && document.theForm.trainer.checked == false && document.theForm.group.checked == false && document.theForm.other_person.checked == false)

  {
    alert("Please tell us who you exercise with.");
    return (false);
  }

  if (document.theForm.other_person.checked == true && document.theForm.descr_other_person.value == "")

  {
	
	alert("Please tell us who you exercise with in the space provided.");
	document.theForm.descr_other_person.focus();
	return (false);
  }

  if (document.theForm.other_person.checked == true && document.theForm.descr_other_person.value.length < 4)

  {
	
	alert("Please tell us who you exercise with in the space provided.  You must enter at least 4 characters in this field.");
	document.theForm.descr_other_person.focus();
	return (false);
  }

  if (document.theForm.other_person.checked == true && document.theForm.descr_other_person.value.length > 12)

  {
	
	alert("Please do not enter more than 12 characters for the name of the person with whom you exercise.");
	document.theForm.descr_other_person.focus();
	return (false);
  }

 var radioSelected = false;
  for (i = 0;  i < document.theForm.tod.length;  i++)
  {
    if (document.theForm.tod[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("During what time of day do you usually work out?  Please click on the appropriate circle.");
    return (false);
  }


 var radioSelected = false;
  for (i = 0;  i < document.theForm.sneakers.length;  i++)
  {
    if (document.theForm.sneakers[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How many pairs of sneakers do you own?  Please click on the appropriate circle.");
    return (false);
  }



if (document.theForm.how_long.value == "")
  {
    alert("How long have you been exercising?");
    document.theForm.how_long.focus();
    return (false);
  }
  
  if (document.theForm.how_long.value.length < 3)
  {
    alert("Please tell us for how long you have been exercising.  You must enter at least 3 characters in this field.");
    document.theForm.how_long.focus();
    return (false);
  }

  if (document.theForm.how_long.value.length > 12)
  {
    alert("Please do not enter more than 12 characters for the amount of time you have been exercising.");
    document.theForm.how_long.focus();
    return (false);
  }
  
    

  if (document.theForm.Review.value == "")
  {
    alert("Please enter your overall review.");
    document.theForm.Review.focus();
    return (false);
  }

//begin word counter


 var expresscount, expressshort;
expresscount = countWords();
//alert("expresscount = " + expresscount);
expressshort = 25 - expresscount;
//alert("expressshort = " + expressshort);

if (expresscount < 25)
{
alert("The total number of words you have entered is " + expresscount + ". You must write at least another " + expressshort + " words.");
      document.theForm.Review.focus(); 
    return (false);
  }

if (expresscount > 50)
{
alert("The total number of words you have entered is " + expresscount + ". Please do not write more than 50 words.");
      document.theForm.Review.focus(); 
    return (false);
  }

  
/*       
    //alert("expresscount = " + expresscount);
   if (expresscount >= 250 || expresscount <= 500)
    {
    document.survs3k351.expressval.value = "250";
    }
    else
    {
    document.survs3k351.expertval.value = "500";
  }
 
  return (true);
}
*/

function countWords()
{	
var wordcount;


wordcount = document.theForm.Review.value.split(" ").length;
//alert(wordcount);
//theRegExp = /^\s/g;

//wordcount = theForm.ebay6.value.replace(theRegExp, "");
//alert(item);


//wordcount2 = theForm.ebay6.value.split(theRegExp).length;
//wordcount = wordcount2.split("|").length;
return (wordcount);
}
  
  
 if (document.theForm.Rating.selectedIndex == 0)

  {
    alert("Please select your overall equipment rating.");
    document.theForm.Rating.focus();
    return (false);
  }
    
  var randomnum;
//alert(Math.random());
randomnum = (Math.random()*10000000000);
//alert(randomnum);
randomnum = Math.round(randomnum);
//alert(randomnum);


//alert(randomnum);
//var chgkey;
//chgkey = document.npdForm.id.value;
//alert(chgkey);
document.theForm.memkey.value = randomnum;
//alert(randomnum);
randomnum = document.theForm.memkey.value;
document.theForm.memkey.value = randomnum;
//alert(randomnum);

//chgkey = document.npdForm.id.value;
//alert("chgkey =",chgkey);

//document.npdForm.cookie = "idcookie" + "=" + escape(document.npdForm.id.value) + "; path=/"
document.cookie = "memcookie" + "=" + escape(randomnum) + "; path=/"





/* THIS CODE DOESN'T SET A COOKIE IN FIREFOX; ONLY WORKS IN IE.

var chgkey;
chgkey = document.theForm.memkey.value;
//alert(chgkey);
document.theForm.memkey.value = randomnum;
chgkey = document.theForm.memkey.value;
//alert(chgkey);

document.cookie = "memcookie" + "=" + escape(theForm.memkey.value) + "; path=/"
*/
  
  return (true);
}




  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 