function trimAll(sString)
{
   while (sString.substring(0,1) == ' ')
   {
      sString = sString.substring(1, sString.length);
   }
   while (sString.substring(sString.length-1, sString.length) == ' ')
   {
      sString = sString.substring(0,sString.length-1);
   }
return sString;
}


// JavaScript Document


// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}

function Feedback_Validator(theForm)
{

  if (theForm.Comments.value == "")
  {
    alert("Please enter a valid comment in the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  //var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- \t\r\n\f";
  var checkStr = theForm.Name.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, whitespace and \"-\" characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserTel.value == "")
  {
    alert("Please enter a value for the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  if (theForm.UserTel.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  var checkOK = "0123456789-()- \t\r\n\f";
  var checkStr = theForm.UserTel.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"()-\" characters in the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  return (true);
}

function Advertise_Validator(theForm)
{

  if (theForm.Comments.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Comments.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Username.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Username.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Username\" field.");
    theForm.Username.focus();
    return (false);
  }

  //var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- \t\r\n\f";
  var checkStr = theForm.Username.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, whitespace and \"-\" characters in the \"Username\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserTel.value == "")
  {
    alert("Please enter a value for the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  if (theForm.UserTel.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  var checkOK = "0123456789-()-";
  var checkStr = theForm.UserTel.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"()-\" characters in the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  var checkOK = "0123456789-()-";
  var checkStr = theForm.UserFAX.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"()-\" characters in the \"UserFAX\" field.");
    theForm.UserFAX.focus();
    return (false);
  }
  return (true);
}

function Sales_Validator(theForm)
{

  if (theForm.Comments.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Comments.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }
  return (true);
}

function Contact_KOTA_Validator(theForm)
{

  if (theForm.Comments.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Comments.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Username.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Username.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Username\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserTel.value == "")
  {
    alert("Please enter a value for the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  if (theForm.UserTel.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  var checkOK = "0123456789-()-";
  var checkStr = theForm.UserTel.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"()-\" characters in the \"UserTel\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  return (true);
}

function Old_West_Night_Out_Validator(theForm)
{

  //var checkLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
  var checkLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  var checkNumbers = "0123456789"
  var checkWhitespace = " \t\r\n\f"
  
  if (theForm.Groupname.value == "")
  {
    alert("Please enter a value for the \"Group Name\" field.");
    theForm.Groupname.focus();
    return (false);
  }
  
  if (theForm.Groupname.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Group Name\" field.");
    theForm.Name.focus();
    return (false);
  }
  
  if (theForm.Username.value == "")
  {
    alert("Please enter a value for the \"Your Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Username.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Your Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  var checkOK = checkLetters + checkWhitespace + "-"
  var checkStr = theForm.Username.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letters, whitespace and \"-\" characters in the \"Your Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Address.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.Address.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.UserCityStateZIP.value == "")
  {
    alert("Please enter a value for the \"City/State/ZIP\" field.");
    theForm.UserCityStateZIP.focus();
    return (false);
  }

  if (theForm.UserCityStateZIP.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"City/State/ZIP\" field.");
    theForm.UserCityStateZIP.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"E-Mail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"E-Mail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }
  
  var checkOK = checkLetters + checkNumbers + "@-_."
  var checkStr = theForm.UserEmail.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letters, numbers, \"@\", \"-\", \"_\" and \".\" characters in the \"E-Mail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }
  
  if (theForm.UserTel.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  
  if (theForm.UserTel.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  
  var checkOK = checkNumbers + checkWhitespace + "-()extEXT."
  var checkStr = theForm.UserTel.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only numbers, parentheses, \"-\", \"EXT.\" and \"ext.\" characters in the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  
  if (valButton(theForm.Eligible) == null)
  {
	  	alert("Please indicate if you have won a Circle B prize in the past year.");
		return (false);
  }
  
  if (valButton(theForm.Eligible) == "No")
  {
	  alert("You have indicated you are not eligible. Please wait and try again next summer.");
	  return (false);
  }
              
  return (true);
}

function Contest_Entry_Validator(theForm)
{

  //var checkLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
  var checkLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  var checkNumbers = "0123456789"
  var checkWhitespace = " \t\r\n\f"
   
  if (theForm.Username.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Username.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  var checkOK = checkLetters + checkWhitespace + "-"
  var checkStr = theForm.Username.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letters, whitespace and \"-\" characters in the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Address.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.Address.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.UserCityStateZIP.value == "")
  {
    alert("Please enter a value for the \"City/State/ZIP\" field.");
    theForm.UserCityStateZIP.focus();
    return (false);
  }

  if (theForm.UserCityStateZIP.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"City/State/ZIP\" field.");
    theForm.UserCityStateZIP.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"E-Mail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"E-Mail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }
  
  var checkOK = checkLetters + checkNumbers + "@-_."
  var checkStr = theForm.UserEmail.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letters, numbers, \"@\", \"-\", \"_\" and \".\" characters in the \"E-Mail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }
  
  if (theForm.UserTel.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  
  if (theForm.UserTel.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  
  var checkOK = checkNumbers + checkWhitespace + "-()extEXT."
  var checkStr = theForm.UserTel.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only numbers, parentheses, \"-\", \"EXT.\" and \"ext.\" characters in the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }
  
  if (valButton(theForm.ContestType) == null)
  {
	  	alert("Please indicate which contest you want to enter.");
		return (false);
  }
  
              
  return (true);
}

function RadioNews_Validator(theForm)
{

  if (valButton(theForm.StoryType) == null)
  {
     alert("Please select a comment type from one of the radio buttons.");
     return (false);
  }

  if (theForm.Comments.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Comments.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Comments\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Username.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Username.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Email\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserTel.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  if (theForm.UserTel.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  var checkOK = "0123456789-()-";
  var checkStr = theForm.UserTel.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"()-\" characters in the \"Phone\" field.");
    theForm.UserTel.focus();
    return (false);
  }

  return (true);

}

function Instant_Message_KOTA_Validator(theForm)
{

  if (theForm.Comments.value == "")
  {
    alert("Please enter a value for the \"Message\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Comments.value.length > 1000)
  {
    alert("Please enter at most 1000 characters in the \"Message\" field.");
    theForm.Comments.focus();
    return (false);
  }

  if (theForm.Username.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.Username.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Name\" field.");
    theForm.Username.focus();
    return (false);
  }

  if (theForm.UserEmail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 60)
  {
    alert("Please enter at most 60 characters in the \"Email\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  return (true);
}

function submitform(theForm)
{
 if(theForm.onsubmit())
 {//this check triggers the validations
    theForm.submit();
 }
}

