﻿function yoVal()
{

if (document.yogurtform.yogurt.value == "")
  {
    alert("Please enter the name of the yogurt you eat.");
    document.yogurtform.yogurt.focus();
    return (false);
  }
  
  if (document.yogurtform.yogurt.value.length < 1)
  {
    alert("Please enter the name of the yogurt you eat.");
    document.yogurtform.yogurt.focus();
    return (false);
  }

  if (document.yogurtform.yogurt.value.length > 24)
  {
    alert("Please enter no more than 24 characters in the name of yogurt field.");
    document.yogurtform.yogurt.focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.yogurtform.often.length;  i++)
  {
    if (document.yogurtform.often[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How often do you eat yogurt?  Please click on the appropriate circle.");
    return (false);
  }

  if (document.yogurtform.grocery.checked == false && document.yogurtform.conven.checked == false && document.yogurtform.online.checked == false && document.yogurtform.disc.checked == false && document.yogurtform.drug.checked == false && document.yogurtform.other.checked == false)

  {
    alert("Please tell us where you buy your yogurt.");
    return (false);
  }

  if (document.yogurtform.other.checked == true && document.yogurtform.descr_other.value == "")

  {
	
	alert("Please tell us in one to two words where you buy your yogurt.");
	document.yogurtform.descr_other.focus();
	return (false);
  }
  
  if (document.yogurtform.dannon.checked == false && document.yogurtform.yoplait.checked == false && document.yogurtform.bc.checked == false && document.yogurtform.la_yog.checked == false && document.yogurtform.stony.checked == false && document.yogurtform.axel.checked == false && document.yogurtform.ww.checked == false && document.yogurtform.other_yog.checked == false)

  {
    alert("Please tell us which brand(s) of yogurt you eat.");
    return (false);
  }

  if (document.yogurtform.other_yog.checked == true && document.yogurtform.other_brand.value == "")

  {
	
	alert("Please tell us which other brand of yogurt you eat.");
	document.yogurtform.other_brand.focus();
	return (false);
  }
  

 var radioSelected = false;
  for (i = 0;  i < document.yogurtform.same.length;  i++)
  {
    if (document.yogurtform.same[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Do you always eat the same kind of yogurt?  Please click on the appropriate circle.");
    return (false);
  }
  

  if (document.yogurtform.like.checked == false && document.yogurtform.calc.checked == false && document.yogurtform.diet.checked == false && document.yogurtform.health.checked == false && document.yogurtform.easy.checked == false)

  {
    alert("Please tell us why you eat yogurt.");
    return (false);
  }

    if (document.yogurtform.allsame.checked == false && document.yogurtform.special.checked == false && document.yogurtform.coupon.checked == false && document.yogurtform.hungry.checked == false && document.yogurtform.other_switch.checked == false)

  {
    alert("Please tell us why you might switch brands.");
    return (false);
  }

  if (document.yogurtform.dislike.value == "")
  {
    alert("Please tell us the worst brand of yogurt you've ever had.");
    document.yogurtform.dislike.focus();
    return (false);
  }
  
  if (document.yogurtform.dislike.value.length < 1)
  {
    alert("Please tell us the worst brand of yogurt you've ever had.");
    document.yogurtform.dislike.focus();
    return (false);
  }

  if (document.yogurtform.dislike.value.length > 24)
  {
    alert("Please tell us the worst brand of yogurt you've ever had.");
    document.yogurtform.dislike.focus();
    return (false);
  }

  var radioSelected = false;
  for (i = 0;  i < document.yogurtform.add.length;  i++)
  {
    if (document.yogurtform.add[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Have you ever added anything to your yogurt for flavor?  Please click on the appropriate circle.");
    return (false);
  }
  
  if (document.yogurtform.Vanil.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Vanil.focus();
    return (false);
  }

   if (document.yogurtform.Plain.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Plain.focus();
    return (false);
  }

 if (document.yogurtform.Straw.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Straw.focus();
    return (false);
  }

  if (document.yogurtform.Pine.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Pine.focus();
    return (false);
  }

   if (document.yogurtform.Blue.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Blue.focus();
    return (false);
  }

   if (document.yogurtform.Coffee.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Coffee.focus();
    return (false);
  }
 
 if (document.yogurtform.Banan.selectedIndex == 0)

  {
    alert("Please select a ranking for all of the yogurt flavors listed.");
    document.yogurtform.Banan.focus();
    return (false);
  }
  

  if (document.yogurtform.Review.value == "")
  {
    alert("Please enter your overall review.");
    document.yogurtform.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.yogurtform.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.yogurtform.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.yogurtform.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.yogurtform.Rating.selectedIndex == 0)

  {
    alert("Please select your overall product rating.");
    document.yogurtform.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.yogurtform.memkey.value = randomnum;
//alert(randomnum);
randomnum = document.yogurtform.memkey.value;
document.yogurtform.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);
}




  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 