﻿function formVal()
{

  var radioSelected = false;
  for (i = 0;  i < document.theForm.PUNCTUAL.length;  i++)
  {
    if (document.theForm.PUNCTUAL[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Are you usually on time, early or late?  Please select your answer.");
    return (false);
  }

  var radioSelected = false;
  for (i = 0;  i < document.theForm.FREQU.length;  i++)
  {
    if (document.theForm.FREQU[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How frequently do you wear a watch?  Please select your answer.");
    return (false);
  }

 var radioSelected = false;
  for (i = 0;  i < document.theForm.HOW_MANY.length;  i++)
  {
    if (document.theForm.HOW_MANY[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How many watches do you own?  Please select your answer.");
    return (false);
  }

 var found_it3 //initial value is null because we gave it no other value


  for (var i=0; i<document.theForm.KIND.length; i++)  { 
if (document.theForm.KIND[i].checked)  {

found_it3 = document.theForm.KIND[i].value //set found_it equal to checked button's value
//alert(found_it)
} 
}

if(!found_it3)

{
alert("What kind of watch do you wear most often?  Please click on the appropriate circle.")
return false; 

}


if(found_it3 == "OTHER_KIND" && document.theForm.DESCR_OTHER_KIND.value ==""){ //if found_it is NOT equal to null, a button HAS been checked

alert("Please tell us what kind of watch you wear in the space provided.")
document.theForm.DESCR_OTHER_KIND.focus();
return false; 

}

if(found_it3 == "OTHER_KIND" && document.theForm.DESCR_OTHER_KIND.value.length < 3){ //if found_it is NOT equal to null, a button HAS been checked

alert("Please tell us what kind of watch you wear in the space provided. You must enter at least 3 characters in this field.")
document.theForm.DESCR_OTHER_KIND.focus();
return false; 

}

if(found_it3 == "OTHER_KIND" && document.theForm.DESCR_OTHER_KIND.value.length > 14){ //if found_it is NOT equal to null, a button HAS been checked

alert("Please do not enter more than 14 characters for the kind of watch you wear.")
document.theForm.DESCR_OTHER_KIND.focus();
return false; 

}

var radioSelected = false;
  for (i = 0;  i < document.theForm.COST.length;  i++)
  {
    if (document.theForm.COST[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How much money did you spend on the watch you wear most often?  Please select your answer.");
    return (false);
  }

 if (document.theForm.JEWELER.checked == false && document.theForm.ONLINE.checked == false && document.theForm.CATALOG.checked == false && document.theForm.DSCT.checked == false && document.theForm.RET.checked == false && document.theForm.DEPT.checked == false && document.theForm.OTHER.checked == false)

  {
    alert("Where do you typically purchase a watch?  Please check all that apply.");
    return (false);
  }

 if (document.theForm.OTHER.checked == true && document.theForm.DESCR_OTHER.value == "")

{
    alert("Please tell us where you purchase a watch in the space provided.");
    document.theForm.DESCR_OTHER.focus();
    return (false);
  }

 if (document.theForm.OTHER.checked == true && document.theForm.DESCR_OTHER.value.length < 3)

{
    alert("Please tell us where you purchase a watch in the space provided. You must enter at least 3 characters in this field.");
    document.theForm.DESCR_OTHER.focus();
    return (false);
  }

 if (document.theForm.OTHER.checked == true && document.theForm.DESCR_OTHER.value.length > 20)

{
    alert("Please do not enter more than 20 characters for where you purchase a watch.");
    document.theForm.DESCR_OTHER.focus();
    return (false);
  }


  var radioSelected = false;
  for (i = 0;  i < document.theForm.PURCH.length;  i++)
  {
    if (document.theForm.PURCH[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How many times a year do you purchase a watch for yourself?  Please select your answer.");
    return (false);
  }

 if (document.theForm.TV.checked == false && document.theForm.ONLINE_AD.checked == false && document.theForm.MAGAD.checked == false && document.theForm.DISPLAY.checked == false && document.theForm.REC.checked == false && document.theForm.ENDORSE.checked == false && document.theForm.MATCH.checked == false && document.theForm.OTHER_REASON.checked == false)

  {
    alert("How did you select the watch you wear most often?  Please check all that apply.");
    return (false);
  }

if (document.theForm.OTHER_REASON.checked == true && document.theForm.DESCR_OTHER_REASON.value == "")

{
    alert("Please tell how you selected your watch in the space provided.");
    document.theForm.DESCR_OTHER_REASON.focus();
    return (false);
  }

if (document.theForm.OTHER_REASON.checked == true && document.theForm.DESCR_OTHER_REASON.value.length < 3)

{
    alert("Please tell how you selected your watch in the space provided. You must enter at least 3 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 > 14)

{
    alert("Please do not enter more than 14 characters for your description of how you selected your watch.");
    document.theForm.DESCR_OTHER_REASON.focus();
    return (false);
  }


 if (document.theForm.REL.checked == false && document.theForm.COMFORT.checked == false && document.theForm.STYLE.checked == false && document.theForm.SIZE.checked == false && document.theForm.OTHER_SELECT.checked == false)

  {
    alert("Why did you select the watch you wear most often?  Please check all that apply.");
    return (false);
  }

if (document.theForm.OTHER_SELECT.checked == true && document.theForm.DESCR_OTHER_SELECT.value == "")

{
    alert("Please tell why you selected your watch in the space provided.");
    document.theForm.DESCR_OTHER_SELECT.focus();
    return (false);
  }

if (document.theForm.OTHER_SELECT.checked == true && document.theForm.DESCR_OTHER_SELECT.value.length < 3)

{
    alert("Please tell why you selected your watch in the space provided. You must enter at least 3 characters in this field.");
    document.theForm.DESCR_OTHER_SELECT.focus();
    return (false);
  }

if (document.theForm.OTHER_SELECT.checked == true && document.theForm.DESCR_OTHER_SELECT.value.length > 14)

{
    alert("Please do not enter more than 14 characters for your explanation of why you selected your watch.");
    document.theForm.DESCR_OTHER_SELECT.focus();
    return (false);
  }

  var radioSelected = false;
  for (i = 0;  i < document.theForm.REPAIR.length;  i++)
  {
    if (document.theForm.REPAIR[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("If your watch stops working, will you repair it or purchase a new one?  Please select your answer.");
    return (false);
  }
  
 if (document.theForm.Review.value == "")
  {
    alert("Please enter your first review.");
    document.theForm.Review.focus();
    return (false);
  }

//begin word counter


 var expresscount1, expressshort1;
expresscount1 = countWords1();
//alert("expresscount = " + expresscount);
expressshort1 = 25 - expresscount1;
//alert("expressshort = " + expressshort);

if (expresscount1 < 25)
{
alert("The total number of words you have entered is " + expresscount1 + ". You must write at least another " + expressshort1 + " words.");
      document.theForm.Review.focus(); 
    return (false);
  }

if (expresscount1 > 50)
{
alert("The total number of words you have entered is " + expresscount1 + ". 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 countWords1()
{	
var wordcount1;


wordcount1 = 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 (wordcount1);
}
  
  
  
  
  //2nd review
    
 if (document.theForm.Review2.value == "")
  {
    alert("Please enter your second review.");
    document.theForm.Review2.focus();
    return (false);
  }

//begin word counter


 var expresscount2, expressshort2;
expresscount2 = countWords2();
//alert("expresscount = " + expresscount);
expressshort2 = 25 - expresscount2;
//alert("expressshort = " + expressshort);

if (expresscount2 < 25)
{
alert("The total number of words you have entered is " + expresscount2 + ". You must write at least another " + expressshort2 + " words.");
      document.theForm.Review2.focus(); 
    return (false);
  }

if (expresscount2 > 50)
{
alert("The total number of words you have entered is " + expresscount2 + ". Please do not write more than 50 words.");
      document.theForm.Review2.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 countWords2()
{	
var wordcount2;


wordcount2 = document.theForm.Review2.value.split(" ").length;

return (wordcount2);
}
    
 if (document.theForm.Rating.selectedIndex == 0)

  {
    alert("Please select your overall product 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);
}
 