function wc(teaser,content,count)
{
	var i;
	var curLen = 0;
	strArray = teaser.value.split(' ');
	
	for (i=0; i<strArray.length; i++) {
		if (strArray[i].length > 0) curLen++;
	}
	strArray = content.value.replace(new RegExp(/\n/g), " ").split(' ');
	for (i=0; i<strArray.length; i++) {
		if (strArray[i].length > 0) curLen++;
	}
	count.value = curLen;	
}

function Form_Validator(theForm)
{
  var check = new RegExp(/^\({0,1}[0-9]{3}\){0,1}[ \-\.]{0,1}[0-9]{3}[ \-\.]{0,1}[0-9]{4}$/);

  if (!validPersonsName(theForm.name, 5, 60, true)) {
  	return (false);
  }

  if (!validEmailAddress(theForm.email)) {
  	return (false);
  }  
  
  if (theForm.phone.value != "") {
  	if (theForm.phone.value.length > 14) {
  		alert("Phone number must be less than 15 characters long");
	    theForm.phone.focus();
	    return (false);
	}
	if (!check.test(theForm.phone.value)) {
     	alert("Phone number must be 10 digits that can additionally have parentheses, hyphens, periods and spaces");
     	theForm.phone.focus();
	  	return (false);
	}
  }

  if (!validMemberNumber(theForm)) {
    theForm.number.focus();
  	return (false);
  }

  if (theForm.teaser.value == "") {
  	alert("You must enter in part of your ad as the teaser line");
  	theForm.teaser.focus();
  	return (false);
  }
  if (theForm.teaser.value.length < 10) {
  	alert("You must enter at least ten characters in the teaser line");
  	theForm.teaser.focus();
  	return (false);
  }
  
  if (theForm.content.value == "")
  {
    alert("Please enter text into the \"content\" area.");
    theForm.content.focus();
    return (false);
  }
  if (theForm.content.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"content\" area.");
    theForm.content.focus();
    return (false);
  }
  
  if (theForm.content.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"content\" area.");
    theForm.content.focus();
    return (false);
  }
  
  if (theForm.counter.value > 50) {
  	alert("The teaser line and ad content must be fifty words or less(" + theForm.counter.value + ").");
   	theForm.content.focus();
   	return (false);
  }
  if (theForm.response.value != "") {
    if (theForm.response.value.length < 10) {
    	alert("Ad rejection response text must be at least 10 characters long.");
        theForm.response.focus();
    	return(false);
    }
  
    if (theForm.response.value.length > 1000) {
      alert("Ad rejection response text must be 1000 characters or less.");
      theForm.response.focus();
  	  return(false);
    }
  }
  
  	
  if (!validSecurityCode(theForm)) {
  	return (false);
  }  
  
  return (true);
}
