// JavaScript Document
// JavaScript Document
// JavaScript Document
function Validator(theForm)
{

//Radio button 
if (!theForm.poster[0].checked && !theForm.poster[1].checked) {
	// no radio button is selected
	 alert("Please Select \"Post type\" field.");
	return false;
}



//First Name check
 if (theForm.p_title.value == "")
  {
    alert("Please enter a value for the \"Post title\" field.");
    theForm.p_title.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆ’Å Å’Å½Å¡Å“Å¾Å¸Ã€ÃÃ‚ÃƒÃ„Ã…Ã†Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃÃŽÃÃÃ‘Ã’Ã“Ã”Ã•Ã–Ã˜Ã™ÃšÃ›ÃœÃÃžÃŸÃ Ã¡Ã¢Ã£Ã¤Ã¥Ã¦Ã§Ã¨Ã©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã°Ã±Ã²Ã³Ã´ÃµÃ¶Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾Ã¿0123456789  . \t\r\n\f";
  var checkStr = theForm.p_title.value;
  var allValid = true;
  var validGroups = 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 in the \"Post title\" field.");
    theForm.p_title.focus();
    return (false);
  }


//Locatio validation
if (theForm.p_location.value == "")
  {
    alert("Please enter a value for the \"Closest city\" field.");
    theForm.p_location.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆ’Å Å’Å½Å¡Å“Å¾Å¸Ã€ÃÃ‚ÃƒÃ„Ã…Ã†Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃÃŽÃÃÃ‘Ã’Ã“Ã”Ã•Ã–Ã˜Ã™ÃšÃ›ÃœÃÃžÃŸÃ Ã¡Ã¢Ã£Ã¤Ã¥Ã¦Ã§Ã¨Ã©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã°Ã±Ã²Ã³Ã´ÃµÃ¶Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾Ã¿0123456789-$ % & - / . \t\r\n\f";
  var checkStr = theForm.p_location.value;
  var allValid = true;
  var validGroups = 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, digit, whitespace and \"$ % & - / .\" characters in the \"Closest city\" field.");
    theForm.p_location.focus();
    return (false);
  }


/* Validation for the select box */
if (theForm.p_f_type.selectedIndex ==0)
  {
    alert("Please select one of the \"Produce type\" options.");
    theForm.p_f_type.focus();
    return (false);
   }
 

//Food name check
 if (theForm.p_f_name.value == "")
  {
    alert("Please enter a value for the \"Food name\" field.");
    theForm.p_f_name.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆ’Å Å’Å½Å¡Å“Å¾Å¸Ã€ÃÃ‚ÃƒÃ„Ã…Ã†Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃÃŽÃÃÃ‘Ã’Ã“Ã”Ã•Ã–Ã˜Ã™ÃšÃ›ÃœÃÃžÃŸÃ Ã¡Ã¢Ã£Ã¤Ã¥Ã¦Ã§Ã¨Ã©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã°Ã±Ã²Ã³Ã´ÃµÃ¶Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾Ã¿ . \t\r\n\f";
  var checkStr = theForm.p_f_name.value;
  var allValid = true;
  var validGroups = 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 characters in the \"Food name\" field.");
    theForm.p_f_name.focus();
    return (false);
  }


//Description check
 if (theForm.p_description.value == "")
  {
    alert("Please enter a value for the \"Post description\" field.");
    theForm.p_description.focus();
    return (false);
  }



return true;
}













