﻿function golfVal()
{

var radioSelected = false;
  for (i = 0;  i < document.golfform.often.length;  i++)
  {
    if (document.golfform.often[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How many times a year do you play golf?  Please click on the appropriate circle.");
    return (false);
  }

/*
var radioSelected = false;
  for (i = 0;  i < document.golfform.putter.length;  i++)
  {
    if (document.golfform.putter[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("What brand of putter do you use?  Please click on the appropriate circle.");
    return (false);
  }

var radioSelected = false;
  for (i = 0;  i < document.golfform.type.length;  i++)
  {
    if (document.golfform.type[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("What length putter do you use?  Please click on the appropriate circle.");
    return (false);
  }

var radioSelected = false;
  for (i = 0;  i < document.golfform.driver.length;  i++)
  {
    if (document.golfform.driver[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("What brand of driver do you use?  Please click on the appropriate circle.");
    return (false);
  }
*/
if (document.golfform.club.selectedIndex == 0)

  {
    alert("Do you belong to a golf club?  Please select your answer.");
    document.golfform.club.focus();
    return (false);
  }


/*
var radioSelected = false;
  for (i = 0;  i < document.golfform.club.length;  i++)
  {
    if (document.golfform.club[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Do you belong to a club?  Please click on the appropriate circle.");
    return (false);
  }
*/
var radioSelected = false;
  for (i = 0;  i < document.golfform.lessons.length;  i++)
  {
    if (document.golfform.lessons[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("How many golf lessons do you take in a year?  Please click on the appropriate circle.");
    return (false);
  }

if (document.golfform.drive.checked == false && document.golfform.putt.checked == false && document.golfform.wedges.checked == false && document.golfform.balls.checked == false && document.golfform.woods.checked == false && document.golfform.irons.checked == false && document.golfform.gloves.checked == false && document.golfform.shoes.checked == false && document.golfform.na.checked == false)

  {
    alert("Please tell us which items you plan on purchasing in the next 6 months.");
    return (false);
  }

if (document.golfform.club.selectedIndex == 2 && document.golfform.price.checked == false && document.golfform.trial.checked == false && document.golfform.recom.checked == false && document.golfform.fit.checked == false && document.golfform.ad.checked == false && document.golfform.other_sel.checked == false && document.golfform.friend.checked == false && document.golfform.neverb.checked == false)

  {
    alert("Please tell us 3 reasons why you selected your last golf club. If you have never belonged to a golf club, please check 'I have never belonged to a golf club.'");
    return (false);
  }
  
  if (document.golfform.club.selectedIndex == 1 && document.golfform.price.checked == false && document.golfform.trial.checked == false && document.golfform.recom.checked == false && document.golfform.fit.checked == false && document.golfform.ad.checked == false && document.golfform.other_sel.checked == false && document.golfform.friend.checked == false && document.golfform.neverb.checked == false)

  {
    alert("Please tell us 3 reasons why you selected your last golf club.");
    return (false);
  }

  
  if (document.golfform.club.selectedIndex == 1 && document.golfform.neverb.checked == true)

  {
    alert("Your answer to Question 2 indicates that you currently belong to a golf club. Please select 3 reasons why you have chosen this golf club.");
    return (false);
  }


/*
if (document.golfform.neverb.checked == true && document.golfform.price.checked == true) || (document.golfform.neverb.checked == true && document.golfform.trial.checked == true) || (document.golfform.neverb.checked == true && document.golfform.ad.checked == true) || (document.golfform.neverb.checked == true && document.golfform.friend.checked == true) || (document.golfform.neverb.checked == true && document.golfform.recom.checked == true) || (document.golfform.neverb.checked == true && document.golfform.fit.checked == true) || (document.golfform.neverb.checked == true && document.golfform.other_sel.checked == true)
	{
    alert("If you have never belonged to a golf club, please do not select any other reasons for selecting your last golf club.");
    return (false);
  	}
*/

if (document.golfform.neverb.checked == false)

var NewCount = 0

if (document.golfform.price.checked)
{NewCount = NewCount + 1}

if (document.golfform.trial.checked)
{NewCount = NewCount + 1}

if (document.golfform.recom.checked)
{NewCount = NewCount + 1}

if (document.golfform.fit.checked)
{NewCount = NewCount + 1}

if (document.golfform.ad.checked)
{NewCount = NewCount + 1}

if (document.golfform.other_sel.checked)
{NewCount = NewCount + 1}

if (document.golfform.friend.checked)
{NewCount = NewCount + 1}


if (NewCount < 3)
{
alert("Please check 3 reasons why you selected your last golf club.")
return (false);
}


/*
var formControls = document.golfform.elements;
var c = 0;
for (var i = 0; i < formControls.length; i++)
if (formControls[i].type.toLowerCase() == 'checkbox'
&& formControls[i].checked)
c++;
alert(c)
*/












if (document.golfform.other_sel.checked == true && document.golfform.other_reas.value == "")

	{
    alert("Please tell us why you selected your last golf club in the space provided.");
    document.golfform.other_reas.focus();
    return (false);
  	}

if (document.golfform.other_sel.checked == true && document.golfform.other_reas.length < 5)

	{
    alert("Please tell us why you selected your last golf club in the space provided. You must enter at least 5 characters in this field.");
    document.golfform.other_reas.focus();
    return (false);
  	}

if (document.golfform.other_sel.checked == true && document.golfform.other_reas.length > 20)

	{
    alert("Please do not enter more than 20 characters in this field.");
    document.golfform.other_reas.focus();
    return (false);
  	}


if (document.golfform.sports.checked == false && document.golfform.golf.checked == false && document.golfform.online.checked == false && document.golfform.proshop.checked == false && document.golfform.catalog.checked == false && document.golfform.other_purch.checked == false)

  {
    alert("Please tell us where you made your last golf equipment purchase.");
    return (false);
  }

if (document.golfform.other_purch.checked == true && document.golfform.other_descr.value == "") 

	{
    alert("Please tell us where you made your last golf equimpent purchase in the space provided.");
    document.golfform.other_descr.focus();
    return (false);
  	}

if (document.golfform.other_purch.checked == true && document.golfform.other_descr.length < 3) 

	{
    alert("Please tell us where you made your last golf equimpent purchase in the space provided. You must enter at least 3 characters in this field.");
    document.golfform.other_descr.focus();
    return (false);
  	}

if (document.golfform.other_purch.checked == true && document.golfform.other_descr.length > 20) 

	{
    alert("Please do not enter more than 20 characters for the name of the store where you last purchased golf equipment.");
    document.golfform.other_descr.focus();
    return (false);
  	}
/*
var radioSelected = false;
  for (i = 0;  i < document.golfform.service.length;  i++)
  {
    if (document.golfform.service[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please rate the service you were provided during your last golf equipment purchase.");
    return (false);
  }

var radioSelected = false;
  for (i = 0;  i < document.golfform.perform.length;  i++)
  {
    if (document.golfform.perform[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Did the equipment you last purchased perform to your expectations?  Please click on the appropriate circle.");
    return (false);
  }
*/
if (document.golfform.love.checked == false && document.golfform.social.checked == false && document.golfform.business.checked == false && document.golfform.compete.checked == false && document.golfform.other_play.checked == false)

  {
    alert("Please tell us why you play golf.");
    return (false);
  }

if (document.golfform.other_play.checked == true && document.golfform.why_play.value == "") 

	{
    alert("Please tell us in the space provided why you play golf.");
    document.golfform.why_play.focus();
    return (false);
  	}

if (document.golfform.other_play.checked == true && document.golfform.why_play.length < 5) 

	{
    alert("Please tell us in the space provided why you play golf. You must enter at least 5 characters in this field.");
    document.golfform.why_play.focus();
    return (false);
  	}

if (document.golfform.other_play.checked == true && document.golfform.why_play.length > 20) 

	{
    alert("Please do not enter more than 20 characters for your description of why you play golf.");
    document.golfform.why_play.focus();
    return (false);
  	}


  if (document.golfform.Review.value == "")
  {
    alert("Please enter your overall review.");
    document.golfform.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.golfform.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.golfform.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.golfform.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.golfform.Rating.selectedIndex == 0)

  {
    alert("Please select your overall product rating.");
    document.golfform.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.golfform.memkey.value = randomnum;
//alert(randomnum);
randomnum = document.golfform.memkey.value;
document.golfform.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; IT ONLY WORKS IN IE.

var chgkey;
chgkey = document.golfform.memkey.value;
//alert(chgkey);
document.golfform.memkey.value = randomnum;
chgkey = document.golfform.memkey.value;
//alert(chgkey);

document.cookie = "memcookie" + "=" + escape(golfform.memkey.value) + "; path=/"

  */  
  return (true);
}
 